diff --git a/3rd-dependencies/listDeps.sh b/3rd-dependencies/listDeps.sh old mode 100755 new mode 100644 diff --git a/examples/hawkbit-example-app/pom.xml b/examples/hawkbit-example-app/pom.xml index fccd835bc..86ce5d9eb 100644 --- a/examples/hawkbit-example-app/pom.xml +++ b/examples/hawkbit-example-app/pom.xml @@ -64,7 +64,12 @@ org.eclipse.hawkbit - hawkbit-rest-resource + hawkbit-mgmt-resource + ${project.version} + + + org.eclipse.hawkbit + hawkbit-system-resource ${project.version} diff --git a/examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/Start.java b/examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/Start.java index 382d90c20..76d89af33 100644 --- a/examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/Start.java +++ b/examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/Start.java @@ -11,7 +11,8 @@ package org.eclipse.hawkbit.app; import org.eclipse.hawkbit.RepositoryApplicationConfiguration; import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration; import org.eclipse.hawkbit.ddi.annotation.EnableDdiApi; -import org.eclipse.hawkbit.rest.resource.EnableRestResources; +import org.eclipse.hawkbit.mgmt.annotation.EnableMgmtApi; +import org.eclipse.hawkbit.system.annotation.EnableSystemApi; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Import; @@ -24,8 +25,9 @@ import org.springframework.context.annotation.Import; @SpringBootApplication @Import({ RepositoryApplicationConfiguration.class }) @EnableHawkbitManagedSecurityConfiguration -@EnableRestResources +@EnableMgmtApi @EnableDdiApi +@EnableSystemApi public class Start { /** diff --git a/examples/hawkbit-mgmt-api-client/pom.xml b/examples/hawkbit-mgmt-api-client/pom.xml index 9aaf53dc6..051252d12 100644 --- a/examples/hawkbit-mgmt-api-client/pom.xml +++ b/examples/hawkbit-mgmt-api-client/pom.xml @@ -57,7 +57,7 @@ org.eclipse.hawkbit - hawkbit-rest-api + hawkbit-mgmt-api ${project.version} diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/DistributionSetResourceClient.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/DistributionSetResourceClient.java index 5ac11e012..11df8c323 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/DistributionSetResourceClient.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/DistributionSetResourceClient.java @@ -8,13 +8,13 @@ */ package org.eclipse.hawkbit.mgmt.client.resource; -import org.eclipse.hawkbit.rest.resource.api.DistributionSetRestApi; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi; import org.springframework.cloud.netflix.feign.FeignClient; /** * Client binding for the DistributionSet resource of the management API. */ @FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/distributionsets") -public interface DistributionSetResourceClient extends DistributionSetRestApi { +public interface DistributionSetResourceClient extends MgmtDistributionSetRestApi { } diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/DistributionSetTagResourceClient.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/DistributionSetTagResourceClient.java index 5fbdaf857..628304e26 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/DistributionSetTagResourceClient.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/DistributionSetTagResourceClient.java @@ -8,13 +8,13 @@ */ package org.eclipse.hawkbit.mgmt.client.resource; -import org.eclipse.hawkbit.rest.resource.api.DistributionSetTagRestApi; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi; import org.springframework.cloud.netflix.feign.FeignClient; /** * Client binding for the DistributionSetTag resource of the management API. */ @FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/distributionsettags") -public interface DistributionSetTagResourceClient extends DistributionSetTagRestApi { +public interface DistributionSetTagResourceClient extends MgmtDistributionSetTagRestApi { } diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/DistributionSetTypeResourceClient.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/DistributionSetTypeResourceClient.java index 300f8ddcb..871f79beb 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/DistributionSetTypeResourceClient.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/DistributionSetTypeResourceClient.java @@ -8,7 +8,7 @@ */ package org.eclipse.hawkbit.mgmt.client.resource; -import org.eclipse.hawkbit.rest.resource.api.DistributionSetTypeRestApi; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi; import org.springframework.cloud.netflix.feign.FeignClient; /** @@ -16,6 +16,6 @@ import org.springframework.cloud.netflix.feign.FeignClient; * */ @FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/distributionsettypes") -public interface DistributionSetTypeResourceClient extends DistributionSetTypeRestApi { +public interface DistributionSetTypeResourceClient extends MgmtDistributionSetTypeRestApi { } diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/RolloutResourceClient.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/RolloutResourceClient.java index aed3af7a2..0a40ab107 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/RolloutResourceClient.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/RolloutResourceClient.java @@ -8,13 +8,13 @@ */ package org.eclipse.hawkbit.mgmt.client.resource; -import org.eclipse.hawkbit.rest.resource.api.RolloutRestApi; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi; import org.springframework.cloud.netflix.feign.FeignClient; /** * Client binding for the Rollout resource of the management API. */ @FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/rollouts") -public interface RolloutResourceClient extends RolloutRestApi { +public interface RolloutResourceClient extends MgmtRolloutRestApi { } diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/SoftwareModuleResourceClient.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/SoftwareModuleResourceClient.java index 8610643ef..aaf589779 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/SoftwareModuleResourceClient.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/SoftwareModuleResourceClient.java @@ -8,13 +8,13 @@ */ package org.eclipse.hawkbit.mgmt.client.resource; -import org.eclipse.hawkbit.rest.resource.api.SoftwareModuleRestAPI; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestAPI; import org.springframework.cloud.netflix.feign.FeignClient; /** * Client binding for the SoftwareModule resource of the management API. */ @FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/softwaremodules") -public interface SoftwareModuleResourceClient extends SoftwareModuleRestAPI { +public interface SoftwareModuleResourceClient extends MgmtSoftwareModuleRestAPI { } diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/SoftwareModuleTypeResourceClient.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/SoftwareModuleTypeResourceClient.java index 46410dd6c..5fe0012f6 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/SoftwareModuleTypeResourceClient.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/SoftwareModuleTypeResourceClient.java @@ -8,13 +8,13 @@ */ package org.eclipse.hawkbit.mgmt.client.resource; -import org.eclipse.hawkbit.rest.resource.api.SoftwareModuleTypeRestApi; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi; import org.springframework.cloud.netflix.feign.FeignClient; /** * Client binding for the oftwareModuleType resource of the management API. */ @FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/softwaremoduletypes") -public interface SoftwareModuleTypeResourceClient extends SoftwareModuleTypeRestApi { +public interface SoftwareModuleTypeResourceClient extends MgmtSoftwareModuleTypeRestApi { } diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/TargetResourceClient.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/TargetResourceClient.java index 79385fea4..920666dd1 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/TargetResourceClient.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/TargetResourceClient.java @@ -8,13 +8,13 @@ */ package org.eclipse.hawkbit.mgmt.client.resource; -import org.eclipse.hawkbit.rest.resource.api.TargetRestApi; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi; import org.springframework.cloud.netflix.feign.FeignClient; /** * Client binding for the Target resource of the management API. */ @FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/targets") -public interface TargetResourceClient extends TargetRestApi { +public interface TargetResourceClient extends MgmtTargetRestApi { } diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/TargetTagResourceClient.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/TargetTagResourceClient.java index 930931a87..ad6a1dab9 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/TargetTagResourceClient.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/TargetTagResourceClient.java @@ -8,13 +8,13 @@ */ package org.eclipse.hawkbit.mgmt.client.resource; -import org.eclipse.hawkbit.rest.resource.api.TargetTagRestApi; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi; import org.springframework.cloud.netflix.feign.FeignClient; /** * Client binding for the TargetTag resource of the management API. */ @FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/targettags") -public interface TargetTagResourceClient extends TargetTagRestApi { +public interface TargetTagResourceClient extends MgmtTargetTagRestApi { } diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/DistributionSetBuilder.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/DistributionSetBuilder.java index 2e2d91928..56c0ddbf8 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/DistributionSetBuilder.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/DistributionSetBuilder.java @@ -11,20 +11,20 @@ package org.eclipse.hawkbit.mgmt.client.resource.builder; import java.util.ArrayList; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleAssigmentRest; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssigment; import com.google.common.collect.Lists; /** - * Builder pattern for building {@link DistributionSetRequestBodyPost}. + * Builder pattern for building {@link MgmtDistributionSetRequestBodyPost}. */ public class DistributionSetBuilder { private String name; private String version; private String type; - private final List modules = new ArrayList<>(); + private final List modules = new ArrayList<>(); /** * @param name @@ -37,7 +37,7 @@ public class DistributionSetBuilder { } public DistributionSetBuilder moduleByID(final Long id) { - final SoftwareModuleAssigmentRest softwareModuleAssigmentRest = new SoftwareModuleAssigmentRest(); + final MgmtSoftwareModuleAssigment softwareModuleAssigmentRest = new MgmtSoftwareModuleAssigment(); softwareModuleAssigmentRest.setId(id); modules.add(softwareModuleAssigmentRest); return this; @@ -65,27 +65,27 @@ public class DistributionSetBuilder { /** * Builds a list with a single entry of - * {@link DistributionSetRequestBodyPost} which can directly be used to post + * {@link MgmtDistributionSetRequestBodyPost} which can directly be used to post * on the RESTful-API. * - * @return a single entry list of {@link DistributionSetRequestBodyPost} + * @return a single entry list of {@link MgmtDistributionSetRequestBodyPost} */ - public List build() { + public List build() { return Lists.newArrayList(doBuild(name)); } /** - * Builds a list of multiple {@link DistributionSetRequestBodyPost} to + * Builds a list of multiple {@link MgmtDistributionSetRequestBodyPost} to * create multiple distribution sets at once. An increasing number will be * added to the name of the distribution set. The version and type will * remain the same. * * @param count * the amount of distribution sets body which should be created - * @return a list of {@link DistributionSetRequestBodyPost} + * @return a list of {@link MgmtDistributionSetRequestBodyPost} */ - public List buildAsList(final int count) { - final ArrayList bodyList = Lists.newArrayList(); + public List buildAsList(final int count) { + final ArrayList bodyList = Lists.newArrayList(); for (int index = 0; index < count; index++) { bodyList.add(doBuild(name + index)); } @@ -93,8 +93,8 @@ public class DistributionSetBuilder { return bodyList; } - private DistributionSetRequestBodyPost doBuild(final String prefixName) { - final DistributionSetRequestBodyPost body = new DistributionSetRequestBodyPost(); + private MgmtDistributionSetRequestBodyPost doBuild(final String prefixName) { + final MgmtDistributionSetRequestBodyPost body = new MgmtDistributionSetRequestBodyPost(); body.setName(prefixName); body.setVersion(version); body.setType(type); diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/DistributionSetTypeBuilder.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/DistributionSetTypeBuilder.java index 752834c7d..909e08470 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/DistributionSetTypeBuilder.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/DistributionSetTypeBuilder.java @@ -11,22 +11,22 @@ package org.eclipse.hawkbit.mgmt.client.resource.builder; import java.util.ArrayList; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeAssigmentRest; +import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssigment; import com.google.common.collect.Lists; /** * - * Builder pattern for building {@link DistributionSetTypeRequestBodyPost}. + * Builder pattern for building {@link MgmtDistributionSetTypeRequestBodyPost}. * */ public class DistributionSetTypeBuilder { private String key; private String name; - private final List mandatorymodules = Lists.newArrayList(); - private final List optionalmodules = Lists.newArrayList(); + private final List mandatorymodules = Lists.newArrayList(); + private final List optionalmodules = Lists.newArrayList(); /** * @param key @@ -56,7 +56,7 @@ public class DistributionSetTypeBuilder { */ public DistributionSetTypeBuilder mandatorymodules(final Long... softwareModuleTypeIds) { for (final Long id : softwareModuleTypeIds) { - final SoftwareModuleTypeAssigmentRest softwareModuleTypeAssigmentRest = new SoftwareModuleTypeAssigmentRest(); + final MgmtSoftwareModuleTypeAssigment softwareModuleTypeAssigmentRest = new MgmtSoftwareModuleTypeAssigment(); softwareModuleTypeAssigmentRest.setId(id); this.mandatorymodules.add(softwareModuleTypeAssigmentRest); } @@ -72,7 +72,7 @@ public class DistributionSetTypeBuilder { */ public DistributionSetTypeBuilder optionalmodules(final Long... softwareModuleTypeIds) { for (final Long id : softwareModuleTypeIds) { - final SoftwareModuleTypeAssigmentRest softwareModuleTypeAssigmentRest = new SoftwareModuleTypeAssigmentRest(); + final MgmtSoftwareModuleTypeAssigment softwareModuleTypeAssigmentRest = new MgmtSoftwareModuleTypeAssigment(); softwareModuleTypeAssigmentRest.setId(id); this.optionalmodules.add(softwareModuleTypeAssigmentRest); } @@ -81,17 +81,17 @@ public class DistributionSetTypeBuilder { /** * Builds a list with a single entry of - * {@link DistributionSetTypeRequestBodyPost} which can directly be used in + * {@link MgmtDistributionSetTypeRequestBodyPost} which can directly be used in * the RESTful-API. * - * @return a single entry list of {@link DistributionSetTypeRequestBodyPost} + * @return a single entry list of {@link MgmtDistributionSetTypeRequestBodyPost} */ - public List build() { + public List build() { return Lists.newArrayList(doBuild(name, key)); } /** - * Builds a list of multiple {@link DistributionSetTypeRequestBodyPost} to + * Builds a list of multiple {@link MgmtDistributionSetTypeRequestBodyPost} to * create multiple distribution set types at once. An increasing number will * be added to the name and key of the distribution set type. The optional * and mandatory software module types will remain the same. @@ -99,10 +99,10 @@ public class DistributionSetTypeBuilder { * @param count * the amount of distribution sets type body which should be * created - * @return a list of {@link DistributionSetTypeRequestBodyPost} + * @return a list of {@link MgmtDistributionSetTypeRequestBodyPost} */ - public List buildAsList(final int count) { - final ArrayList bodyList = Lists.newArrayList(); + public List buildAsList(final int count) { + final ArrayList bodyList = Lists.newArrayList(); for (int index = 0; index < count; index++) { bodyList.add(doBuild(name + index, key + index)); } @@ -110,8 +110,8 @@ public class DistributionSetTypeBuilder { } - private DistributionSetTypeRequestBodyPost doBuild(final String prefixName, final String prefixKey) { - final DistributionSetTypeRequestBodyPost body = new DistributionSetTypeRequestBodyPost(); + private MgmtDistributionSetTypeRequestBodyPost doBuild(final String prefixName, final String prefixKey) { + final MgmtDistributionSetTypeRequestBodyPost body = new MgmtDistributionSetTypeRequestBodyPost(); body.setKey(prefixKey); body.setName(prefixName); body.setMandatorymodules(mandatorymodules); diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/RolloutBuilder.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/RolloutBuilder.java index 2e01e0ba2..e9f8431d8 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/RolloutBuilder.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/RolloutBuilder.java @@ -8,13 +8,13 @@ */ package org.eclipse.hawkbit.mgmt.client.resource.builder; -import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutCondition; -import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutCondition.Condition; -import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutRestRequestBody; +import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutCondition; +import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutRestRequestBody; +import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutCondition.Condition; /** * - * Builder pattern for building {@link RolloutRestRequestBody}. + * Builder pattern for building {@link MgmtRolloutRestRequestBody}. * */ public class RolloutBuilder { @@ -95,18 +95,18 @@ public class RolloutBuilder { * * @return the rest request body for creating a rollout */ - public RolloutRestRequestBody build() { + public MgmtRolloutRestRequestBody build() { return doBuild(); } - private RolloutRestRequestBody doBuild() { - final RolloutRestRequestBody body = new RolloutRestRequestBody(); + private MgmtRolloutRestRequestBody doBuild() { + final MgmtRolloutRestRequestBody body = new MgmtRolloutRestRequestBody(); body.setName(name); body.setAmountGroups(groupSize); body.setTargetFilterQuery(targetFilterQuery); body.setDistributionSetId(distributionSetId); - body.setSuccessCondition(new RolloutCondition(Condition.THRESHOLD, successThreshold)); - body.setErrorCondition(new RolloutCondition(Condition.THRESHOLD, errorThreshold)); + body.setSuccessCondition(new MgmtRolloutCondition(Condition.THRESHOLD, successThreshold)); + body.setErrorCondition(new MgmtRolloutCondition(Condition.THRESHOLD, errorThreshold)); return body; } diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/SoftwareModuleAssigmentBuilder.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/SoftwareModuleAssigmentBuilder.java index 8d69db619..a6003e2c5 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/SoftwareModuleAssigmentBuilder.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/SoftwareModuleAssigmentBuilder.java @@ -11,11 +11,11 @@ package org.eclipse.hawkbit.mgmt.client.resource.builder; import java.util.ArrayList; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleAssigmentRest; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssigment; /** * - * Builder pattern for building {@link SoftwareModuleAssigmentRest}. + * Builder pattern for building {@link MgmtSoftwareModuleAssigment}. * */ public class SoftwareModuleAssigmentBuilder { @@ -37,15 +37,15 @@ public class SoftwareModuleAssigmentBuilder { } /** - * Builds a list with a single entry of {@link SoftwareModuleAssigmentRest} + * Builds a list with a single entry of {@link MgmtSoftwareModuleAssigment} * which can directly be used in the RESTful-API. * - * @return a single entry list of {@link SoftwareModuleAssigmentRest} + * @return a single entry list of {@link MgmtSoftwareModuleAssigment} */ - public List build() { - final List softwareModuleAssigmentRestList = new ArrayList<>(); + public List build() { + final List softwareModuleAssigmentRestList = new ArrayList<>(); for (final Long id : ids) { - final SoftwareModuleAssigmentRest softwareModuleAssigmentRest = new SoftwareModuleAssigmentRest(); + final MgmtSoftwareModuleAssigment softwareModuleAssigmentRest = new MgmtSoftwareModuleAssigment(); softwareModuleAssigmentRest.setId(id); softwareModuleAssigmentRestList.add(softwareModuleAssigmentRest); } diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/SoftwareModuleBuilder.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/SoftwareModuleBuilder.java index 4bbfd92b4..d1b38b2b6 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/SoftwareModuleBuilder.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/SoftwareModuleBuilder.java @@ -11,14 +11,14 @@ package org.eclipse.hawkbit.mgmt.client.resource.builder; import java.util.ArrayList; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost; import com.google.common.collect.Lists; /** * - * Builder pattern for building {@link SoftwareModuleRequestBodyPost}. + * Builder pattern for building {@link MgmtSoftwareModuleRequestBodyPost}. * */ public class SoftwareModuleBuilder { @@ -60,27 +60,27 @@ public class SoftwareModuleBuilder { /** * Builds a list with a single entry of - * {@link SoftwareModuleRequestBodyPost} which can directly be used in the + * {@link MgmtSoftwareModuleRequestBodyPost} which can directly be used in the * RESTful-API. * - * @return a single entry list of {@link SoftwareModuleRequestBodyPost} + * @return a single entry list of {@link MgmtSoftwareModuleRequestBodyPost} */ - public List build() { + public List build() { return Lists.newArrayList(doBuild(name)); } /** - * Builds a list of multiple {@link SoftwareModuleRequestBodyPost} to create + * Builds a list of multiple {@link MgmtSoftwareModuleRequestBodyPost} to create * multiple software module at once. An increasing number will be added to * the name of the software module. The version and type will remain the * same. * * @param count * the amount of software module body which should be created - * @return a list of {@link DistributionSetTypeRequestBodyPost} + * @return a list of {@link MgmtDistributionSetTypeRequestBodyPost} */ - public List buildAsList(final int count) { - final ArrayList bodyList = Lists.newArrayList(); + public List buildAsList(final int count) { + final ArrayList bodyList = Lists.newArrayList(); for (int index = 0; index < count; index++) { bodyList.add(doBuild(name + index)); } @@ -88,8 +88,8 @@ public class SoftwareModuleBuilder { return bodyList; } - private SoftwareModuleRequestBodyPost doBuild(final String prefixName) { - final SoftwareModuleRequestBodyPost body = new SoftwareModuleRequestBodyPost(); + private MgmtSoftwareModuleRequestBodyPost doBuild(final String prefixName) { + final MgmtSoftwareModuleRequestBodyPost body = new MgmtSoftwareModuleRequestBodyPost(); body.setName(prefixName); body.setVersion(version); body.setType(type); diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/SoftwareModuleTypeBuilder.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/SoftwareModuleTypeBuilder.java index a6472f0a0..749546442 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/SoftwareModuleTypeBuilder.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/SoftwareModuleTypeBuilder.java @@ -11,14 +11,14 @@ package org.eclipse.hawkbit.mgmt.client.resource.builder; import java.util.ArrayList; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost; import com.google.common.collect.Lists; /** * - * Builder pattern for building {@link SoftwareModuleRequestBodyPost}. + * Builder pattern for building {@link MgmtSoftwareModuleRequestBodyPost}. * */ public class SoftwareModuleTypeBuilder { @@ -60,35 +60,35 @@ public class SoftwareModuleTypeBuilder { /** * Builds a list with a single entry of - * {@link SoftwareModuleTypeRequestBodyPost} which can directly be used in + * {@link MgmtSoftwareModuleTypeRequestBodyPost} which can directly be used in * the RESTful-API. * - * @return a single entry list of {@link SoftwareModuleTypeRequestBodyPost} + * @return a single entry list of {@link MgmtSoftwareModuleTypeRequestBodyPost} */ - public List build() { + public List build() { return Lists.newArrayList(doBuild(key, name)); } /** - * Builds a list of multiple {@link SoftwareModuleTypeRequestBodyPost} to + * Builds a list of multiple {@link MgmtSoftwareModuleTypeRequestBodyPost} to * create multiple software module types at once. An increasing number will * be added to the name and key of the software module type. * * @param count * the amount of software module type bodies which should be * created - * @return a list of {@link SoftwareModuleTypeRequestBodyPost} + * @return a list of {@link MgmtSoftwareModuleTypeRequestBodyPost} */ - public List buildAsList(final int count) { - final ArrayList bodyList = Lists.newArrayList(); + public List buildAsList(final int count) { + final ArrayList bodyList = Lists.newArrayList(); for (int index = 0; index < count; index++) { bodyList.add(doBuild(key + index, name + index)); } return bodyList; } - private SoftwareModuleTypeRequestBodyPost doBuild(final String prefixKey, final String prefixName) { - final SoftwareModuleTypeRequestBodyPost body = new SoftwareModuleTypeRequestBodyPost(); + private MgmtSoftwareModuleTypeRequestBodyPost doBuild(final String prefixKey, final String prefixName) { + final MgmtSoftwareModuleTypeRequestBodyPost body = new MgmtSoftwareModuleTypeRequestBodyPost(); body.setKey(prefixKey); body.setName(prefixName); body.setDescription(description); diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/TagBuilder.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/TagBuilder.java index 6f2eb3248..6718e631e 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/TagBuilder.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/TagBuilder.java @@ -11,12 +11,12 @@ package org.eclipse.hawkbit.mgmt.client.resource.builder; import java.util.ArrayList; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut; import com.google.common.collect.Lists; /** - * Builder pattern for building {@link TagRequestBodyPut}. + * Builder pattern for building {@link MgmtTagRequestBodyPut}. * */ public class TagBuilder { @@ -56,26 +56,26 @@ public class TagBuilder { } /** - * Builds a list with a single entry of {@link TagRequestBodyPut} which can + * Builds a list with a single entry of {@link MgmtTagRequestBodyPut} which can * directly be used in the RESTful-API. * - * @return a single entry list of {@link TagRequestBodyPut} + * @return a single entry list of {@link MgmtTagRequestBodyPut} */ - public List build() { + public List build() { return Lists.newArrayList(doBuild(name)); } /** - * Builds a list of multiple {@link TagRequestBodyPut} to create multiple + * Builds a list of multiple {@link MgmtTagRequestBodyPut} to create multiple * tags at once. An increasing number will be added to the name of the tag. * The color and description will remain the same. * * @param count * the amount of distribution sets body which should be created - * @return a list of {@link TagRequestBodyPut} + * @return a list of {@link MgmtTagRequestBodyPut} */ - public List buildAsList(final int count) { - final ArrayList bodyList = Lists.newArrayList(); + public List buildAsList(final int count) { + final ArrayList bodyList = Lists.newArrayList(); for (int index = 0; index < count; index++) { bodyList.add(doBuild(name + index)); } @@ -83,8 +83,8 @@ public class TagBuilder { return bodyList; } - private TagRequestBodyPut doBuild(final String prefixName) { - final TagRequestBodyPut body = new TagRequestBodyPut(); + private MgmtTagRequestBodyPut doBuild(final String prefixName) { + final MgmtTagRequestBodyPut body = new MgmtTagRequestBodyPut(); body.setName(prefixName); body.setDescription(description); body.setColour(color); diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/TargetBuilder.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/TargetBuilder.java index e496407e1..09b20339b 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/TargetBuilder.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/builder/TargetBuilder.java @@ -11,14 +11,14 @@ package org.eclipse.hawkbit.mgmt.client.resource.builder; import java.util.ArrayList; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody; import com.google.common.collect.Lists; /** * - * Builder pattern for building {@link TargetRequestBody}. + * Builder pattern for building {@link MgmtTargetRequestBody}. * */ public class TargetBuilder { @@ -58,35 +58,35 @@ public class TargetBuilder { } /** - * Builds a list with a single entry of {@link TargetRequestBody} which can + * Builds a list with a single entry of {@link MgmtTargetRequestBody} which can * directly be used in the RESTful-API. * - * @return a single entry list of {@link TargetRequestBody} + * @return a single entry list of {@link MgmtTargetRequestBody} */ - public List build() { + public List build() { return Lists.newArrayList(doBuild(controllerId)); } /** - * Builds a list of multiple {@link TargetRequestBody} to create multiple + * Builds a list of multiple {@link MgmtTargetRequestBody} to create multiple * targets at once. An increasing number will be added to the controllerId * of the target. The name and description will remain. * * @param count * the amount of software module type bodies which should be * created - * @return a list of {@link SoftwareModuleTypeRequestBodyPost} + * @return a list of {@link MgmtSoftwareModuleTypeRequestBodyPost} */ - public List buildAsList(final int count) { - final ArrayList bodyList = Lists.newArrayList(); + public List buildAsList(final int count) { + final ArrayList bodyList = Lists.newArrayList(); for (int index = 0; index < count; index++) { bodyList.add(doBuild(controllerId + index)); } return bodyList; } - private TargetRequestBody doBuild(final String prefixControllerId) { - final TargetRequestBody body = new TargetRequestBody(); + private MgmtTargetRequestBody doBuild(final String prefixControllerId) { + final MgmtTargetRequestBody body = new MgmtTargetRequestBody(); body.setControllerId(prefixControllerId); body.setName(name); body.setDescription(description); diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/scenarios/CreateStartedRolloutExample.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/scenarios/CreateStartedRolloutExample.java index cd74c0474..0e1093f1d 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/scenarios/CreateStartedRolloutExample.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/scenarios/CreateStartedRolloutExample.java @@ -23,10 +23,10 @@ import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleAssigmentB import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleBuilder; import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleTypeBuilder; import org.eclipse.hawkbit.mgmt.client.resource.builder.TargetBuilder; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest; -import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutResponseBody; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRest; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; +import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutResponseBody; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -67,7 +67,7 @@ public class CreateStartedRolloutExample { public void run() { // create three SoftwareModuleTypes - final List createdSoftwareModuleTypes = softwareModuleTypeResource + final List createdSoftwareModuleTypes = softwareModuleTypeResource .createSoftwareModuleTypes(new SoftwareModuleTypeBuilder().key(SM_MODULE_TYPE).name(SM_MODULE_TYPE) .maxAssignments(1).build()) .getBody(); @@ -78,12 +78,12 @@ public class CreateStartedRolloutExample { .getBody(); // create one DistributionSet - final List distributionSetsRest = distributionSetResource.createDistributionSets( + final List distributionSetsRest = distributionSetResource.createDistributionSets( new DistributionSetBuilder().name("rollout-example").version("1.0.0").type(DS_MODULE_TYPE).build()) .getBody(); // create three SoftwareModules - final List softwareModulesRest = softwareModuleResource + final List softwareModulesRest = softwareModuleResource .createSoftwareModules( new SoftwareModuleBuilder().name("firmware").version("1.0.0").type(SM_MODULE_TYPE).build()) .getBody(); @@ -97,7 +97,7 @@ public class CreateStartedRolloutExample { .description("Targets used for rollout example").buildAsList(10)); // create a Rollout - final RolloutResponseBody rolloutResponseBody = rolloutResource + final MgmtRolloutResponseBody rolloutResponseBody = rolloutResource .create(new RolloutBuilder().name("MyRollout").groupSize(2).targetFilterQuery("name==00-FF-AA-0*") .distributionSetId(distributionSetsRest.get(0).getDsId()).successThreshold("80") .errorThreshold("50").build()) diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/scenarios/GettingStartedDefaultScenario.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/scenarios/GettingStartedDefaultScenario.java index 5873403f0..43a98aff4 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/scenarios/GettingStartedDefaultScenario.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/scenarios/GettingStartedDefaultScenario.java @@ -19,9 +19,9 @@ import org.eclipse.hawkbit.mgmt.client.resource.builder.DistributionSetTypeBuild import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleAssigmentBuilder; import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleBuilder; import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleTypeBuilder; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRest; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -70,7 +70,7 @@ public class GettingStartedDefaultScenario { // create one SoftwareModuleTypes LOGGER.info("Creating software module type {}", SM_MODULE_TYPE); - final List createdSoftwareModuleTypes = softwareModuleTypeResource + final List createdSoftwareModuleTypes = softwareModuleTypeResource .createSoftwareModuleTypes(new SoftwareModuleTypeBuilder().key(SM_MODULE_TYPE).name(SM_MODULE_TYPE) .maxAssignments(1).build()) .getBody(); @@ -86,17 +86,17 @@ public class GettingStartedDefaultScenario { final String dsVersion3 = "2.1.0"; LOGGER.info("Creating distribution set {}:{}", DS_EXAMPLE_NAME, dsVersion1); - final List distributionSetsRest1 = distributionSetResource.createDistributionSets( + final List distributionSetsRest1 = distributionSetResource.createDistributionSets( new DistributionSetBuilder().name(DS_EXAMPLE_NAME).version(dsVersion1).type(DS_MODULE_TYPE).build()) .getBody(); LOGGER.info("Creating distribution set {}:{}", DS_EXAMPLE_NAME, dsVersion2); - final List distributionSetsRest2 = distributionSetResource.createDistributionSets( + final List distributionSetsRest2 = distributionSetResource.createDistributionSets( new DistributionSetBuilder().name(DS_EXAMPLE_NAME).version(dsVersion2).type(DS_MODULE_TYPE).build()) .getBody(); LOGGER.info("Creating distribution set {}:{}", DS_EXAMPLE_NAME, dsVersion3); - final List distributionSetsRest3 = distributionSetResource.createDistributionSets( + final List distributionSetsRest3 = distributionSetResource.createDistributionSets( new DistributionSetBuilder().name(DS_EXAMPLE_NAME).version(dsVersion3).type(DS_MODULE_TYPE).build()) .getBody(); @@ -106,15 +106,15 @@ public class GettingStartedDefaultScenario { final String swVersion3 = "3"; LOGGER.info("Creating distribution set {}:{}", SM_EXAMPLE_NAME, swVersion1); - final List softwareModulesRest1 = softwareModuleResource.createSoftwareModules( + final List softwareModulesRest1 = softwareModuleResource.createSoftwareModules( new SoftwareModuleBuilder().name(SM_EXAMPLE_NAME).version(swVersion1).type(SM_MODULE_TYPE).build()) .getBody(); LOGGER.info("Creating distribution set {}:{}", SM_EXAMPLE_NAME, swVersion2); - final List softwareModulesRest2 = softwareModuleResource.createSoftwareModules( + final List softwareModulesRest2 = softwareModuleResource.createSoftwareModules( new SoftwareModuleBuilder().name(SM_EXAMPLE_NAME).version(swVersion2).type(SM_MODULE_TYPE).build()) .getBody(); LOGGER.info("Creating distribution set {}:{}", SM_EXAMPLE_NAME, swVersion3); - final List softwareModulesRest3 = softwareModuleResource.createSoftwareModules( + final List softwareModulesRest3 = softwareModuleResource.createSoftwareModules( new SoftwareModuleBuilder().name(SM_EXAMPLE_NAME).version(swVersion3).type(SM_MODULE_TYPE).build()) .getBody(); diff --git a/hawkbit-autoconfigure/pom.xml b/hawkbit-autoconfigure/pom.xml index dcbb95920..3fb623978 100644 --- a/hawkbit-autoconfigure/pom.xml +++ b/hawkbit-autoconfigure/pom.xml @@ -64,13 +64,19 @@ org.eclipse.hawkbit - hawkbit-rest-resource + hawkbit-ddi-resource ${project.version} true org.eclipse.hawkbit - hawkbit-ddi-resource + hawkbit-system-resource + ${project.version} + true + + + org.eclipse.hawkbit + hawkbit-mgmt-resource ${project.version} true diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java index 9638377eb..d337658b8 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java @@ -29,7 +29,6 @@ import org.eclipse.hawkbit.im.authentication.UserAuthenticationFilter; import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; -import org.eclipse.hawkbit.rest.resource.RestConstants; import org.eclipse.hawkbit.security.ControllerTenantAwareAuthenticationDetailsSource; import org.eclipse.hawkbit.security.DdiSecurityProperties; import org.eclipse.hawkbit.security.DosFilter; @@ -41,6 +40,7 @@ import org.eclipse.hawkbit.security.HttpControllerPreAuthenticatedSecurityHeader import org.eclipse.hawkbit.security.HttpDownloadAuthenticationFilter; import org.eclipse.hawkbit.security.PreAuthTokenSourceTrustAuthenticationProvider; import org.eclipse.hawkbit.security.SystemSecurityContext; +import org.eclipse.hawkbit.system.rest.api.SystemRestConstant; import org.eclipse.hawkbit.tenancy.TenantAware; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -292,8 +292,9 @@ public class SecurityManagedConfiguration { new AuthenticationSuccessTenantMetadataCreationFilter(tenantAware, systemManagement), RequestHeaderAuthenticationFilter.class) .authorizeRequests().anyRequest().authenticated() - .antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/admin/**") - .hasAnyAuthority(SpPermission.SYSTEM_ADMIN).antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/**") + .antMatchers(SystemRestConstant.BASE_SYSTEM_MAPPING + "/admin/**") + .hasAnyAuthority(SpPermission.SYSTEM_ADMIN) + .antMatchers(SystemRestConstant.BASE_SYSTEM_MAPPING + "/**") .hasAnyAuthority(SpPermission.SYSTEM_DIAG); } } diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/web/ResourceControllerAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/web/ResourceControllerAutoConfiguration.java index ef489049f..34ed5ddcd 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/web/ResourceControllerAutoConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/web/ResourceControllerAutoConfiguration.java @@ -9,20 +9,19 @@ package org.eclipse.hawkbit.autoconfigure.web; import org.eclipse.hawkbit.ddi.annotation.EnableDdiApi; -import org.eclipse.hawkbit.rest.resource.EnableRestResources; +import org.eclipse.hawkbit.mgmt.annotation.EnableMgmtApi; +import org.eclipse.hawkbit.system.annotation.EnableSystemApi; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; /** * Auto-Configuration for enabling the REST-Resources. - * - * * */ @Configuration -@ConditionalOnClass({ EnableDdiApi.class, EnableRestResources.class }) -@Import({ EnableDdiApi.class, EnableRestResources.class }) +@ConditionalOnClass({ EnableDdiApi.class, EnableMgmtApi.class, EnableSystemApi.class }) +@Import({ EnableDdiApi.class, EnableMgmtApi.class, EnableSystemApi.class }) public class ResourceControllerAutoConfiguration { } diff --git a/hawkbit-ddi-api/pom.xml b/hawkbit-ddi-api/pom.xml index 6dd30fdf9..e91053fc5 100644 --- a/hawkbit-ddi-api/pom.xml +++ b/hawkbit-ddi-api/pom.xml @@ -1,4 +1,14 @@ - + + 4.0.0 @@ -9,12 +19,19 @@ hawkbit-ddi-api hawkBit :: DDI API - - + + - org.eclipse.hawkbit - hawkbit-rest-api - ${project.version} + org.springframework.hateoas + spring-hateoas + + + com.fasterxml.jackson.core + jackson-annotations + + + javax.validation + validation-api javax.servlet @@ -22,17 +39,12 @@ provided - commons-io - commons-io - 2.4 + org.hibernate + hibernate-validator org.springframework.security spring-security-web - - org.hibernate - hibernate-validator - - + diff --git a/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifact.java b/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifact.java index d39a44daa..5fc911946 100644 --- a/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifact.java +++ b/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifact.java @@ -10,13 +10,13 @@ package org.eclipse.hawkbit.ddi.json.model; import javax.validation.constraints.NotNull; -import org.eclipse.hawkbit.rest.resource.model.artifact.ArtifactHash; import org.springframework.hateoas.ResourceSupport; import com.fasterxml.jackson.annotation.JsonProperty; /** - * Download information for all artifacts related to a specific {@link DdiChunk}. + * Download information for all artifacts related to a specific {@link DdiChunk} + * . */ public class DdiArtifact extends ResourceSupport { @@ -25,16 +25,16 @@ public class DdiArtifact extends ResourceSupport { private String filename; @JsonProperty - private ArtifactHash hashes; + private DdiArtifactHash hashes; @JsonProperty private Long size; - public ArtifactHash getHashes() { + public DdiArtifactHash getHashes() { return hashes; } - public void setHashes(final ArtifactHash hashes) { + public void setHashes(final DdiArtifactHash hashes) { this.hashes = hashes; } diff --git a/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifactHash.java b/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifactHash.java new file mode 100644 index 000000000..9541055f8 --- /dev/null +++ b/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifactHash.java @@ -0,0 +1,57 @@ +/** + * 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.ddi.json.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Hashes for given Artifact. + * + * + */ +public class DdiArtifactHash { + + @JsonProperty + private String sha1; + + @JsonProperty + private String md5; + + /** + * Default constructor. + */ + public DdiArtifactHash() { + } + + /** + * Public constructor. + * + * @param sha1 + * @param md5 + */ + public DdiArtifactHash(final String sha1, final String md5) { + this.sha1 = sha1; + this.md5 = md5; + } + + /** + * @return the sha1 + */ + public String getSha1() { + return sha1; + } + + /** + * @return the md5 + */ + public String getMd5() { + return md5; + } + +} diff --git a/hawkbit-ddi-resource/pom.xml b/hawkbit-ddi-resource/pom.xml index bcc1b4932..cafcfdf70 100644 --- a/hawkbit-ddi-resource/pom.xml +++ b/hawkbit-ddi-resource/pom.xml @@ -1,4 +1,14 @@ - + + 4.0.0 @@ -10,31 +20,26 @@ hawkbit-ddi-resource hawkBit :: DDI Resources - - + + org.eclipse.hawkbit hawkbit-ddi-api ${project.version} - + org.eclipse.hawkbit - hawkbit-rest-resource + hawkbit-rest-core ${project.version} - - + + org.eclipse.hawkbit hawkbit-repository ${project.version} + + - - org.eclipse.hawkbit - hawkbit-rest-resource - ${project.version} - test - tests - org.springframework.boot spring-boot-starter diff --git a/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/annotation/EnableDdiApi.java b/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/annotation/EnableDdiApi.java similarity index 100% rename from hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/annotation/EnableDdiApi.java rename to hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/annotation/EnableDdiApi.java diff --git a/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/resource/ArtifactStoreController.java b/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/ArtifactStoreController.java similarity index 98% rename from hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/resource/ArtifactStoreController.java rename to hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/ArtifactStoreController.java index 61f3fd465..2a6d544ab 100644 --- a/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/resource/ArtifactStoreController.java +++ b/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/ArtifactStoreController.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.ddi.resource; +package org.eclipse.hawkbit.ddi.rest.resource; import java.io.IOException; import java.util.List; @@ -24,7 +24,7 @@ import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.rest.resource.helper.RestResourceConversionHelper; +import org.eclipse.hawkbit.rest.util.RestResourceConversionHelper; import org.eclipse.hawkbit.security.HawkbitSecurityProperties; import org.eclipse.hawkbit.util.IpUtil; import org.slf4j.Logger; diff --git a/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/resource/DataConversionHelper.java b/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java similarity index 95% rename from hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/resource/DataConversionHelper.java rename to hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java index 8533c6eac..2fd151f6e 100644 --- a/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/resource/DataConversionHelper.java +++ b/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.ddi.resource; +package org.eclipse.hawkbit.ddi.rest.resource; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; @@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.hawkbit.api.ArtifactUrlHandler; import org.eclipse.hawkbit.api.UrlProtocol; import org.eclipse.hawkbit.ddi.json.model.DdiArtifact; +import org.eclipse.hawkbit.ddi.json.model.DdiArtifactHash; import org.eclipse.hawkbit.ddi.json.model.DdiChunk; import org.eclipse.hawkbit.ddi.json.model.DdiConfig; import org.eclipse.hawkbit.ddi.json.model.DdiControllerBase; @@ -30,7 +31,6 @@ import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.rest.resource.model.artifact.ArtifactHash; import org.eclipse.hawkbit.tenancy.TenantAware; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.hateoas.Link; @@ -85,7 +85,7 @@ public final class DataConversionHelper { final List files = new ArrayList<>(); module.getLocalArtifacts().forEach(artifact -> { final DdiArtifact file = new DdiArtifact(); - file.setHashes(new ArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash())); + file.setHashes(new DdiArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash())); file.setFilename(artifact.getFilename()); file.setSize(artifact.getSize()); final String linkHttp = artifactUrlHandler.getUrl(targetid, artifact.getSoftwareModule().getId(), @@ -104,7 +104,8 @@ public final class DataConversionHelper { static DdiControllerBase fromTarget(final Target target, final List actions, final String defaultControllerPollTime, final TenantAware tenantAware) { - final DdiControllerBase result = new DdiControllerBase(new DdiConfig(new DdiPolling(defaultControllerPollTime))); + final DdiControllerBase result = new DdiControllerBase( + new DdiConfig(new DdiPolling(defaultControllerPollTime))); boolean addedUpdate = false; boolean addedCancel = false; diff --git a/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/resource/RootController.java b/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/RootController.java similarity index 99% rename from hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/resource/RootController.java rename to hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/RootController.java index e48e2ec5f..4f485984b 100644 --- a/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/resource/RootController.java +++ b/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/RootController.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.ddi.resource; +package org.eclipse.hawkbit.ddi.rest.resource; import java.io.IOException; import java.util.List; @@ -40,7 +40,7 @@ import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; -import org.eclipse.hawkbit.rest.resource.helper.RestResourceConversionHelper; +import org.eclipse.hawkbit.rest.util.RestResourceConversionHelper; import org.eclipse.hawkbit.security.HawkbitSecurityProperties; import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.util.IpUtil; diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/ArtifactDownloadTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiArtifactDownloadTest.java similarity index 99% rename from hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/ArtifactDownloadTest.java rename to hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiArtifactDownloadTest.java index f7173f86e..af65b1351 100644 --- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/ArtifactDownloadTest.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiArtifactDownloadTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.ddi.resource; +package org.eclipse.hawkbit.ddi.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; import static org.junit.Assert.assertTrue; @@ -60,10 +60,10 @@ import ru.yandex.qatools.allure.annotations.Stories; @ActiveProfiles({ "im", "test" }) @Features("Component Tests - Direct Device Integration API") @Stories("Artifact Download Resource") -public class ArtifactDownloadTest extends AbstractIntegrationTestWithMongoDB { +public class DdiArtifactDownloadTest extends AbstractIntegrationTestWithMongoDB { - public ArtifactDownloadTest() { - LOG = LoggerFactory.getLogger(ArtifactDownloadTest.class); + public DdiArtifactDownloadTest() { + LOG = LoggerFactory.getLogger(DdiArtifactDownloadTest.class); } private volatile int downLoadProgress = 0; diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/CancelActionTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java similarity index 99% rename from hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/CancelActionTest.java rename to hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java index 3c236c196..27a7e7f1f 100644 --- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/CancelActionTest.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.ddi.resource; +package org.eclipse.hawkbit.ddi.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; @@ -23,13 +23,11 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.hawkbit.AbstractIntegrationTest; -import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.rest.resource.JsonBuilder; import org.junit.Test; import org.springframework.hateoas.MediaTypes; import org.springframework.http.MediaType; @@ -45,7 +43,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @ActiveProfiles({ "im", "test" }) @Features("Component Tests - Direct Device Integration API") @Stories("Cancel Action Resource") -public class CancelActionTest extends AbstractIntegrationTest { +public class DdiCancelActionTest extends AbstractIntegrationTest { @Test @Description("Test of the controller can continue a started update even after a cancel command if it so desires.") diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/ConfigDataTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java similarity index 97% rename from hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/ConfigDataTest.java rename to hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java index ee40d6ded..b757f1f1a 100644 --- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/ConfigDataTest.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.ddi.resource; +package org.eclipse.hawkbit.ddi.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; @@ -22,9 +22,7 @@ import java.util.HashMap; import java.util.Map; import org.eclipse.hawkbit.AbstractIntegrationTest; -import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.rest.resource.JsonBuilder; import org.junit.Test; import org.springframework.hateoas.MediaTypes; import org.springframework.http.MediaType; @@ -40,7 +38,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @ActiveProfiles({ "im", "test" }) @Features("Component Tests - Direct Device Integration API") @Stories("Config Data Resource") -public class ConfigDataTest extends AbstractIntegrationTest { +public class DdiConfigDataTest extends AbstractIntegrationTest { @Test @Description("We verify that the config data (i.e. device attributes like serial number, hardware revision etc.) " diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/DeploymentBaseTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java similarity index 99% rename from hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/DeploymentBaseTest.java rename to hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java index 4ba5c9cdf..dd2f66a04 100644 --- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/DeploymentBaseTest.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.ddi.resource; +package org.eclipse.hawkbit.ddi.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; @@ -26,7 +26,6 @@ import java.util.List; import org.apache.commons.lang3.RandomUtils; import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB; -import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.ActionType; @@ -36,7 +35,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; -import org.eclipse.hawkbit.rest.resource.JsonBuilder; import org.fest.assertions.core.Condition; import org.junit.Test; import org.springframework.data.domain.PageRequest; @@ -57,7 +55,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @ActiveProfiles({ "im", "test" }) @Features("Component Tests - Direct Device Integration API") @Stories("Deployment Action Resource") -public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { +public class DdiDeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { @Test() @Description("Ensures that artifacts are not found, when softare module does not exists.") diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/RootControllerTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java similarity index 98% rename from hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/RootControllerTest.java rename to hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java index be390959a..f291393b9 100644 --- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/resource/RootControllerTest.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.ddi.resource; +package org.eclipse.hawkbit.ddi.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB; -import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.WithSpringAuthorityRule; import org.eclipse.hawkbit.WithUser; @@ -33,7 +32,6 @@ import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; -import org.eclipse.hawkbit.rest.resource.JsonBuilder; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; import org.eclipse.hawkbit.util.IpUtil; import org.junit.Test; @@ -51,7 +49,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @ActiveProfiles({ "im", "test" }) @Features("Component Tests - Direct Device Integration API") @Stories("Root Poll Resource") -public class RootControllerTest extends AbstractIntegrationTestWithMongoDB { +public class DdiRootControllerTest extends AbstractIntegrationTestWithMongoDB { @Test @Description("Ensures that targets cannot be created e.g. in plug'n play scenarios when tenant does not exists but can be created if the tenant exists.") diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/JsonBuilder.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/JsonBuilder.java similarity index 99% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/JsonBuilder.java rename to hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/JsonBuilder.java index dec0bb070..cf791bcf8 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/JsonBuilder.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/JsonBuilder.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.ddi.rest.resource; import java.util.ArrayList; import java.util.List; diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/MockMvcResultPrinter.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/MockMvcResultPrinter.java similarity index 97% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/MockMvcResultPrinter.java rename to hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/MockMvcResultPrinter.java index b01bb4e9f..ba5020c58 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/MockMvcResultPrinter.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/MockMvcResultPrinter.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit; +package org.eclipse.hawkbit.ddi.rest.resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/hawkbit-mgmt-api/pom.xml b/hawkbit-mgmt-api/pom.xml new file mode 100644 index 000000000..4c99cd7bc --- /dev/null +++ b/hawkbit-mgmt-api/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + org.eclipse.hawkbit + hawkbit-parent + 0.2.0-SNAPSHOT + + hawkbit-mgmt-api + hawkBit :: Mgmt REST API + + + + org.springframework.hateoas + spring-hateoas + + + com.fasterxml.jackson.core + jackson-annotations + + + javax.validation + validation-api + + + javax.servlet + javax.servlet-api + provided + + + + + org.easytesting + fest-assert + test + + + ru.yandex.qatools.allure + allure-junit-adaptor + test + + + \ No newline at end of file diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/MetadataRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MetadataRest.java similarity index 96% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/MetadataRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MetadataRest.java index a5c24c4a9..70cfff0d0 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/MetadataRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MetadataRest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model; +package org.eclipse.hawkbit.mgmt.json.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/BaseEntityRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtBaseEntity.java similarity index 94% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/BaseEntityRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtBaseEntity.java index 6d80a407c..728734050 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/BaseEntityRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtBaseEntity.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model; +package org.eclipse.hawkbit.mgmt.json.model; import org.springframework.hateoas.ResourceSupport; @@ -17,7 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * A json annotated rest model for BaseEntity to RESTful API representation. * */ -public abstract class BaseEntityRest extends ResourceSupport { +public abstract class MgmtBaseEntity extends ResourceSupport { @JsonProperty private String createdBy; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/IdRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtId.java similarity index 92% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/IdRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtId.java index d15114d4e..e83c43d52 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/IdRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtId.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model; +package org.eclipse.hawkbit.mgmt.json.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; @@ -18,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * */ @JsonIgnoreProperties(ignoreUnknown = true) -public class IdRest { +public class MgmtId { @JsonProperty private Long id; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/NamedEntityRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtNamedEntity.java similarity index 91% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/NamedEntityRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtNamedEntity.java index d82d14f75..d335261ad 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/NamedEntityRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtNamedEntity.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model; +package org.eclipse.hawkbit.mgmt.json.model; import com.fasterxml.jackson.annotation.JsonProperty; @@ -14,7 +14,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * A json annotated rest model for NamedEntity to RESTful API representation. * */ -public abstract class NamedEntityRest extends BaseEntityRest { +public abstract class MgmtNamedEntity extends MgmtBaseEntity { @JsonProperty(required = true) private String name; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PollStatusRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtPollStatus.java similarity index 95% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PollStatusRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtPollStatus.java index d66d02512..5e5163a6a 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PollStatusRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtPollStatus.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model; +package org.eclipse.hawkbit.mgmt.json.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class PollStatusRest { +public class MgmtPollStatus { @JsonProperty private Long lastRequestAt; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PagedList.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/PagedList.java similarity index 97% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PagedList.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/PagedList.java index 9d5cc458c..173f3ce31 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PagedList.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/PagedList.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model; +package org.eclipse.hawkbit.mgmt.json.model; import java.util.List; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtAction.java similarity index 92% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtAction.java index 630bcb993..5b63b5f69 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtAction.java @@ -6,9 +6,9 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.action; +package org.eclipse.hawkbit.mgmt.json.model.action; -import org.eclipse.hawkbit.rest.resource.model.BaseEntityRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtBaseEntity; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -21,7 +21,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ActionRest extends BaseEntityRest { +public class MgmtAction extends MgmtBaseEntity { /** * API definition for {@link UpdateAction}. diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatusRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtActionStatus.java similarity index 97% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatusRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtActionStatus.java index e5af39bac..26120d2d5 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatusRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtActionStatus.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.action; +package org.eclipse.hawkbit.mgmt.json.model.action; import java.util.List; @@ -21,7 +21,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ActionStatusRest { +public class MgmtActionStatus { /** * Action is finished successfully for this target. diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/artifact/MgmtArtifact.java similarity index 90% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/artifact/MgmtArtifact.java index f32a32ed8..35ad382e7 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/artifact/MgmtArtifact.java @@ -6,9 +6,9 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.artifact; +package org.eclipse.hawkbit.mgmt.json.model.artifact; -import org.eclipse.hawkbit.rest.resource.model.BaseEntityRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtBaseEntity; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonValue; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ArtifactRest extends BaseEntityRest { +public class MgmtArtifact extends MgmtBaseEntity { + @JsonProperty(required = true) private ArtifactType type; @@ -30,7 +31,7 @@ public class ArtifactRest extends BaseEntityRest { private Long artifactId; @JsonProperty - private ArtifactHash hashes; + private MgmtArtifactHash hashes; @JsonProperty private String providedFilename; @@ -51,7 +52,7 @@ public class ArtifactRest extends BaseEntityRest { * the hashes to set */ @JsonIgnore - public void setHashes(final ArtifactHash hashes) { + public void setHashes(final MgmtArtifactHash hashes) { this.hashes = hashes; } @@ -81,7 +82,7 @@ public class ArtifactRest extends BaseEntityRest { /** * @return the hashes */ - public ArtifactHash getHashes() { + public MgmtArtifactHash getHashes() { return hashes; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactHash.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/artifact/MgmtArtifactHash.java similarity index 83% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactHash.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/artifact/MgmtArtifactHash.java index 58b81d8fd..d43ae4339 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactHash.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/artifact/MgmtArtifactHash.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.artifact; +package org.eclipse.hawkbit.mgmt.json.model.artifact; import com.fasterxml.jackson.annotation.JsonProperty; @@ -15,7 +15,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * * */ -public class ArtifactHash { +public class MgmtArtifactHash { @JsonProperty private String sha1; @@ -26,7 +26,7 @@ public class ArtifactHash { /** * Default constructor. */ - public ArtifactHash() { + public MgmtArtifactHash() { } /** @@ -35,7 +35,7 @@ public class ArtifactHash { * @param sha1 * @param md5 */ - public ArtifactHash(final String sha1, final String md5) { + public MgmtArtifactHash(final String sha1, final String md5) { super(); this.sha1 = sha1; this.md5 = md5; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/ActionTypeRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtActionType.java similarity index 85% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/ActionTypeRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtActionType.java index bf6a649a0..98017d18a 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/ActionTypeRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtActionType.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.distributionset; +package org.eclipse.hawkbit.mgmt.json.model.distributionset; import com.fasterxml.jackson.annotation.JsonValue; @@ -17,7 +17,7 @@ import com.fasterxml.jackson.annotation.JsonValue; * * */ -public enum ActionTypeRest { +public enum MgmtActionType { /** * The soft action type. */ @@ -35,7 +35,7 @@ public enum ActionTypeRest { private final String name; - private ActionTypeRest(final String name) { + private MgmtActionType(final String name) { this.name = name; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSet.java similarity index 86% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSet.java index 2ff764eba..7caaf4cdd 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSet.java @@ -6,13 +6,13 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.distributionset; +package org.eclipse.hawkbit.mgmt.json.model.distributionset; import java.util.ArrayList; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -30,7 +30,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class DistributionSetRest extends NamedEntityRest { +public class MgmtDistributionSet extends MgmtNamedEntity { @JsonProperty(value = "id", required = true) private Long dsId; @@ -39,7 +39,7 @@ public class DistributionSetRest extends NamedEntityRest { private String version; @JsonProperty - private List modules = new ArrayList<>(); + private List modules = new ArrayList<>(); @JsonProperty private boolean requiredMigrationStep; @@ -99,7 +99,7 @@ public class DistributionSetRest extends NamedEntityRest { /** * @return the modules */ - public List getModules() { + public List getModules() { return modules; } @@ -107,7 +107,7 @@ public class DistributionSetRest extends NamedEntityRest { * @param modules * the modules to set */ - public void setModules(final List modules) { + public void setModules(final List modules) { this.modules = modules; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyPost.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSetRequestBodyPost.java similarity index 67% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyPost.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSetRequestBodyPost.java index bf5470d72..a56b5aaba 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyPost.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSetRequestBodyPost.java @@ -6,11 +6,11 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.distributionset; +package org.eclipse.hawkbit.mgmt.json.model.distributionset; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleAssigmentRest; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssigment; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -23,22 +23,22 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class DistributionSetRequestBodyPost extends DistributionSetRequestBodyPut { +public class MgmtDistributionSetRequestBodyPost extends MgmtDistributionSetRequestBodyPut { // deprecated format from the time where os, application and runtime where // statically defined @JsonProperty - private SoftwareModuleAssigmentRest os; + private MgmtSoftwareModuleAssigment os; @JsonProperty - private SoftwareModuleAssigmentRest runtime; + private MgmtSoftwareModuleAssigment runtime; @JsonProperty - private SoftwareModuleAssigmentRest application; + private MgmtSoftwareModuleAssigment application; // deprecated format - END @JsonProperty - private List modules; + private List modules; @JsonProperty private boolean requiredMigrationStep; @@ -49,7 +49,7 @@ public class DistributionSetRequestBodyPost extends DistributionSetRequestBodyPu /** * @return the os */ - public SoftwareModuleAssigmentRest getOs() { + public MgmtSoftwareModuleAssigment getOs() { return os; } @@ -59,7 +59,7 @@ public class DistributionSetRequestBodyPost extends DistributionSetRequestBodyPu * * @return updated body */ - public DistributionSetRequestBodyPost setOs(final SoftwareModuleAssigmentRest os) { + public MgmtDistributionSetRequestBodyPost setOs(final MgmtSoftwareModuleAssigment os) { this.os = os; return this; } @@ -67,7 +67,7 @@ public class DistributionSetRequestBodyPost extends DistributionSetRequestBodyPu /** * @return the runtime */ - public SoftwareModuleAssigmentRest getRuntime() { + public MgmtSoftwareModuleAssigment getRuntime() { return runtime; } @@ -77,7 +77,7 @@ public class DistributionSetRequestBodyPost extends DistributionSetRequestBodyPu * * @return updated body */ - public DistributionSetRequestBodyPost setRuntime(final SoftwareModuleAssigmentRest runtime) { + public MgmtDistributionSetRequestBodyPost setRuntime(final MgmtSoftwareModuleAssigment runtime) { this.runtime = runtime; return this; @@ -86,7 +86,7 @@ public class DistributionSetRequestBodyPost extends DistributionSetRequestBodyPu /** * @return the application */ - public SoftwareModuleAssigmentRest getApplication() { + public MgmtSoftwareModuleAssigment getApplication() { return application; } @@ -96,7 +96,7 @@ public class DistributionSetRequestBodyPost extends DistributionSetRequestBodyPu * * @return updated body */ - public DistributionSetRequestBodyPost setApplication(final SoftwareModuleAssigmentRest application) { + public MgmtDistributionSetRequestBodyPost setApplication(final MgmtSoftwareModuleAssigment application) { this.application = application; return this; @@ -115,7 +115,7 @@ public class DistributionSetRequestBodyPost extends DistributionSetRequestBodyPu * * @return updated body */ - public DistributionSetRequestBodyPost setRequiredMigrationStep(final boolean requiredMigrationStep) { + public MgmtDistributionSetRequestBodyPost setRequiredMigrationStep(final boolean requiredMigrationStep) { this.requiredMigrationStep = requiredMigrationStep; return this; @@ -124,7 +124,7 @@ public class DistributionSetRequestBodyPost extends DistributionSetRequestBodyPu /** * @return the modules */ - public List getModules() { + public List getModules() { return modules; } @@ -134,7 +134,7 @@ public class DistributionSetRequestBodyPost extends DistributionSetRequestBodyPu * * @return updated body */ - public DistributionSetRequestBodyPost setModules(final List modules) { + public MgmtDistributionSetRequestBodyPost setModules(final List modules) { this.modules = modules; return this; @@ -153,7 +153,7 @@ public class DistributionSetRequestBodyPost extends DistributionSetRequestBodyPu * * @return updated body */ - public DistributionSetRequestBodyPost setType(final String type) { + public MgmtDistributionSetRequestBodyPost setType(final String type) { this.type = type; return this; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyPut.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSetRequestBodyPut.java similarity index 82% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyPut.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSetRequestBodyPut.java index 2f19625f3..4494dd8a8 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyPut.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSetRequestBodyPut.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.distributionset; +package org.eclipse.hawkbit.mgmt.json.model.distributionset; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class DistributionSetRequestBodyPut { +public class MgmtDistributionSetRequestBodyPut { @JsonProperty private String name; @@ -43,7 +43,7 @@ public class DistributionSetRequestBodyPut { * * @return updated body */ - public DistributionSetRequestBodyPut setName(final String name) { + public MgmtDistributionSetRequestBodyPut setName(final String name) { this.name = name; return this; } @@ -61,7 +61,7 @@ public class DistributionSetRequestBodyPut { * * @return updated body */ - public DistributionSetRequestBodyPut setDescription(final String description) { + public MgmtDistributionSetRequestBodyPut setDescription(final String description) { this.description = description; return this; @@ -80,7 +80,7 @@ public class DistributionSetRequestBodyPut { * * @return updated body */ - public DistributionSetRequestBodyPut setVersion(final String version) { + public MgmtDistributionSetRequestBodyPut setVersion(final String version) { this.version = version; return this; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentRequestBody.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentRequestBody.java similarity index 85% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentRequestBody.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentRequestBody.java index 5135a977c..46c43ac8b 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentRequestBody.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentRequestBody.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.distributionset; +package org.eclipse.hawkbit.mgmt.json.model.distributionset; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; @@ -16,14 +16,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; * */ @JsonIgnoreProperties(ignoreUnknown = true) -public class TargetAssignmentRequestBody { +public class MgmtTargetAssignmentRequestBody { @JsonProperty private String id; private long forcetime; - private ActionTypeRest type; + private MgmtActionType type; /** * @return the id @@ -43,7 +43,7 @@ public class TargetAssignmentRequestBody { /** * @return the type */ - public ActionTypeRest getType() { + public MgmtActionType getType() { return type; } @@ -51,7 +51,7 @@ public class TargetAssignmentRequestBody { * @param type * the type to set */ - public void setType(final ActionTypeRest type) { + public void setType(final MgmtActionType type) { this.type = type; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentResponseBody.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBody.java similarity index 93% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentResponseBody.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBody.java index 77676f844..d5247c577 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentResponseBody.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBody.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.distributionset; +package org.eclipse.hawkbit.mgmt.json.model.distributionset; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -20,7 +20,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class TargetAssignmentResponseBody { +public class MgmtTargetAssignmentResponseBody { private int assigned; private int alreadyAssigned; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyPost.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRequestBodyPost.java similarity index 68% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyPost.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRequestBodyPost.java index ba0f548f6..82ecb2cc5 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyPost.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRequestBodyPost.java @@ -6,11 +6,11 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.distributionsettype; +package org.eclipse.hawkbit.mgmt.json.model.distributionsettype; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeAssigmentRest; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssigment; import com.fasterxml.jackson.annotation.JsonProperty; @@ -18,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * Request Body for DistributionSetType POST. * */ -public class DistributionSetTypeRequestBodyPost { +public class MgmtDistributionSetTypeRequestBodyPost { @JsonProperty(required = true) private String name; @@ -30,10 +30,10 @@ public class DistributionSetTypeRequestBodyPost { private String key; @JsonProperty - private List mandatorymodules; + private List mandatorymodules; @JsonProperty - private List optionalmodules; + private List optionalmodules; /** * @return the name @@ -48,7 +48,7 @@ public class DistributionSetTypeRequestBodyPost { * * @return updated body */ - public DistributionSetTypeRequestBodyPost setName(final String name) { + public MgmtDistributionSetTypeRequestBodyPost setName(final String name) { this.name = name; return this; } @@ -66,7 +66,7 @@ public class DistributionSetTypeRequestBodyPost { * * @return updated body */ - public DistributionSetTypeRequestBodyPost setDescription(final String description) { + public MgmtDistributionSetTypeRequestBodyPost setDescription(final String description) { this.description = description; return this; } @@ -84,7 +84,7 @@ public class DistributionSetTypeRequestBodyPost { * * @return updated body */ - public DistributionSetTypeRequestBodyPost setKey(final String key) { + public MgmtDistributionSetTypeRequestBodyPost setKey(final String key) { this.key = key; return this; } @@ -92,7 +92,7 @@ public class DistributionSetTypeRequestBodyPost { /** * @return the mandatory modules */ - public List getMandatorymodules() { + public List getMandatorymodules() { return mandatorymodules; } @@ -102,8 +102,8 @@ public class DistributionSetTypeRequestBodyPost { * * @return updated body */ - public DistributionSetTypeRequestBodyPost setMandatorymodules( - final List mandatorymodules) { + public MgmtDistributionSetTypeRequestBodyPost setMandatorymodules( + final List mandatorymodules) { this.mandatorymodules = mandatorymodules; return this; } @@ -111,7 +111,7 @@ public class DistributionSetTypeRequestBodyPost { /** * @return the optional modules */ - public List getOptionalmodules() { + public List getOptionalmodules() { return optionalmodules; } @@ -121,8 +121,8 @@ public class DistributionSetTypeRequestBodyPost { * * @return updated body */ - public DistributionSetTypeRequestBodyPost setOptionalmodules( - final List optionalmodules) { + public MgmtDistributionSetTypeRequestBodyPost setOptionalmodules( + final List optionalmodules) { this.optionalmodules = optionalmodules; return this; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyPut.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRequestBodyPut.java similarity index 79% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyPut.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRequestBodyPut.java index 6bf21b93f..220f58e4d 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyPut.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRequestBodyPut.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.distributionsettype; +package org.eclipse.hawkbit.mgmt.json.model.distributionsettype; import com.fasterxml.jackson.annotation.JsonProperty; @@ -14,7 +14,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * Request Body for DistributionSetType PUT, i.e. update. * */ -public class DistributionSetTypeRequestBodyPut { +public class MgmtDistributionSetTypeRequestBodyPut { @JsonProperty private String description; @@ -32,7 +32,7 @@ public class DistributionSetTypeRequestBodyPut { * * @return updated body */ - public DistributionSetTypeRequestBodyPut setDescription(final String description) { + public MgmtDistributionSetTypeRequestBodyPut setDescription(final String description) { this.description = description; return this; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRest.java similarity index 87% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRest.java index e282b2924..5717863d1 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRest.java @@ -6,9 +6,9 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.distributionsettype; +package org.eclipse.hawkbit.mgmt.json.model.distributionsettype; -import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -25,7 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class DistributionSetTypeRest extends NamedEntityRest { +public class MgmtDistributionSetTypeRest extends MgmtNamedEntity { @JsonProperty(value = "id", required = true) private Long moduleId; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutCondition.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutCondition.java similarity index 84% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutCondition.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutCondition.java index 914a5d5c2..d83585415 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutCondition.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutCondition.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.rollout; +package org.eclipse.hawkbit.mgmt.json.model.rollout; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -17,7 +17,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class RolloutCondition { +public class MgmtRolloutCondition { private Condition condition = Condition.THRESHOLD; private String expression = "100"; @@ -25,10 +25,11 @@ public class RolloutCondition { /** * */ - public RolloutCondition() { + public MgmtRolloutCondition() { + // needed for jackson json creator. } - public RolloutCondition(final Condition condition, final String expression) { + public MgmtRolloutCondition(final Condition condition, final String expression) { this.condition = condition; this.expression = expression; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutErrorAction.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutErrorAction.java similarity index 93% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutErrorAction.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutErrorAction.java index 2ed6077e6..71fdf3ac9 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutErrorAction.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutErrorAction.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.rollout; +package org.eclipse.hawkbit.mgmt.json.model.rollout; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -17,7 +17,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class RolloutErrorAction { +public class MgmtRolloutErrorAction { private ErrorAction action = ErrorAction.PAUSE; private String expression = null; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutResponseBody.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutResponseBody.java similarity index 94% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutResponseBody.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutResponseBody.java index dd1296cfd..79455f501 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutResponseBody.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutResponseBody.java @@ -6,12 +6,12 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.rollout; +package org.eclipse.hawkbit.mgmt.json.model.rollout; import java.util.HashMap; import java.util.Map; -import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class RolloutResponseBody extends NamedEntityRest { +public class MgmtRolloutResponseBody extends MgmtNamedEntity { private String targetFilterQuery; private Long distributionSetId; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutRestRequestBody.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutRestRequestBody.java similarity index 72% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutRestRequestBody.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutRestRequestBody.java index 0b83948ff..f3bdb2665 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutRestRequestBody.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutRestRequestBody.java @@ -6,10 +6,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.rollout; +package org.eclipse.hawkbit.mgmt.json.model.rollout; -import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; -import org.eclipse.hawkbit.rest.resource.model.distributionset.ActionTypeRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -21,26 +21,26 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class RolloutRestRequestBody extends NamedEntityRest { +public class MgmtRolloutRestRequestBody extends MgmtNamedEntity { private String targetFilterQuery; private long distributionSetId; private int amountGroups = 1; - private RolloutCondition successCondition = new RolloutCondition(); - private RolloutSuccessAction successAction = new RolloutSuccessAction(); - private RolloutCondition errorCondition = null; - private RolloutErrorAction errorAction = null; + private MgmtRolloutCondition successCondition = new MgmtRolloutCondition(); + private MgmtRolloutSuccessAction successAction = new MgmtRolloutSuccessAction(); + private MgmtRolloutCondition errorCondition = null; + private MgmtRolloutErrorAction errorAction = null; private Long forcetime; - private ActionTypeRest type; + private MgmtActionType type; /** * @return the finishCondition */ - public RolloutCondition getSuccessCondition() { + public MgmtRolloutCondition getSuccessCondition() { return successCondition; } @@ -48,14 +48,14 @@ public class RolloutRestRequestBody extends NamedEntityRest { * @param successCondition * the finishCondition to set */ - public void setSuccessCondition(final RolloutCondition successCondition) { + public void setSuccessCondition(final MgmtRolloutCondition successCondition) { this.successCondition = successCondition; } /** * @return the successAction */ - public RolloutSuccessAction getSuccessAction() { + public MgmtRolloutSuccessAction getSuccessAction() { return successAction; } @@ -63,14 +63,14 @@ public class RolloutRestRequestBody extends NamedEntityRest { * @param successAction * the successAction to set */ - public void setSuccessAction(final RolloutSuccessAction successAction) { + public void setSuccessAction(final MgmtRolloutSuccessAction successAction) { this.successAction = successAction; } /** * @return the errorCondition */ - public RolloutCondition getErrorCondition() { + public MgmtRolloutCondition getErrorCondition() { return errorCondition; } @@ -78,7 +78,7 @@ public class RolloutRestRequestBody extends NamedEntityRest { * @param errorCondition * the errorCondition to set */ - public void setErrorCondition(final RolloutCondition errorCondition) { + public void setErrorCondition(final MgmtRolloutCondition errorCondition) { this.errorCondition = errorCondition; } @@ -145,7 +145,7 @@ public class RolloutRestRequestBody extends NamedEntityRest { /** * @return the type */ - public ActionTypeRest getType() { + public MgmtActionType getType() { return type; } @@ -153,14 +153,14 @@ public class RolloutRestRequestBody extends NamedEntityRest { * @param type * the type to set */ - public void setType(final ActionTypeRest type) { + public void setType(final MgmtActionType type) { this.type = type; } /** * @return the errorAction */ - public RolloutErrorAction getErrorAction() { + public MgmtRolloutErrorAction getErrorAction() { return errorAction; } @@ -168,7 +168,7 @@ public class RolloutRestRequestBody extends NamedEntityRest { * @param errorAction * the errorAction to set */ - public void setErrorAction(final RolloutErrorAction errorAction) { + public void setErrorAction(final MgmtRolloutErrorAction errorAction) { this.errorAction = errorAction; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutSuccessAction.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutSuccessAction.java similarity index 84% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutSuccessAction.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutSuccessAction.java index f14e9a8bf..174aa63fa 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rollout/RolloutSuccessAction.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutSuccessAction.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.rollout; +package org.eclipse.hawkbit.mgmt.json.model.rollout; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -17,7 +17,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class RolloutSuccessAction { +public class MgmtRolloutSuccessAction { private SuccessAction action = SuccessAction.NEXTGROUP; private String expression = null; @@ -25,10 +25,11 @@ public class RolloutSuccessAction { /** * */ - public RolloutSuccessAction() { + public MgmtRolloutSuccessAction() { + // needed for json creator } - public RolloutSuccessAction(final SuccessAction action, final String expression) { + public MgmtRolloutSuccessAction(final SuccessAction action, final String expression) { this.action = action; this.expression = expression; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rolloutgroup/RolloutGroupResponseBody.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rolloutgroup/MgmtRolloutGroupResponseBody.java similarity index 88% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rolloutgroup/RolloutGroupResponseBody.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rolloutgroup/MgmtRolloutGroupResponseBody.java index bb1b0116e..5e740a1fb 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/rolloutgroup/RolloutGroupResponseBody.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rolloutgroup/MgmtRolloutGroupResponseBody.java @@ -6,9 +6,9 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.rolloutgroup; +package org.eclipse.hawkbit.mgmt.json.model.rolloutgroup; -import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -21,7 +21,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class RolloutGroupResponseBody extends NamedEntityRest { +public class MgmtRolloutGroupResponseBody extends MgmtNamedEntity { @JsonProperty(value = "id", required = true) private Long rolloutGroupId; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModule.java similarity index 93% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModule.java index a5ab41c8b..fe47347a9 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModule.java @@ -6,9 +6,9 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.softwaremodule; +package org.eclipse.hawkbit.mgmt.json.model.softwaremodule; -import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class SoftwareModuleRest extends NamedEntityRest { +public class MgmtSoftwareModule extends MgmtNamedEntity { /** * API definition for {@link SoftwareModule.Type#RUNTIME}. */ diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleAssigmentRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleAssigment.java similarity index 73% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleAssigmentRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleAssigment.java index 3c866dca6..79bc31ad3 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleAssigmentRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleAssigment.java @@ -6,20 +6,17 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.softwaremodule; +package org.eclipse.hawkbit.mgmt.json.model.softwaremodule; -import org.eclipse.hawkbit.rest.resource.model.IdRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtId; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; /** * Request Body of SoftwareModule for assignment operations (ID only). * - * - * - * */ @JsonIgnoreProperties(ignoreUnknown = true) -public class SoftwareModuleAssigmentRest extends IdRest { +public class MgmtSoftwareModuleAssigment extends MgmtId { } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPost.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleRequestBodyPost.java similarity index 80% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPost.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleRequestBodyPost.java index 08638c10f..e39413915 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPost.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleRequestBodyPost.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.softwaremodule; +package org.eclipse.hawkbit.mgmt.json.model.softwaremodule; import com.fasterxml.jackson.annotation.JsonProperty; @@ -14,7 +14,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * Request Body for SoftwareModule POST. * */ -public class SoftwareModuleRequestBodyPost { +public class MgmtSoftwareModuleRequestBodyPost { @JsonProperty(required = true) private String name; @@ -44,7 +44,7 @@ public class SoftwareModuleRequestBodyPost { * * @return updated body */ - public SoftwareModuleRequestBodyPost setName(final String name) { + public MgmtSoftwareModuleRequestBodyPost setName(final String name) { this.name = name; return this; } @@ -62,7 +62,7 @@ public class SoftwareModuleRequestBodyPost { * * @return updated body */ - public SoftwareModuleRequestBodyPost setVersion(final String version) { + public MgmtSoftwareModuleRequestBodyPost setVersion(final String version) { this.version = version; return this; } @@ -80,7 +80,7 @@ public class SoftwareModuleRequestBodyPost { * * @return updated body */ - public SoftwareModuleRequestBodyPost setType(final String type) { + public MgmtSoftwareModuleRequestBodyPost setType(final String type) { this.type = type; return this; } @@ -98,7 +98,7 @@ public class SoftwareModuleRequestBodyPost { * * @return updated body */ - public SoftwareModuleRequestBodyPost setDescription(final String description) { + public MgmtSoftwareModuleRequestBodyPost setDescription(final String description) { this.description = description; return this; } @@ -116,7 +116,7 @@ public class SoftwareModuleRequestBodyPost { * * @return updated body */ - public SoftwareModuleRequestBodyPost setVendor(final String vendor) { + public MgmtSoftwareModuleRequestBodyPost setVendor(final String vendor) { this.vendor = vendor; return this; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPut.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleRequestBodyPut.java similarity index 80% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPut.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleRequestBodyPut.java index 1ee547886..52c097e39 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPut.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleRequestBodyPut.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.softwaremodule; +package org.eclipse.hawkbit.mgmt.json.model.softwaremodule; import com.fasterxml.jackson.annotation.JsonProperty; @@ -14,7 +14,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * Request Body for SoftwareModule PUT. * */ -public class SoftwareModuleRequestBodyPut { +public class MgmtSoftwareModuleRequestBodyPut { @JsonProperty private String description; @@ -35,7 +35,7 @@ public class SoftwareModuleRequestBodyPut { * * @return updated body */ - public SoftwareModuleRequestBodyPut setDescription(final String description) { + public MgmtSoftwareModuleRequestBodyPut setDescription(final String description) { this.description = description; return this; } @@ -53,7 +53,7 @@ public class SoftwareModuleRequestBodyPut { * * @return updated body */ - public SoftwareModuleRequestBodyPut setVendor(final String vendor) { + public MgmtSoftwareModuleRequestBodyPut setVendor(final String vendor) { this.vendor = vendor; return this; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleType.java similarity index 90% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleType.java index ed05c1ee4..c0cda4994 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleType.java @@ -6,9 +6,9 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.softwaremoduletype; +package org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype; -import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class SoftwareModuleTypeRest extends NamedEntityRest { +public class MgmtSoftwareModuleType extends MgmtNamedEntity { @JsonProperty(value = "id", required = true) private Long moduleId; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeAssigmentRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeAssigment.java similarity index 73% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeAssigmentRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeAssigment.java index 68709650b..43bdc157e 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeAssigmentRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeAssigment.java @@ -6,9 +6,9 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.softwaremoduletype; +package org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype; -import org.eclipse.hawkbit.rest.resource.model.IdRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtId; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -17,6 +17,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; * */ @JsonIgnoreProperties(ignoreUnknown = true) -public class SoftwareModuleTypeAssigmentRest extends IdRest { +public class MgmtSoftwareModuleTypeAssigment extends MgmtId { } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPost.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeRequestBodyPost.java similarity index 79% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPost.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeRequestBodyPost.java index 3528f6b98..836c39d19 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPost.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeRequestBodyPost.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.softwaremoduletype; +package org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype; import com.fasterxml.jackson.annotation.JsonProperty; @@ -14,7 +14,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * Request Body for SoftwareModuleType POST. * */ -public class SoftwareModuleTypeRequestBodyPost { +public class MgmtSoftwareModuleTypeRequestBodyPost { @JsonProperty(required = true) private String name; @@ -41,7 +41,7 @@ public class SoftwareModuleTypeRequestBodyPost { * * @return updated body */ - public SoftwareModuleTypeRequestBodyPost setName(final String name) { + public MgmtSoftwareModuleTypeRequestBodyPost setName(final String name) { this.name = name; return this; } @@ -59,7 +59,7 @@ public class SoftwareModuleTypeRequestBodyPost { * * @return updated body */ - public SoftwareModuleTypeRequestBodyPost setDescription(final String description) { + public MgmtSoftwareModuleTypeRequestBodyPost setDescription(final String description) { this.description = description; return this; } @@ -76,7 +76,7 @@ public class SoftwareModuleTypeRequestBodyPost { * the key to set * @return updated body */ - public SoftwareModuleTypeRequestBodyPost setKey(final String key) { + public MgmtSoftwareModuleTypeRequestBodyPost setKey(final String key) { this.key = key; return this; } @@ -94,7 +94,7 @@ public class SoftwareModuleTypeRequestBodyPost { * * @return updated body */ - public SoftwareModuleTypeRequestBodyPost setMaxAssignments(final int maxAssignments) { + public MgmtSoftwareModuleTypeRequestBodyPost setMaxAssignments(final int maxAssignments) { this.maxAssignments = maxAssignments; return this; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPut.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeRequestBodyPut.java similarity index 79% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPut.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeRequestBodyPut.java index 107a3cd2b..ecc8c9f65 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPut.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeRequestBodyPut.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.softwaremoduletype; +package org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype; import com.fasterxml.jackson.annotation.JsonProperty; @@ -14,7 +14,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * Request Body for SoftwareModuleType PUT. * */ -public class SoftwareModuleTypeRequestBodyPut { +public class MgmtSoftwareModuleTypeRequestBodyPut { @JsonProperty private String description; @@ -32,7 +32,7 @@ public class SoftwareModuleTypeRequestBodyPut { * * @return updated body */ - public SoftwareModuleTypeRequestBodyPut setDescription(final String description) { + public MgmtSoftwareModuleTypeRequestBodyPut setDescription(final String description) { this.description = description; return this; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/AssignedDistributionSetRequestBody.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtAssignedDistributionSetRequestBody.java similarity index 81% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/AssignedDistributionSetRequestBody.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtAssignedDistributionSetRequestBody.java index 2bfd6cbf8..469780abf 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/AssignedDistributionSetRequestBody.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtAssignedDistributionSetRequestBody.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.tag; +package org.eclipse.hawkbit.mgmt.json.model.tag; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class AssignedDistributionSetRequestBody { +public class MgmtAssignedDistributionSetRequestBody { @JsonProperty(value = "id", required = true) private Long distributionSetId; @@ -28,7 +28,7 @@ public class AssignedDistributionSetRequestBody { return distributionSetId; } - public AssignedDistributionSetRequestBody setDistributionSetId(final Long distributionSetId) { + public MgmtAssignedDistributionSetRequestBody setDistributionSetId(final Long distributionSetId) { this.distributionSetId = distributionSetId; return this; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/AssignedTargetRequestBody.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtAssignedTargetRequestBody.java similarity index 83% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/AssignedTargetRequestBody.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtAssignedTargetRequestBody.java index 2147c2697..6df1d10d7 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/AssignedTargetRequestBody.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtAssignedTargetRequestBody.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.tag; +package org.eclipse.hawkbit.mgmt.json.model.tag; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class AssignedTargetRequestBody { +public class MgmtAssignedTargetRequestBody { @JsonProperty(required = true) private String controllerId; @@ -28,7 +28,7 @@ public class AssignedTargetRequestBody { return controllerId; } - public AssignedTargetRequestBody setControllerId(final String controllerId) { + public MgmtAssignedTargetRequestBody setControllerId(final String controllerId) { this.controllerId = controllerId; return this; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/DistributionSetTagAssigmentResultRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtDistributionSetTagAssigmentResult.java similarity index 61% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/DistributionSetTagAssigmentResultRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtDistributionSetTagAssigmentResult.java index 2078fe891..892bac453 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/DistributionSetTagAssigmentResultRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtDistributionSetTagAssigmentResult.java @@ -6,11 +6,11 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.tag; +package org.eclipse.hawkbit.mgmt.json.model.tag; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -24,27 +24,27 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class DistributionSetTagAssigmentResultRest { +public class MgmtDistributionSetTagAssigmentResult { @JsonProperty - private List assignedDistributionSets; + private List assignedDistributionSets; @JsonProperty - private List unassignedDistributionSets; + private List unassignedDistributionSets; - public List getAssignedDistributionSets() { + public List getAssignedDistributionSets() { return assignedDistributionSets; } - public List getUnassignedDistributionSets() { + public List getUnassignedDistributionSets() { return unassignedDistributionSets; } - public void setAssignedDistributionSets(final List assignedDistributionSets) { + public void setAssignedDistributionSets(final List assignedDistributionSets) { this.assignedDistributionSets = assignedDistributionSets; } - public void setUnassignedDistributionSets(final List unassignedDistributionSets) { + public void setUnassignedDistributionSets(final List unassignedDistributionSets) { this.unassignedDistributionSets = unassignedDistributionSets; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtTag.java similarity index 87% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtTag.java index 54d3c5064..82c33b434 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtTag.java @@ -6,9 +6,9 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.tag; +package org.eclipse.hawkbit.mgmt.json.model.tag; -import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class TagRest extends NamedEntityRest { +public class MgmtTag extends MgmtNamedEntity { @JsonProperty(value = "id", required = true) private Long tagId; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagRequestBodyPut.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtTagRequestBodyPut.java similarity index 80% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagRequestBodyPut.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtTagRequestBodyPut.java index 2165bcfc0..e7037af2b 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagRequestBodyPut.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtTagRequestBodyPut.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.tag; +package org.eclipse.hawkbit.mgmt.json.model.tag; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class TagRequestBodyPut { +public class MgmtTagRequestBodyPut { @JsonProperty private String colour; @@ -34,7 +34,7 @@ public class TagRequestBodyPut { return name; } - public TagRequestBodyPut setName(final String name) { + public MgmtTagRequestBodyPut setName(final String name) { this.name = name; return this; } @@ -43,12 +43,12 @@ public class TagRequestBodyPut { return description; } - public TagRequestBodyPut setDescription(final String description) { + public MgmtTagRequestBodyPut setDescription(final String description) { this.description = description; return this; } - public TagRequestBodyPut setColour(final String colour) { + public MgmtTagRequestBodyPut setColour(final String colour) { this.colour = colour; return this; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TargetTagAssigmentResultRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtTargetTagAssigmentResult.java similarity index 67% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TargetTagAssigmentResultRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtTargetTagAssigmentResult.java index 30d47cc90..61625e59d 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TargetTagAssigmentResultRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/tag/MgmtTargetTagAssigmentResult.java @@ -6,11 +6,11 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.tag; +package org.eclipse.hawkbit.mgmt.json.model.tag; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.target.TargetRest; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -24,27 +24,27 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class TargetTagAssigmentResultRest { +public class MgmtTargetTagAssigmentResult { @JsonProperty - private List assignedTargets; + private List assignedTargets; @JsonProperty - private List unassignedTargets; + private List unassignedTargets; - public void setAssignedTargets(final List assignedTargets) { + public void setAssignedTargets(final List assignedTargets) { this.assignedTargets = assignedTargets; } - public List getAssignedTargets() { + public List getAssignedTargets() { return assignedTargets; } - public void setUnassignedTargets(final List unassignedTargets) { + public void setUnassignedTargets(final List unassignedTargets) { this.unassignedTargets = unassignedTargets; } - public List getUnassignedTargets() { + public List getUnassignedTargets() { return unassignedTargets; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/DistributionSetAssigmentRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtDistributionSetAssigment.java similarity index 64% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/DistributionSetAssigmentRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtDistributionSetAssigment.java index c2dc7f4a9..edfcc5687 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/DistributionSetAssigmentRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtDistributionSetAssigment.java @@ -1,23 +1,23 @@ /** * Copyright (c) 2011-2015 Bosch Software Innovations GmbH, Germany. All rights reserved. */ -package org.eclipse.hawkbit.rest.resource.model.target; +package org.eclipse.hawkbit.mgmt.json.model.target; -import org.eclipse.hawkbit.rest.resource.model.IdRest; -import org.eclipse.hawkbit.rest.resource.model.distributionset.ActionTypeRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtId; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; /** * Request Body of DistributionSet for assignment operations (ID only). * */ -public class DistributionSetAssigmentRest extends IdRest { +public class MgmtDistributionSetAssigment extends MgmtId { private long forcetime; - private ActionTypeRest type; + private MgmtActionType type; /** * @return the type */ - public ActionTypeRest getType() { + public MgmtActionType getType() { return type; } @@ -25,7 +25,7 @@ public class DistributionSetAssigmentRest extends IdRest { * @param type * the type to set */ - public void setType(final ActionTypeRest type) { + public void setType(final MgmtActionType type) { this.type = type; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRest.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTarget.java similarity index 90% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRest.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTarget.java index 37baeeec9..40dd553a5 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRest.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTarget.java @@ -1,12 +1,12 @@ /** * Copyright (c) 2011-2015 Bosch Software Innovations GmbH, Germany. All rights reserved. */ -package org.eclipse.hawkbit.rest.resource.model.target; +package org.eclipse.hawkbit.mgmt.json.model.target; import java.net.URI; -import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; -import org.eclipse.hawkbit.rest.resource.model.PollStatusRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; +import org.eclipse.hawkbit.mgmt.json.model.MgmtPollStatus; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -20,7 +20,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class TargetRest extends NamedEntityRest { +public class MgmtTarget extends MgmtNamedEntity { @JsonProperty(required = true) private String controllerId; @@ -41,7 +41,7 @@ public class TargetRest extends NamedEntityRest { private String address; @JsonProperty - private PollStatusRest pollStatus; + private MgmtPollStatus pollStatus; @JsonProperty private String securityToken; @@ -111,7 +111,7 @@ public class TargetRest extends NamedEntityRest { /** * @return the pollStatus */ - public PollStatusRest getPollStatus() { + public MgmtPollStatus getPollStatus() { return pollStatus; } @@ -120,7 +120,7 @@ public class TargetRest extends NamedEntityRest { * the pollStatus to set */ @JsonIgnore - public void setPollStatus(final PollStatusRest pollStatus) { + public void setPollStatus(final MgmtPollStatus pollStatus) { this.pollStatus = pollStatus; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetAttributes.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTargetAttributes.java similarity index 63% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetAttributes.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTargetAttributes.java index 821be6b45..dad8e868f 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetAttributes.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTargetAttributes.java @@ -1,7 +1,7 @@ /** * Copyright (c) 2011-2015 Bosch Software Innovations GmbH, Germany. All rights reserved. */ -package org.eclipse.hawkbit.rest.resource.model.target; +package org.eclipse.hawkbit.mgmt.json.model.target; import java.util.HashMap; import java.util.Map; @@ -10,6 +10,6 @@ import java.util.Map; * {@link Map} with attributes of SP Target. * */ -public class TargetAttributes extends HashMap { +public class MgmtTargetAttributes extends HashMap { } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRequestBody.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTargetRequestBody.java similarity index 78% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRequestBody.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTargetRequestBody.java index bc1ca8a63..bc40326e4 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRequestBody.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTargetRequestBody.java @@ -1,7 +1,7 @@ /** * Copyright (c) 2011-2015 Bosch Software Innovations GmbH, Germany. All rights reserved. */ -package org.eclipse.hawkbit.rest.resource.model.target; +package org.eclipse.hawkbit.mgmt.json.model.target; import com.fasterxml.jackson.annotation.JsonProperty; @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * Request body for target PUT/POST commands. * */ -public class TargetRequestBody { +public class MgmtTargetRequestBody { @JsonProperty(required = true) private String name; @@ -43,7 +43,7 @@ public class TargetRequestBody { * @param name * the name to set */ - public TargetRequestBody setName(final String name) { + public MgmtTargetRequestBody setName(final String name) { this.name = name; return this; } @@ -52,7 +52,7 @@ public class TargetRequestBody { * @param description * the description to set */ - public TargetRequestBody setDescription(final String description) { + public MgmtTargetRequestBody setDescription(final String description) { this.description = description; return this; } @@ -61,7 +61,7 @@ public class TargetRequestBody { * @param controllerId * the controllerId to set */ - public TargetRequestBody setControllerId(final String controllerId) { + public MgmtTargetRequestBody setControllerId(final String controllerId) { this.controllerId = controllerId; return this; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/DistributionSetRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java similarity index 76% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/DistributionSetRestApi.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java index 80caefc94..26788760e 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/DistributionSetRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java @@ -7,21 +7,20 @@ * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.api; +package org.eclipse.hawkbit.mgmt.rest.api; import java.util.List; -import org.eclipse.hawkbit.rest.resource.RestConstants; -import org.eclipse.hawkbit.rest.resource.model.MetadataRest; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPut; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest; -import org.eclipse.hawkbit.rest.resource.model.distributionset.TargetAssignmentRequestBody; -import org.eclipse.hawkbit.rest.resource.model.distributionset.TargetAssignmentResponseBody; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleAssigmentRest; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest; -import org.eclipse.hawkbit.rest.resource.model.target.TargetRest; +import org.eclipse.hawkbit.mgmt.json.model.MetadataRest; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPut; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentRequestBody; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentResponseBody; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssigment; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; @@ -33,8 +32,8 @@ import org.springframework.web.bind.annotation.RequestParam; /** * REST Resource handling for DistributionSet CRUD operations. */ -@RequestMapping(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) -public interface DistributionSetRestApi { +@RequestMapping(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) +public interface MgmtDistributionSetRestApi { /** * Handles the GET request of retrieving all DistributionSets . @@ -56,11 +55,11 @@ public interface DistributionSetRestApi { * JsonResponseExceptionHandler is handling the response. */ @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> getDistributionSets( - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + public ResponseEntity> getDistributionSets( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); /** * Handles the GET request of retrieving a single DistributionSet . @@ -75,7 +74,7 @@ public interface DistributionSetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getDistributionSet( + public ResponseEntity getDistributionSet( @PathVariable("distributionSetId") final Long distributionSetId); /** @@ -91,8 +90,8 @@ public interface DistributionSetRestApi { */ @RequestMapping(method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> createDistributionSets( - @RequestBody final List sets); + public ResponseEntity> createDistributionSets( + @RequestBody final List sets); /** * Handles the DELETE request for a single DistributionSet . @@ -118,9 +117,9 @@ public interface DistributionSetRestApi { */ @RequestMapping(method = RequestMethod.PUT, value = "/{distributionSetId}", consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - public ResponseEntity updateDistributionSet( + public ResponseEntity updateDistributionSet( @PathVariable("distributionSetId") final Long distributionSetId, - @RequestBody final DistributionSetRequestBodyPut toUpdate); + @RequestBody final MgmtDistributionSetRequestBodyPut toUpdate); /** * Handles the GET request of retrieving assigned targets to a specific @@ -146,12 +145,12 @@ public interface DistributionSetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/assignedTargets", produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - public ResponseEntity> getAssignedTargets( + public ResponseEntity> getAssignedTargets( @PathVariable("distributionSetId") final Long distributionSetId, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); /** * Handles the GET request of retrieving installed targets to a specific @@ -177,12 +176,12 @@ public interface DistributionSetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/installedTargets", produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - public ResponseEntity> getInstalledTargets( + public ResponseEntity> getInstalledTargets( @PathVariable("distributionSetId") final Long distributionSetId, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); /** * Handles the POST request of assigning multiple targets to a single @@ -200,9 +199,9 @@ public interface DistributionSetRestApi { @RequestMapping(method = RequestMethod.POST, value = "/{distributionSetId}/assignedTargets", consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - public ResponseEntity createAssignedTarget( + public ResponseEntity createAssignedTarget( @PathVariable("distributionSetId") final Long distributionSetId, - @RequestBody final List targetIds); + @RequestBody final List targetIds); /** * Gets a paged list of meta data for a distribution set. @@ -228,10 +227,10 @@ public interface DistributionSetRestApi { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) public ResponseEntity> getMetadata( @PathVariable("distributionSetId") final Long distributionSetId, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); /** * Gets a single meta data value for a specific key of a distribution set. @@ -311,7 +310,7 @@ public interface DistributionSetRestApi { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity assignSoftwareModules(@PathVariable("distributionSetId") final Long distributionSetId, - @RequestBody final List softwareModuleIDs); + @RequestBody final List softwareModuleIDs); /** * Deletes the assignment of the software module form the distribution set. @@ -355,9 +354,9 @@ public interface DistributionSetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/assignedSM", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> getAssignedSoftwareModules( + public ResponseEntity> getAssignedSoftwareModules( @PathVariable("distributionSetId") final Long distributionSetId, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam); + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam); } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/DistributionSetTagRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java similarity index 72% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/DistributionSetTagRestApi.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java index 83f29bb17..316f2a56e 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/DistributionSetTagRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java @@ -2,21 +2,20 @@ * 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 + * are made available under the terms of the Eclipse License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.api; +package org.eclipse.hawkbit.mgmt.rest.api; import java.util.List; -import org.eclipse.hawkbit.rest.resource.RestConstants; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest; -import org.eclipse.hawkbit.rest.resource.model.tag.AssignedDistributionSetRequestBody; -import org.eclipse.hawkbit.rest.resource.model.tag.DistributionSetTagAssigmentResultRest; -import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut; -import org.eclipse.hawkbit.rest.resource.model.tag.TagRest; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtAssignedDistributionSetRequestBody; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtDistributionSetTagAssigmentResult; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; @@ -29,8 +28,8 @@ import org.springframework.web.bind.annotation.RequestParam; * REST Resource handling for DistributionSetTag CRUD operations. * */ -@RequestMapping(RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING) -public interface DistributionSetTagRestApi { +@RequestMapping(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING) +public interface MgmtDistributionSetTagRestApi { /** * Handles the GET request of retrieving all DistributionSet tags. * @@ -52,11 +51,11 @@ public interface DistributionSetTagRestApi { * JsonResponseExceptionHandler is handling the response. */ @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> getDistributionSetTags( - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getDistributionSetTags( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); /** * Handles the GET request of retrieving a single distribution set tag. @@ -71,7 +70,7 @@ public interface DistributionSetTagRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionsetTagId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getDistributionSetTag( + ResponseEntity getDistributionSetTag( @PathVariable("distributionsetTagId") final Long distributionsetTagId); /** @@ -86,7 +85,7 @@ public interface DistributionSetTagRestApi { */ @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> createDistributionSetTags(@RequestBody final List tags); + ResponseEntity> createDistributionSetTags(@RequestBody final List tags); /** * @@ -104,9 +103,9 @@ public interface DistributionSetTagRestApi { */ @RequestMapping(method = RequestMethod.PUT, value = "/{distributionsetTagId}", consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity updateDistributionSetTag( + ResponseEntity updateDistributionSetTag( @PathVariable("distributionsetTagId") final Long distributionsetTagId, - @RequestBody final TagRequestBodyPut restDSTagRest); + @RequestBody final MgmtTagRequestBodyPut restDSTagRest); /** * Handles the DELETE request for a single distribution set tag. @@ -120,7 +119,7 @@ public interface DistributionSetTagRestApi { * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionsetTagId}") - public ResponseEntity deleteDistributionSetTag( + ResponseEntity deleteDistributionSetTag( @PathVariable("distributionsetTagId") final Long distributionsetTagId); /** @@ -135,8 +134,8 @@ public interface DistributionSetTagRestApi { * in case the given {@code distributionsetTagId} doesn't * exists. */ - @RequestMapping(method = RequestMethod.GET, value = RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING) - public ResponseEntity> getAssignedDistributionSets( + @RequestMapping(method = RequestMethod.GET, value = MgmtRestConstants.DISTRIBUTIONSET_REQUEST_MAPPING) + ResponseEntity> getAssignedDistributionSets( @PathVariable("distributionsetTagId") final Long distributionsetTagId); /** @@ -154,11 +153,11 @@ public interface DistributionSetTagRestApi { * in case the given {@code distributionsetTagId} doesn't * exists. */ - @RequestMapping(method = RequestMethod.POST, value = RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING + @RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.DISTRIBUTIONSET_REQUEST_MAPPING + "/toggleTagAssignment") - public ResponseEntity toggleTagAssignment( + ResponseEntity toggleTagAssignment( @PathVariable("distributionsetTagId") final Long distributionsetTagId, - @RequestBody final List assignedDSRequestBodies); + @RequestBody final List assignedDSRequestBodies); /** * Handles the POST request to assign distribution sets to the given tag id. @@ -173,10 +172,10 @@ public interface DistributionSetTagRestApi { * in case the given {@code distributionsetTagId} doesn't * exists. */ - @RequestMapping(method = RequestMethod.POST, value = RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING) - public ResponseEntity> assignDistributionSets( + @RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.DISTRIBUTIONSET_REQUEST_MAPPING) + ResponseEntity> assignDistributionSets( @PathVariable("distributionsetTagId") final Long distributionsetTagId, - @RequestBody final List assignedDSRequestBodies); + @RequestBody final List assignedDSRequestBodies); /** * Handles the DELETE request to unassign all distribution set from the @@ -189,8 +188,8 @@ public interface DistributionSetTagRestApi { * in case the given {@code distributionsetTagId} doesn't * exists. */ - @RequestMapping(method = RequestMethod.DELETE, value = RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING) - public ResponseEntity unassignDistributionSets( + @RequestMapping(method = RequestMethod.DELETE, value = MgmtRestConstants.DISTRIBUTIONSET_REQUEST_MAPPING) + ResponseEntity unassignDistributionSets( @PathVariable("distributionsetTagId") final Long distributionsetTagId); /** @@ -206,9 +205,8 @@ public interface DistributionSetTagRestApi { * in case the given {@code distributionsetTagId} doesn't * exists. */ - @RequestMapping(method = RequestMethod.DELETE, value = RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING + @RequestMapping(method = RequestMethod.DELETE, value = MgmtRestConstants.DISTRIBUTIONSET_REQUEST_MAPPING + "/{distributionsetId}") - public ResponseEntity unassignDistributionSet( - @PathVariable("distributionsetTagId") final Long distributionsetTagId, + ResponseEntity unassignDistributionSet(@PathVariable("distributionsetTagId") final Long distributionsetTagId, @PathVariable("distributionsetId") final Long distributionsetId); } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/DistributionSetTypeRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java similarity index 72% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/DistributionSetTypeRestApi.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java index 1900d8d7d..28af107f7 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/DistributionSetTypeRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java @@ -2,21 +2,20 @@ * 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 + * are made available under the terms of the Eclipse License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.api; +package org.eclipse.hawkbit.mgmt.rest.api; import java.util.List; -import org.eclipse.hawkbit.rest.resource.RestConstants; -import org.eclipse.hawkbit.rest.resource.model.IdRest; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyPut; -import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRest; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRest; +import org.eclipse.hawkbit.mgmt.json.model.MgmtId; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPut; +import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRest; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; @@ -30,8 +29,8 @@ import org.springframework.web.bind.annotation.RequestParam; * operations. * */ -@RequestMapping(RestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) -public interface DistributionSetTypeRestApi { +@RequestMapping(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) +public interface MgmtDistributionSetTypeRestApi { /** * Handles the GET request of retrieving all DistributionSetTypes. @@ -55,11 +54,11 @@ public interface DistributionSetTypeRestApi { * response. */ @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> getDistributionSetTypes( - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getDistributionSetTypes( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); /** * Handles the GET request of retrieving a single DistributionSetType @@ -74,7 +73,7 @@ public interface DistributionSetTypeRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getDistributionSetType( + ResponseEntity getDistributionSetType( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId); /** @@ -86,7 +85,7 @@ public interface DistributionSetTypeRestApi { * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetTypeId}") - public ResponseEntity deleteDistributionSetType( + ResponseEntity deleteDistributionSetType( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId); /** @@ -100,9 +99,9 @@ public interface DistributionSetTypeRestApi { */ @RequestMapping(method = RequestMethod.PUT, value = "/{distributionSetTypeId}", consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity updateDistributionSetType( + ResponseEntity updateDistributionSetType( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, - @RequestBody final DistributionSetTypeRequestBodyPut restDistributionSetType); + @RequestBody final MgmtDistributionSetTypeRequestBodyPut restDistributionSetType); /** * Handles the POST request of creating new DistributionSetTypes. The @@ -117,8 +116,8 @@ public interface DistributionSetTypeRestApi { */ @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> createDistributionSetTypes( - @RequestBody final List distributionSetTypes); + ResponseEntity> createDistributionSetTypes( + @RequestBody final List distributionSetTypes); /** * Handles the GET request of retrieving the list of mandatory software @@ -129,9 +128,9 @@ public interface DistributionSetTypeRestApi { * @return Unpaged list of module types and OK in case of success. */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}/" - + RestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, produces = { "application/hal+json", + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> getMandatoryModules( + ResponseEntity> getMandatoryModules( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId); /** @@ -145,9 +144,9 @@ public interface DistributionSetTypeRestApi { * @return Unpaged list of module types and OK in case of success. */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}/" - + RestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES + "/{softwareModuleTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getMandatoryModule( + ResponseEntity getMandatoryModule( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId); @@ -162,9 +161,9 @@ public interface DistributionSetTypeRestApi { * @return Unpaged list of module types and OK in case of success. */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}/" - + RestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES + "/{softwareModuleTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getOptionalModule( + ResponseEntity getOptionalModule( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId); @@ -177,9 +176,9 @@ public interface DistributionSetTypeRestApi { * @return Unpaged list of module types and OK in case of success. */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}/" - + RestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, produces = { "application/hal+json", + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> getOptionalModules( + ResponseEntity> getOptionalModules( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId); /** @@ -194,10 +193,9 @@ public interface DistributionSetTypeRestApi { * @return OK if the request was successful */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetTypeId}/" - + RestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES + "/{softwareModuleTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity removeMandatoryModule( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, + ResponseEntity removeMandatoryModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId); /** @@ -212,10 +210,9 @@ public interface DistributionSetTypeRestApi { * @return OK if the request was successful */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetTypeId}/" - + RestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES + "/{softwareModuleTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity removeOptionalModule( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, + ResponseEntity removeOptionalModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId); /** @@ -230,11 +227,11 @@ public interface DistributionSetTypeRestApi { * @return OK if the request was successful */ @RequestMapping(method = RequestMethod.POST, value = "/{distributionSetTypeId}/" - + RestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, consumes = { "application/hal+json", + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity addMandatoryModule( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @RequestBody final IdRest smtId); + ResponseEntity addMandatoryModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId, + @RequestBody final MgmtId smtId); /** * Handles the POST request for adding an optional software module type to a @@ -248,10 +245,10 @@ public interface DistributionSetTypeRestApi { * @return OK if the request was successful */ @RequestMapping(method = RequestMethod.POST, value = "/{distributionSetTypeId}/" - + RestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, consumes = { "application/hal+json", + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity addOptionalModule( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @RequestBody final IdRest smtId); + ResponseEntity addOptionalModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId, + @RequestBody final MgmtId smtId); } diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java new file mode 100644 index 000000000..e07d77f2f --- /dev/null +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java @@ -0,0 +1,46 @@ +/** + * 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.mgmt.rest.api; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * + */ +@RequestMapping(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) +public interface MgmtDownloadArtifactRestApi { + + /** + * Handles the GET request for downloading an artifact. + * + * @param softwareModuleId + * of the parent SoftwareModule + * @param artifactId + * of the related LocalArtifact + * @param servletResponse + * of the servlet + * @param request + * of the client + * + * @return responseEntity with status ok if successful + */ + @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/artifacts/{artifactId}/download") + @ResponseBody + ResponseEntity downloadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, + @PathVariable("artifactId") final Long artifactId, final HttpServletResponse servletResponse, + final HttpServletRequest request); + +} diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadRestApi.java new file mode 100644 index 000000000..c7caed01b --- /dev/null +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadRestApi.java @@ -0,0 +1,42 @@ +/** + * 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.mgmt.rest.api; + +import javax.servlet.http.HttpServletResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * A resource for download artifacts. + * + */ +@RequestMapping(MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE) +public interface MgmtDownloadRestApi { + + /** + * Handles the GET request for downloading an artifact. + * + * @param downloadId + * the generated download id + * @param response + * of the servlet + * @return {@link ResponseEntity} with status {@link HttpStatus#OK} if + * successful + */ + @RequestMapping(method = RequestMethod.GET, value = MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING) + @ResponseBody + ResponseEntity downloadArtifactByDownloadId(@PathVariable final String downloadId, + final HttpServletResponse response); + +} diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/RestConstants.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java similarity index 92% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/RestConstants.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java index bde96f7a8..d8f395568 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/RestConstants.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.api; /** * Constants for RESTful API. @@ -14,23 +14,13 @@ package org.eclipse.hawkbit.rest.resource; * * */ -public final class RestConstants { +public final class MgmtRestConstants { /** * API version definition. We are using only major versions. */ public static final String API_VERSION = "v1"; - /** - * The base URL mapping for the spring acuator management context path. - */ - public static final String BASE_SYSTEM_MAPPING = "/system"; - - /** - * URL mapping for system admin operations. - */ - public static final String SYSTEM_ADMIN_MAPPING = BASE_SYSTEM_MAPPING + "/admin"; - /** * The base URL mapping of the SP rest resources. */ @@ -50,6 +40,64 @@ public final class RestConstants { */ public static final String REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT = "50"; + /** + * The software module URL mapping rest resource. + */ + public static final String SOFTWAREMODULE_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/softwaremodules"; + + public static final String DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE = "/api/" + API_VERSION + "/downloadserver/"; + public static final String DOWNLOAD_ID_V1_REQUEST_MAPPING = "downloadId/{downloadId}"; + + /** + * The target URL mapping, href link for assigned distribution set. + */ + public static final String TARGET_V1_ASSIGNED_DISTRIBUTION_SET = "assignedDS"; + /** + * The target URL mapping, href link for installed distribution set. + */ + public static final String TARGET_V1_INSTALLED_DISTRIBUTION_SET = "installedDS"; + /** + * The target URL mapping, href link for target attributes. + */ + public static final String TARGET_V1_ATTRIBUTES = "attributes"; + /** + * The target URL mapping, href link for target actions. + */ + public static final String TARGET_V1_ACTIONS = "actions"; + /** + * The target URL mapping, href link for canceled actions. + */ + public static final String TARGET_V1_CANCELED_ACTION = "canceledaction"; + /** + * The target URL mapping, href link for canceled actions. + */ + public static final String TARGET_V1_ACTION_STATUS = "status"; + + /** + * The target URL mapping rest resource. + */ + public static final String TARGET_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/targets"; + + /** + * The tag URL mapping rest resource. + */ + public static final String TARGET_TAG_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/targettags"; + /** + * The tag URL mapping rest resource. + */ + public static final String TARGET_TAG_TAGERTS_REQUEST_MAPPING = "/{targetTagId}/targets"; + + /** + * The tag URL mapping rest resource. + */ + public static final String DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + + "/distributionsettags"; + + /** + * The tag URL mapping rest resource. + */ + public static final String DISTRIBUTIONSET_REQUEST_MAPPING = "/{distributionsetTagId}/distributionsets"; + /** * The default offset parameter in case the offset parameter is not present * in the request. @@ -87,62 +135,6 @@ public final class RestConstants { */ public static final String REQUEST_PARAMETER_SEARCH = "q"; - /** - * The target URL mapping, href link for assigned distribution set. - */ - public static final String TARGET_V1_ASSIGNED_DISTRIBUTION_SET = "assignedDS"; - /** - * The target URL mapping, href link for installed distribution set. - */ - public static final String TARGET_V1_INSTALLED_DISTRIBUTION_SET = "installedDS"; - /** - * The target URL mapping, href link for target attributes. - */ - public static final String TARGET_V1_ATTRIBUTES = "attributes"; - /** - * The target URL mapping, href link for target actions. - */ - public static final String TARGET_V1_ACTIONS = "actions"; - /** - * The target URL mapping, href link for canceled actions. - */ - public static final String TARGET_V1_CANCELED_ACTION = "canceledaction"; - /** - * The target URL mapping, href link for canceled actions. - */ - public static final String TARGET_V1_ACTION_STATUS = "status"; - - /** - * The target URL mapping rest resource. - */ - public static final String TARGET_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/targets"; - - public static final String SYSTEM_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/system"; - /** - * The software module URL mapping rest resource. - */ - public static final String SOFTWAREMODULE_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/softwaremodules"; - - /** - * The tag URL mapping rest resource. - */ - public static final String TARGET_TAG_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/targettags"; - /** - * The tag URL mapping rest resource. - */ - public static final String TARGET_TAG_TAGERTS_REQUEST_MAPPING = "/{targetTagId}/targets"; - - /** - * The tag URL mapping rest resource. - */ - public static final String DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING - + "/distributionsettags"; - - /** - * The tag URL mapping rest resource. - */ - public static final String DISTRIBUTIONSET_REQUEST_MAPPING = "/{distributionsetTagId}/distributionsets"; - /** * The software module type URL mapping rest resource. */ @@ -184,11 +176,8 @@ public final class RestConstants { public static final String DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES = "mandatorymoduletypes"; - public static final String DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE = "/api/" + API_VERSION + "/downloadserver/"; - public static final String DOWNLOAD_ID_V1_REQUEST_MAPPING = "downloadId/{downloadId}"; - // constant class, private constructor. - private RestConstants() { + private MgmtRestConstants() { } } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/RolloutRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java similarity index 69% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/RolloutRestApi.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java index 9f76b6bce..ea4578cad 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/RolloutRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java @@ -2,18 +2,17 @@ * 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 + * are made available under the terms of the Eclipse License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.api; +package org.eclipse.hawkbit.mgmt.rest.api; -import org.eclipse.hawkbit.rest.resource.RestConstants; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutResponseBody; -import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutRestRequestBody; -import org.eclipse.hawkbit.rest.resource.model.rolloutgroup.RolloutGroupResponseBody; -import org.eclipse.hawkbit.rest.resource.model.target.TargetRest; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutResponseBody; +import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutRestRequestBody; +import org.eclipse.hawkbit.mgmt.json.model.rolloutgroup.MgmtRolloutGroupResponseBody; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; @@ -26,8 +25,8 @@ import org.springframework.web.bind.annotation.RequestParam; * REST Resource handling rollout CRUD operations. * */ -@RequestMapping(RestConstants.ROLLOUT_V1_REQUEST_MAPPING) -public interface RolloutRestApi { +@RequestMapping(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING) +public interface MgmtRolloutRestApi { /** * Handles the GET request of retrieving all rollouts. @@ -49,11 +48,11 @@ public interface RolloutRestApi { * JsonResponseExceptionHandler is handling the response. */ @RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - public ResponseEntity> getRollouts( - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getRollouts( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); /** * Handles the GET request of retrieving a single rollout. @@ -66,7 +65,7 @@ public interface RolloutRestApi { */ @RequestMapping(value = "/{rolloutId}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - public ResponseEntity getRollout(@PathVariable("rolloutId") final Long rolloutId); + ResponseEntity getRollout(@PathVariable("rolloutId") final Long rolloutId); /** * Handles the POST request for creating rollout. @@ -81,7 +80,7 @@ public interface RolloutRestApi { */ @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity create(@RequestBody final RolloutRestRequestBody rolloutRequestBody); + ResponseEntity create(@RequestBody final MgmtRolloutRestRequestBody rolloutRequestBody); /** * Handles the POST request for starting a rollout. @@ -96,8 +95,8 @@ public interface RolloutRestApi { */ @RequestMapping(method = RequestMethod.POST, value = "/{rolloutId}/start", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity start(@PathVariable("rolloutId") final Long rolloutId, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_ASYNC, defaultValue = "false") final boolean startAsync); + ResponseEntity start(@PathVariable("rolloutId") final Long rolloutId, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_ASYNC, defaultValue = "false") final boolean startAsync); /** * Handles the POST request for pausing a rollout. @@ -112,7 +111,7 @@ public interface RolloutRestApi { */ @RequestMapping(method = RequestMethod.POST, value = "/{rolloutId}/pause", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity pause(@PathVariable("rolloutId") final Long rolloutId); + ResponseEntity pause(@PathVariable("rolloutId") final Long rolloutId); /** * Handles the POST request for resuming a rollout. @@ -127,7 +126,7 @@ public interface RolloutRestApi { */ @RequestMapping(method = RequestMethod.POST, value = "/{rolloutId}/resume", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity resume(@PathVariable("rolloutId") final Long rolloutId); + ResponseEntity resume(@PathVariable("rolloutId") final Long rolloutId); /** * Handles the GET request of retrieving all rollout groups referred to a @@ -153,12 +152,12 @@ public interface RolloutRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{rolloutId}/deploygroups", produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - public ResponseEntity> getRolloutGroups( + ResponseEntity> getRolloutGroups( @PathVariable("rolloutId") final Long rolloutId, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); /** * Handles the GET request for retrieving a single rollout group. @@ -167,12 +166,12 @@ public interface RolloutRestApi { * the rolloutId to retrieve the group from * @param groupId * the groupId to retrieve the rollout group - * @return the OK response containing the RolloutGroupResponseBody + * @return the OK response containing the MgmtRolloutGroupResponseBody * @throws EntityNotFoundException */ @RequestMapping(method = RequestMethod.GET, value = "/{rolloutId}/deploygroups/{groupId}", produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - public ResponseEntity getRolloutGroup(@PathVariable("rolloutId") final Long rolloutId, + ResponseEntity getRolloutGroup(@PathVariable("rolloutId") final Long rolloutId, @PathVariable("groupId") final Long groupId); /** @@ -200,10 +199,10 @@ public interface RolloutRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{rolloutId}/deploygroups/{groupId}/targets", produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - public ResponseEntity> getRolloutGroupTargets(@PathVariable("rolloutId") final Long rolloutId, + ResponseEntity> getRolloutGroupTargets(@PathVariable("rolloutId") final Long rolloutId, @PathVariable("groupId") final Long groupId, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/SoftwareModuleRestAPI.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestAPI.java similarity index 74% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/SoftwareModuleRestAPI.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestAPI.java index 0eb874489..e452eb9a3 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/SoftwareModuleRestAPI.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestAPI.java @@ -2,21 +2,20 @@ * 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 + * are made available under the terms of the Eclipse License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.api; +package org.eclipse.hawkbit.mgmt.rest.api; import java.util.List; -import org.eclipse.hawkbit.rest.resource.RestConstants; -import org.eclipse.hawkbit.rest.resource.model.MetadataRest; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.artifact.ArtifactRest; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRequestBodyPut; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest; +import org.eclipse.hawkbit.mgmt.json.model.MetadataRest; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPut; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; @@ -32,8 +31,8 @@ import org.springframework.web.multipart.MultipartFile; * operations. * */ -@RequestMapping(RestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) -public interface SoftwareModuleRestAPI { +@RequestMapping(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) +public interface MgmtSoftwareModuleRestAPI { /** * Handles POST request for artifact upload. @@ -56,7 +55,7 @@ public interface SoftwareModuleRestAPI { */ @RequestMapping(method = RequestMethod.POST, value = "/{softwareModuleId}/artifacts", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity uploadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, + ResponseEntity uploadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, @RequestParam("file") final MultipartFile file, @RequestParam(value = "filename", required = false) final String optionalFileName, @RequestParam(value = "md5sum", required = false) final String md5Sum, @@ -76,8 +75,7 @@ public interface SoftwareModuleRestAPI { @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/artifacts", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) @ResponseBody - public ResponseEntity> getArtifacts( - @PathVariable("softwareModuleId") final Long softwareModuleId); + ResponseEntity> getArtifacts(@PathVariable("softwareModuleId") final Long softwareModuleId); /** * Handles the GET request of retrieving a single Artifact meta data @@ -93,7 +91,7 @@ public interface SoftwareModuleRestAPI { @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/artifacts/{artifactId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) @ResponseBody - public ResponseEntity getArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, + ResponseEntity getArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("artifactId") final Long artifactId); /** @@ -108,7 +106,7 @@ public interface SoftwareModuleRestAPI { */ @RequestMapping(method = RequestMethod.DELETE, value = "/{softwareModuleId}/artifacts/{artifactId}") @ResponseBody - public ResponseEntity deleteArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, + ResponseEntity deleteArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("artifactId") final Long artifactId); /** @@ -132,11 +130,11 @@ public interface SoftwareModuleRestAPI { * JsonResponseExceptionHandler is handling the response. */ @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> getSoftwareModules( - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getSoftwareModules( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); /** * Handles the GET request of retrieving a single software module. @@ -150,8 +148,7 @@ public interface SoftwareModuleRestAPI { */ @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getSoftwareModule( - @PathVariable("softwareModuleId") final Long softwareModuleId); + ResponseEntity getSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId); /** * Handles the POST request of creating new softwaremodules. The request @@ -166,8 +163,8 @@ public interface SoftwareModuleRestAPI { */ @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> createSoftwareModules( - @RequestBody final List softwareModules); + ResponseEntity> createSoftwareModules( + @RequestBody final List softwareModules); /** * Handles the PUT request of updating a software module. @@ -180,9 +177,9 @@ public interface SoftwareModuleRestAPI { */ @RequestMapping(method = RequestMethod.PUT, value = "/{softwareModuleId}", consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity updateSoftwareModule( + ResponseEntity updateSoftwareModule( @PathVariable("softwareModuleId") final Long softwareModuleId, - @RequestBody final SoftwareModuleRequestBodyPut restSoftwareModule); + @RequestBody final MgmtSoftwareModuleRequestBodyPut restSoftwareModule); /** * Handles the DELETE request for a single software module. @@ -193,7 +190,7 @@ public interface SoftwareModuleRestAPI { * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{softwareModuleId}") - public ResponseEntity deleteSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId); + ResponseEntity deleteSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId); /** * Gets a paged list of meta data for a software module. @@ -217,12 +214,11 @@ public interface SoftwareModuleRestAPI { */ @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/metadata", produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - public ResponseEntity> getMetadata( - @PathVariable("softwareModuleId") final Long softwareModuleId, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); /** * Gets a single meta data value for a specific key of a software module. @@ -236,7 +232,7 @@ public interface SoftwareModuleRestAPI { */ @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/metadata/{metadataKey}", produces = { MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getMetadataValue(@PathVariable("softwareModuleId") final Long softwareModuleId, + ResponseEntity getMetadataValue(@PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("metadataKey") final String metadataKey); /** @@ -251,7 +247,7 @@ public interface SoftwareModuleRestAPI { */ @RequestMapping(method = RequestMethod.PUT, value = "/{softwareModuleId}/metadata/{metadataKey}", produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - public ResponseEntity updateMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId, + ResponseEntity updateMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("metadataKey") final String metadataKey, @RequestBody final MetadataRest metadata); /** @@ -264,7 +260,7 @@ public interface SoftwareModuleRestAPI { * @return status OK if the delete request is successful */ @RequestMapping(method = RequestMethod.DELETE, value = "/{softwareModuleId}/metadata/{metadataKey}") - public ResponseEntity deleteMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId, + ResponseEntity deleteMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("metadataKey") final String metadataKey); /** @@ -280,8 +276,7 @@ public interface SoftwareModuleRestAPI { @RequestMapping(method = RequestMethod.POST, value = "/{softwareModuleId}/metadata", consumes = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - public ResponseEntity> createMetadata( - @PathVariable("softwareModuleId") final Long softwareModuleId, + ResponseEntity> createMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId, @RequestBody final List metadataRest); } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/SoftwareModuleTypeRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java similarity index 70% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/SoftwareModuleTypeRestApi.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java index a98e35a32..6c7252d62 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/SoftwareModuleTypeRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java @@ -2,19 +2,18 @@ * 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 + * are made available under the terms of the Eclipse License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.api; +package org.eclipse.hawkbit.mgmt.rest.api; import java.util.List; -import org.eclipse.hawkbit.rest.resource.RestConstants; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRequestBodyPut; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRest; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPut; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; @@ -28,8 +27,8 @@ import org.springframework.web.bind.annotation.RequestParam; * operations. * */ -@RequestMapping(RestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) -public interface SoftwareModuleTypeRestApi { +@RequestMapping(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) +public interface MgmtSoftwareModuleTypeRestApi { /** * Handles the GET request of retrieving all SoftwareModuleTypes . * @@ -51,11 +50,11 @@ public interface SoftwareModuleTypeRestApi { * JsonResponseExceptionHandler is handling the response. */ @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> getTypes( - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getTypes( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); /** * Handles the GET request of retrieving a single software module type . @@ -69,7 +68,7 @@ public interface SoftwareModuleTypeRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getSoftwareModuleType( + ResponseEntity getSoftwareModuleType( @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId); /** @@ -81,7 +80,7 @@ public interface SoftwareModuleTypeRestApi { * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{softwareModuleTypeId}") - public ResponseEntity deleteSoftwareModuleType( + ResponseEntity deleteSoftwareModuleType( @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId); /** @@ -95,9 +94,9 @@ public interface SoftwareModuleTypeRestApi { */ @RequestMapping(method = RequestMethod.PUT, value = "/{softwareModuleTypeId}", consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity updateSoftwareModuleType( + ResponseEntity updateSoftwareModuleType( @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId, - @RequestBody final SoftwareModuleTypeRequestBodyPut restSoftwareModuleType); + @RequestBody final MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType); /** * Handles the POST request of creating new SoftwareModuleTypes. The request @@ -112,7 +111,7 @@ public interface SoftwareModuleTypeRestApi { */ @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> createSoftwareModuleTypes( - @RequestBody final List softwareModuleTypes); + ResponseEntity> createSoftwareModuleTypes( + @RequestBody final List softwareModuleTypes); } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/TargetRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java similarity index 72% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/TargetRestApi.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java index 48e242f81..572dcf500 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/TargetRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java @@ -2,23 +2,22 @@ * 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 + * are made available under the terms of the Eclipse License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.api; +package org.eclipse.hawkbit.mgmt.rest.api; import java.util.List; -import org.eclipse.hawkbit.rest.resource.RestConstants; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.action.ActionRest; -import org.eclipse.hawkbit.rest.resource.model.action.ActionStatusRest; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest; -import org.eclipse.hawkbit.rest.resource.model.target.DistributionSetAssigmentRest; -import org.eclipse.hawkbit.rest.resource.model.target.TargetAttributes; -import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody; -import org.eclipse.hawkbit.rest.resource.model.target.TargetRest; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction; +import org.eclipse.hawkbit.mgmt.json.model.action.MgmtActionStatus; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtDistributionSetAssigment; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAttributes; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; @@ -30,8 +29,8 @@ import org.springframework.web.bind.annotation.RequestParam; /** * Api for handling target operations. */ -@RequestMapping(RestConstants.TARGET_V1_REQUEST_MAPPING) -public interface TargetRestApi { +@RequestMapping(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING) +public interface MgmtTargetRestApi { /** * Handles the GET request of retrieving a single target. @@ -45,7 +44,7 @@ public interface TargetRestApi { @RequestMapping(method = RequestMethod.GET, value = "/{targetId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getTarget(@PathVariable("targetId") final String targetId); + ResponseEntity getTarget(@PathVariable("targetId") final String targetId); /** * Handles the GET request of retrieving all targets. @@ -68,11 +67,11 @@ public interface TargetRestApi { */ @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> getTargets( - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getTargets( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); /** * Handles the POST request of creating new targets. The request body must @@ -87,7 +86,7 @@ public interface TargetRestApi { */ @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> createTargets(@RequestBody final List targets); + ResponseEntity> createTargets(@RequestBody final List targets); /** * Handles the PUT request of updating a target. The ID is within the URL @@ -105,8 +104,8 @@ public interface TargetRestApi { */ @RequestMapping(method = RequestMethod.PUT, value = "/{targetId}", consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity updateTarget(@PathVariable("targetId") final String targetId, - @RequestBody final TargetRequestBody targetRest); + ResponseEntity updateTarget(@PathVariable("targetId") final String targetId, + @RequestBody final MgmtTargetRequestBody targetRest); /** * Handles the DELETE request of deleting a target. @@ -119,7 +118,7 @@ public interface TargetRestApi { */ @RequestMapping(method = RequestMethod.DELETE, value = "/{targetId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity deleteTarget(@PathVariable("targetId") final String targetId); + ResponseEntity deleteTarget(@PathVariable("targetId") final String targetId); /** * Handles the GET request of retrieving the attributes of a specific @@ -133,7 +132,7 @@ public interface TargetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}/attributes", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getAttributes(@PathVariable("targetId") final String targetId); + ResponseEntity getAttributes(@PathVariable("targetId") final String targetId); /** * Handles the GET request of retrieving the Actions of a specific target. @@ -158,11 +157,11 @@ public interface TargetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> getActionHistory(@PathVariable("targetId") final String targetId, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getActionHistory(@PathVariable("targetId") final String targetId, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); /** * Handles the GET request of retrieving a specific Actions of a specific @@ -176,7 +175,7 @@ public interface TargetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions/{actionId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getAction(@PathVariable("targetId") final String targetId, + ResponseEntity getAction(@PathVariable("targetId") final String targetId, @PathVariable("actionId") final Long actionId); /** @@ -196,7 +195,7 @@ public interface TargetRestApi { * if the target or the action is not found */ @RequestMapping(method = RequestMethod.DELETE, value = "/{targetId}/actions/{actionId}") - public ResponseEntity cancelAction(@PathVariable("targetId") final String targetId, + ResponseEntity cancelAction(@PathVariable("targetId") final String targetId, @PathVariable("actionId") final Long actionId, @RequestParam(value = "force", required = false, defaultValue = "false") final boolean force); @@ -223,11 +222,11 @@ public interface TargetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions/{actionId}/status", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> getActionStatusList( - @PathVariable("targetId") final String targetId, @PathVariable("actionId") final Long actionId, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam); + ResponseEntity> getActionStatusList(@PathVariable("targetId") final String targetId, + @PathVariable("actionId") final Long actionId, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam); /** * Handles the GET request of retrieving the assigned distribution set of an @@ -242,8 +241,7 @@ public interface TargetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}/assignedDS", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getAssignedDistributionSet( - @PathVariable("targetId") final String targetId); + ResponseEntity getAssignedDistributionSet(@PathVariable("targetId") final String targetId); /** * Changes the assigned distribution set of a target. @@ -260,8 +258,8 @@ public interface TargetRestApi { */ @RequestMapping(method = RequestMethod.POST, value = "/{targetId}/assignedDS", consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity postAssignedDistributionSet(@PathVariable("targetId") final String targetId, - @RequestBody final DistributionSetAssigmentRest dsId); + ResponseEntity postAssignedDistributionSet(@PathVariable("targetId") final String targetId, + @RequestBody final MgmtDistributionSetAssigment dsId); /** * Handles the GET request of retrieving the installed distribution set of @@ -276,7 +274,6 @@ public interface TargetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}/installedDS", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getInstalledDistributionSet( - @PathVariable("targetId") final String targetId); + ResponseEntity getInstalledDistributionSet(@PathVariable("targetId") final String targetId); } \ No newline at end of file diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/TargetTagRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java similarity index 67% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/TargetTagRestApi.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java index 940b578d4..90646a562 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/api/TargetTagRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java @@ -2,21 +2,20 @@ * 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 + * are made available under the terms of the Eclipse License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.api; +package org.eclipse.hawkbit.mgmt.rest.api; import java.util.List; -import org.eclipse.hawkbit.rest.resource.RestConstants; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.tag.AssignedTargetRequestBody; -import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut; -import org.eclipse.hawkbit.rest.resource.model.tag.TagRest; -import org.eclipse.hawkbit.rest.resource.model.tag.TargetTagAssigmentResultRest; -import org.eclipse.hawkbit.rest.resource.model.target.TargetRest; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtAssignedTargetRequestBody; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTargetTagAssigmentResult; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; @@ -29,8 +28,8 @@ import org.springframework.web.bind.annotation.RequestParam; * REST Resource handling for TargetTag CRUD operations. * */ -@RequestMapping(RestConstants.TARGET_TAG_V1_REQUEST_MAPPING) -public interface TargetTagRestApi { +@RequestMapping(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING) +public interface MgmtTargetTagRestApi { /** * Handles the GET request of retrieving all target tags. @@ -52,11 +51,11 @@ public interface TargetTagRestApi { * JsonResponseExceptionHandler is handling the response. */ @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> getTargetTags( - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getTargetTags( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); /** * Handles the GET request of retrieving a single target tag. @@ -70,7 +69,7 @@ public interface TargetTagRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetTagId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getTargetTag(@PathVariable("targetTagId") final Long targetTagId); + ResponseEntity getTargetTag(@PathVariable("targetTagId") final Long targetTagId); /** * Handles the POST request of creating new target tag. The request body @@ -84,7 +83,7 @@ public interface TargetTagRestApi { */ @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> createTargetTags(@RequestBody final List tags); + ResponseEntity> createTargetTags(@RequestBody final List tags); /** * @@ -100,8 +99,8 @@ public interface TargetTagRestApi { */ @RequestMapping(method = RequestMethod.PUT, value = "/{targetTagId}", consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity updateTagretTag(@PathVariable("targetTagId") final Long targetTagId, - @RequestBody final TagRequestBodyPut restTargetTagRest); + ResponseEntity updateTagretTag(@PathVariable("targetTagId") final Long targetTagId, + @RequestBody final MgmtTagRequestBodyPut restTargetTagRest); /** * Handles the DELETE request for a single target tag. @@ -114,7 +113,7 @@ public interface TargetTagRestApi { * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{targetTagId}") - public ResponseEntity deleteTargetTag(@PathVariable("targetTagId") final Long targetTagId); + ResponseEntity deleteTargetTag(@PathVariable("targetTagId") final Long targetTagId); /** * Handles the GET request of retrieving all assigned targets by the given @@ -127,8 +126,8 @@ public interface TargetTagRestApi { * @throws EntityNotFoundException * in case the given {@code targetTagId} doesn't exists. */ - @RequestMapping(method = RequestMethod.GET, value = RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING) - public ResponseEntity> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId); + @RequestMapping(method = RequestMethod.GET, value = MgmtRestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING) + ResponseEntity> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId); /** * Handles the POST request to toggle the assignment of targets by the given @@ -143,11 +142,11 @@ public interface TargetTagRestApi { * @throws EntityNotFoundException * in case the given {@code targetTagId} doesn't exists. */ - @RequestMapping(method = RequestMethod.POST, value = RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING + @RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING + "/toggleTagAssignment") - public ResponseEntity toggleTagAssignment( + ResponseEntity toggleTagAssignment( @PathVariable("targetTagId") final Long targetTagId, - @RequestBody final List assignedTargetRequestBodies); + @RequestBody final List assignedTargetRequestBodies); /** * Handles the POST request to assign targets to the given tag id. @@ -161,9 +160,9 @@ public interface TargetTagRestApi { * @throws EntityNotFoundException * in case the given {@code targetTagId} doesn't exists. */ - @RequestMapping(method = RequestMethod.POST, value = RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING) - public ResponseEntity> assignTargets(@PathVariable("targetTagId") final Long targetTagId, - @RequestBody final List assignedTargetRequestBodies); + @RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING) + ResponseEntity> assignTargets(@PathVariable("targetTagId") final Long targetTagId, + @RequestBody final List assignedTargetRequestBodies); /** * Handles the DELETE request to unassign all targets from the given tag id. @@ -174,8 +173,8 @@ public interface TargetTagRestApi { * @throws EntityNotFoundException * in case the given {@code targetTagId} doesn't exists. */ - @RequestMapping(method = RequestMethod.DELETE, value = RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING) - public ResponseEntity unassignTargets(@PathVariable("targetTagId") final Long targetTagId); + @RequestMapping(method = RequestMethod.DELETE, value = MgmtRestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING) + ResponseEntity unassignTargets(@PathVariable("targetTagId") final Long targetTagId); /** * Handles the DELETE request to unassign one target from the given tag id. @@ -188,8 +187,8 @@ public interface TargetTagRestApi { * @throws EntityNotFoundException * in case the given {@code targetTagId} doesn't exists. */ - @RequestMapping(method = RequestMethod.DELETE, value = RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING + @RequestMapping(method = RequestMethod.DELETE, value = MgmtRestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING + "/{controllerId}") - public ResponseEntity unassignTarget(@PathVariable("targetTagId") final Long targetTagId, + ResponseEntity unassignTarget(@PathVariable("targetTagId") final Long targetTagId, @PathVariable("controllerId") final String controllerId); } diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/PagedListTest.java b/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/PagedListTest.java similarity index 97% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/PagedListTest.java rename to hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/PagedListTest.java index 68ce570a1..c17acb3b1 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/PagedListTest.java +++ b/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/PagedListTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model; +package org.eclipse.hawkbit.mgmt.json.model; import static org.fest.assertions.Assertions.assertThat; import static org.junit.Assert.fail; diff --git a/hawkbit-rest-resource/pom.xml b/hawkbit-mgmt-resource/pom.xml similarity index 82% rename from hawkbit-rest-resource/pom.xml rename to hawkbit-mgmt-resource/pom.xml index 45d104963..311cbae76 100644 --- a/hawkbit-rest-resource/pom.xml +++ b/hawkbit-mgmt-resource/pom.xml @@ -9,7 +9,7 @@ hawkbit-parent 0.2.0-SNAPSHOT - hawkbit-rest-resource + hawkbit-mgmt-resource hawkBit :: REST Resources @@ -21,43 +21,14 @@ org.eclipse.hawkbit - hawkbit-core + hawkbit-mgmt-api ${project.version} org.eclipse.hawkbit - hawkbit-rest-api + hawkbit-rest-core ${project.version} - - org.eclipse.hawkbit - hawkbit-ddi-api - ${project.version} - - - javax.servlet - javax.servlet-api - provided - - - org.apache.tomcat.embed - tomcat-embed-core - provided - - - io.springfox - springfox-core - 2.0.3 - - - commons-io - commons-io - 2.4 - - - org.springframework.security - spring-security-web - diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/EnableRestResources.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/annotation/EnableMgmtApi.java similarity index 91% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/EnableRestResources.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/annotation/EnableMgmtApi.java index 8f9952054..ee34a3988 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/EnableRestResources.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/annotation/EnableMgmtApi.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -29,6 +29,6 @@ import org.springframework.stereotype.Controller; @Retention(RetentionPolicy.RUNTIME) @Configuration @ComponentScan -public @interface EnableRestResources { +public @interface EnableMgmtApi { } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetMapper.java similarity index 75% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetMapper.java index 8051146a1..111ba00ae 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetMapper.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; @@ -14,6 +14,13 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; import java.util.ArrayList; import java.util.List; +import org.eclipse.hawkbit.mgmt.json.model.MetadataRest; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentResponseBody; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.SoftwareManagement; @@ -22,12 +29,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModule; -import org.eclipse.hawkbit.rest.resource.api.DistributionSetRestApi; -import org.eclipse.hawkbit.rest.resource.api.DistributionSetTypeRestApi; -import org.eclipse.hawkbit.rest.resource.model.MetadataRest; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest; -import org.eclipse.hawkbit.rest.resource.model.distributionset.TargetAssignmentResponseBody; /** * A mapper which maps repository model to RESTful model representation and @@ -37,8 +38,8 @@ import org.eclipse.hawkbit.rest.resource.model.distributionset.TargetAssignmentR * * */ -public final class DistributionSetMapper { - private DistributionSetMapper() { +public final class MgmtDistributionSetMapper { + private MgmtDistributionSetMapper() { // Utility class } @@ -65,7 +66,7 @@ public final class DistributionSetMapper { } /** - * {@link DistributionSetRequestBodyPost}s to {@link DistributionSet}s. + * {@link MgmtDistributionSetRequestBodyPost}s to {@link DistributionSet}s. * * @param sets * to convert @@ -73,11 +74,11 @@ public final class DistributionSetMapper { * to use for conversion * @return converted list of {@link DistributionSet}s */ - static List dsFromRequest(final Iterable sets, + static List dsFromRequest(final Iterable sets, final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement) { final List mappedList = new ArrayList<>(); - for (final DistributionSetRequestBodyPost dsRest : sets) { + for (final MgmtDistributionSetRequestBodyPost dsRest : sets) { mappedList.add(fromRequest(dsRest, softwareManagement, distributionSetManagement)); } return mappedList; @@ -85,7 +86,7 @@ public final class DistributionSetMapper { } /** - * {@link DistributionSetRequestBodyPost} to {@link DistributionSet}. + * {@link MgmtDistributionSetRequestBodyPost} to {@link DistributionSet}. * * @param dsRest * to convert @@ -93,7 +94,7 @@ public final class DistributionSetMapper { * to use for conversion * @return converted {@link DistributionSet} */ - static DistributionSet fromRequest(final DistributionSetRequestBodyPost dsRest, + static DistributionSet fromRequest(final MgmtDistributionSetRequestBodyPost dsRest, final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement) { final DistributionSet result = new DistributionSet(); @@ -152,12 +153,12 @@ public final class DistributionSetMapper { * the ds set * @return the response */ - public static DistributionSetRest toResponse(final DistributionSet distributionSet) { + public static MgmtDistributionSet toResponse(final DistributionSet distributionSet) { if (distributionSet == null) { return null; } - final DistributionSetRest response = new DistributionSetRest(); - RestModelMapper.mapNamedToNamed(response, distributionSet); + final MgmtDistributionSet response = new MgmtDistributionSet(); + MgmtRestModelMapper.mapNamedToNamed(response, distributionSet); response.setDsId(distributionSet.getId()); response.setVersion(distributionSet.getVersion()); @@ -165,35 +166,35 @@ public final class DistributionSetMapper { response.setType(distributionSet.getType().getKey()); distributionSet.getModules() - .forEach(module -> response.getModules().add(SoftwareModuleMapper.toResponse(module))); + .forEach(module -> response.getModules().add(MgmtSoftwareModuleMapper.toResponse(module))); response.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep()); response.add( - linkTo(methodOn(DistributionSetRestApi.class).getDistributionSet(response.getDsId())).withRel("self")); + linkTo(methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(response.getDsId())).withRel("self")); response.add(linkTo( - methodOn(DistributionSetTypeRestApi.class).getDistributionSetType(distributionSet.getType().getId())) + methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(distributionSet.getType().getId())) .withRel("type")); - response.add(linkTo(methodOn(DistributionSetRestApi.class).getMetadata(response.getDsId(), - Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET), - Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)) + response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getMetadata(response.getDsId(), + Integer.parseInt(MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET), + Integer.parseInt(MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)) .withRel("metadata")); return response; } - static TargetAssignmentResponseBody toResponse(final DistributionSetAssignmentResult dsAssignmentResult) { - final TargetAssignmentResponseBody result = new TargetAssignmentResponseBody(); + static MgmtTargetAssignmentResponseBody toResponse(final DistributionSetAssignmentResult dsAssignmentResult) { + final MgmtTargetAssignmentResponseBody result = new MgmtTargetAssignmentResponseBody(); result.setAssigned(dsAssignmentResult.getAssigned()); result.setAlreadyAssigned(dsAssignmentResult.getAlreadyAssigned()); result.setTotal(dsAssignmentResult.getTotal()); return result; } - static List toResponseDistributionSets(final Iterable sets) { - final List response = new ArrayList<>(); + static List toResponseDistributionSets(final Iterable sets) { + final List response = new ArrayList<>(); if (sets != null) { for (final DistributionSet set : sets) { @@ -219,11 +220,11 @@ public final class DistributionSetMapper { return mappedList; } - static List toResponseFromDsList(final List sets) { - final List mappedList = new ArrayList<>(); + static List toResponseFromDsList(final List sets) { + final List mappedList = new ArrayList<>(); if (sets != null) { for (final DistributionSet set : sets) { - final DistributionSetRest response = toResponse(set); + final MgmtDistributionSet response = toResponse(set); mappedList.add(response); } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java similarity index 79% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java index 27231308b..2db11f489 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java @@ -6,18 +6,30 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import org.eclipse.hawkbit.mgmt.json.model.MetadataRest; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPut; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentRequestBody; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentResponseBody; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssigment; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi; import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult; import org.eclipse.hawkbit.repository.DistributionSetFields; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetMetadataFields; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.TargetFields; @@ -30,18 +42,6 @@ import org.eclipse.hawkbit.repository.model.DsMetadataCompositeKey; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; -import org.eclipse.hawkbit.rest.resource.api.DistributionSetRestApi; -import org.eclipse.hawkbit.rest.resource.helper.RestResourceConversionHelper; -import org.eclipse.hawkbit.rest.resource.model.MetadataRest; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPut; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest; -import org.eclipse.hawkbit.rest.resource.model.distributionset.TargetAssignmentRequestBody; -import org.eclipse.hawkbit.rest.resource.model.distributionset.TargetAssignmentResponseBody; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleAssigmentRest; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest; -import org.eclipse.hawkbit.rest.resource.model.target.TargetRest; import org.eclipse.hawkbit.tenancy.TenantAware; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,8 +57,8 @@ import org.springframework.web.bind.annotation.RestController; * REST Resource handling for {@link DistributionSet} CRUD operations. */ @RestController -public class DistributionSetResource implements DistributionSetRestApi { - private static final Logger LOG = LoggerFactory.getLogger(DistributionSetResource.class); +public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { + private static final Logger LOG = LoggerFactory.getLogger(MgmtDistributionSetResource.class); @Autowired private SoftwareManagement softwareManagement; @@ -79,7 +79,7 @@ public class DistributionSetResource implements DistributionSetRestApi { private DistributionSetManagement distributionSetManagement; @Override - public ResponseEntity> getDistributionSets(final int pagingOffsetParam, + public ResponseEntity> getDistributionSets(final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); @@ -95,20 +95,20 @@ public class DistributionSetResource implements DistributionSetRestApi { findDsPage = this.distributionSetManagement.findDistributionSetsAll(pageable, false, null); } - final List rest = DistributionSetMapper.toResponseFromDsList(findDsPage.getContent()); + final List rest = MgmtDistributionSetMapper.toResponseFromDsList(findDsPage.getContent()); return new ResponseEntity<>(new PagedList<>(rest, findDsPage.getTotalElements()), HttpStatus.OK); } @Override - public ResponseEntity getDistributionSet(final Long distributionSetId) { + public ResponseEntity getDistributionSet(final Long distributionSetId) { final DistributionSet foundDs = findDistributionSetWithExceptionIfNotFound(distributionSetId); - return new ResponseEntity<>(DistributionSetMapper.toResponse(foundDs), HttpStatus.OK); + return new ResponseEntity<>(MgmtDistributionSetMapper.toResponse(foundDs), HttpStatus.OK); } @Override - public ResponseEntity> createDistributionSets( - final List sets) { + public ResponseEntity> createDistributionSets( + final List sets) { LOG.debug("creating {} distribution sets", sets.size()); // set default Ds type if ds type is null @@ -116,10 +116,11 @@ public class DistributionSetResource implements DistributionSetRestApi { .getTenantMetadata(this.currentTenant.getCurrentTenant()).getDefaultDsType().getKey())); final Iterable createdDSets = this.distributionSetManagement.createDistributionSets( - DistributionSetMapper.dsFromRequest(sets, this.softwareManagement, this.distributionSetManagement)); + MgmtDistributionSetMapper.dsFromRequest(sets, this.softwareManagement, this.distributionSetManagement)); LOG.debug("{} distribution sets created, return status {}", sets.size(), HttpStatus.CREATED); - return new ResponseEntity<>(DistributionSetMapper.toResponseDistributionSets(createdDSets), HttpStatus.CREATED); + return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDistributionSets(createdDSets), + HttpStatus.CREATED); } @Override @@ -132,8 +133,8 @@ public class DistributionSetResource implements DistributionSetRestApi { } @Override - public ResponseEntity updateDistributionSet(final Long distributionSetId, - final DistributionSetRequestBodyPut toUpdate) { + public ResponseEntity updateDistributionSet(final Long distributionSetId, + final MgmtDistributionSetRequestBodyPut toUpdate) { final DistributionSet set = findDistributionSetWithExceptionIfNotFound(distributionSetId); if (toUpdate.getDescription() != null) { @@ -148,12 +149,12 @@ public class DistributionSetResource implements DistributionSetRestApi { set.setVersion(toUpdate.getVersion()); } return new ResponseEntity<>( - DistributionSetMapper.toResponse(this.distributionSetManagement.updateDistributionSet(set)), + MgmtDistributionSetMapper.toResponse(this.distributionSetManagement.updateDistributionSet(set)), HttpStatus.OK); } @Override - public ResponseEntity> getAssignedTargets(final Long distributionSetId, + public ResponseEntity> getAssignedTargets(final Long distributionSetId, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { // check if distribution set exists otherwise throw exception @@ -173,12 +174,12 @@ public class DistributionSetResource implements DistributionSetRestApi { targetsAssignedDS = this.targetManagement.findTargetByAssignedDistributionSet(distributionSetId, pageable); } - return new ResponseEntity<>(new PagedList<>(TargetMapper.toResponse(targetsAssignedDS.getContent()), + return new ResponseEntity<>(new PagedList<>(MgmtTargetMapper.toResponse(targetsAssignedDS.getContent()), targetsAssignedDS.getTotalElements()), HttpStatus.OK); } @Override - public ResponseEntity> getInstalledTargets(final Long distributionSetId, + public ResponseEntity> getInstalledTargets(final Long distributionSetId, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { // check if distribution set exists otherwise throw exception // immediately @@ -198,22 +199,24 @@ public class DistributionSetResource implements DistributionSetRestApi { pageable); } - return new ResponseEntity<>(new PagedList(TargetMapper.toResponse(targetsInstalledDS.getContent()), - targetsInstalledDS.getTotalElements()), HttpStatus.OK); + return new ResponseEntity<>( + new PagedList(MgmtTargetMapper.toResponse(targetsInstalledDS.getContent()), + targetsInstalledDS.getTotalElements()), + HttpStatus.OK); } @Override - public ResponseEntity createAssignedTarget(final Long distributionSetId, - final List targetIds) { + public ResponseEntity createAssignedTarget(final Long distributionSetId, + final List targetIds) { final DistributionSetAssignmentResult assignDistributionSet = this.deployManagament.assignDistributionSet( distributionSetId, targetIds.stream() .map(t -> new TargetWithActionType(t.getId(), - RestResourceConversionHelper.convertActionType(t.getType()), t.getForcetime())) + MgmtRestModelMapper.convertActionType(t.getType()), t.getForcetime())) .collect(Collectors.toList())); - return new ResponseEntity<>(DistributionSetMapper.toResponse(assignDistributionSet), HttpStatus.OK); + return new ResponseEntity<>(MgmtDistributionSetMapper.toResponse(assignDistributionSet), HttpStatus.OK); } @Override @@ -240,7 +243,7 @@ public class DistributionSetResource implements DistributionSetRestApi { } return new ResponseEntity<>( - new PagedList<>(DistributionSetMapper.toResponseDsMetadata(metaDataPage.getContent()), + new PagedList<>(MgmtDistributionSetMapper.toResponseDsMetadata(metaDataPage.getContent()), metaDataPage.getTotalElements()), HttpStatus.OK); @@ -253,7 +256,7 @@ public class DistributionSetResource implements DistributionSetRestApi { final DistributionSet ds = findDistributionSetWithExceptionIfNotFound(distributionSetId); final DistributionSetMetadata findOne = this.distributionSetManagement .findOne(new DsMetadataCompositeKey(ds, metadataKey)); - return ResponseEntity. ok(DistributionSetMapper.toResponseDsMetadata(findOne)); + return ResponseEntity. ok(MgmtDistributionSetMapper.toResponseDsMetadata(findOne)); } @Override @@ -264,7 +267,7 @@ public class DistributionSetResource implements DistributionSetRestApi { final DistributionSet ds = findDistributionSetWithExceptionIfNotFound(distributionSetId); final DistributionSetMetadata updated = this.distributionSetManagement .updateDistributionSetMetadata(new DistributionSetMetadata(metadataKey, ds, metadata.getValue())); - return ResponseEntity.ok(DistributionSetMapper.toResponseDsMetadata(updated)); + return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDsMetadata(updated)); } @Override @@ -284,20 +287,20 @@ public class DistributionSetResource implements DistributionSetRestApi { final DistributionSet ds = findDistributionSetWithExceptionIfNotFound(distributionSetId); final List created = this.distributionSetManagement - .createDistributionSetMetadata(DistributionSetMapper.fromRequestDsMetadata(ds, metadataRest)); - return new ResponseEntity<>(DistributionSetMapper.toResponseDsMetadata(created), HttpStatus.CREATED); + .createDistributionSetMetadata(MgmtDistributionSetMapper.fromRequestDsMetadata(ds, metadataRest)); + return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDsMetadata(created), HttpStatus.CREATED); } @Override public ResponseEntity assignSoftwareModules(final Long distributionSetId, - final List softwareModuleIDs) { + final List softwareModuleIDs) { // check if distribution set exists otherwise throw exception // immediately final DistributionSet ds = findDistributionSetWithExceptionIfNotFound(distributionSetId); final Set softwareModuleToBeAssigned = new HashSet<>(); - for (final SoftwareModuleAssigmentRest sm : softwareModuleIDs) { + for (final MgmtSoftwareModuleAssigment sm : softwareModuleIDs) { final SoftwareModule softwareModule = this.softwareManagement.findSoftwareModuleById(sm.getId()); if (softwareModule != null) { softwareModuleToBeAssigned.add(softwareModule); @@ -321,7 +324,7 @@ public class DistributionSetResource implements DistributionSetRestApi { } @Override - public ResponseEntity> getAssignedSoftwareModules(final Long distributionSetId, + public ResponseEntity> getAssignedSoftwareModules(final Long distributionSetId, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { // check if distribution set exists otherwise throw exception // immediately @@ -332,7 +335,7 @@ public class DistributionSetResource implements DistributionSetRestApi { final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); final Page softwaremodules = this.softwareManagement.findSoftwareModuleByAssignedTo(pageable, foundDs); - return new ResponseEntity<>(new PagedList<>(SoftwareModuleMapper.toResponse(softwaremodules.getContent()), + return new ResponseEntity<>(new PagedList<>(MgmtSoftwareModuleMapper.toResponse(softwaremodules.getContent()), softwaremodules.getTotalElements()), HttpStatus.OK); } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java similarity index 72% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java index eaa0fec28..5d0131fec 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java @@ -6,12 +6,20 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import java.util.List; import java.util.stream.Collectors; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtAssignedDistributionSetRequestBody; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtDistributionSetTagAssigmentResult; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi; import org.eclipse.hawkbit.repository.DistributionSetManagement; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.TagFields; import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; @@ -19,13 +27,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; -import org.eclipse.hawkbit.rest.resource.api.DistributionSetTagRestApi; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest; -import org.eclipse.hawkbit.rest.resource.model.tag.AssignedDistributionSetRequestBody; -import org.eclipse.hawkbit.rest.resource.model.tag.DistributionSetTagAssigmentResultRest; -import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut; -import org.eclipse.hawkbit.rest.resource.model.tag.TagRest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -42,8 +43,8 @@ import org.springframework.web.bind.annotation.RestController; * */ @RestController -public class DistributionSetTagResource implements DistributionSetTagRestApi { - private static final Logger LOG = LoggerFactory.getLogger(DistributionSetTagResource.class); +public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRestApi { + private static final Logger LOG = LoggerFactory.getLogger(MgmtDistributionSetTagResource.class); @Autowired private TagManagement tagManagement; @@ -52,7 +53,7 @@ public class DistributionSetTagResource implements DistributionSetTagRestApi { private DistributionSetManagement distributionSetManagement; @Override - public ResponseEntity> getDistributionSetTags(final int pagingOffsetParam, + public ResponseEntity> getDistributionSetTags(final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); @@ -74,39 +75,39 @@ public class DistributionSetTagResource implements DistributionSetTagRestApi { } - final List rest = TagMapper.toResponseDistributionSetTag(findTargetsAll.getContent()); + final List rest = MgmtTagMapper.toResponseDistributionSetTag(findTargetsAll.getContent()); return new ResponseEntity<>(new PagedList<>(rest, countTargetsAll), HttpStatus.OK); } @Override - public ResponseEntity getDistributionSetTag(final Long distributionsetTagId) { + public ResponseEntity getDistributionSetTag(final Long distributionsetTagId) { final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); - return new ResponseEntity<>(TagMapper.toResponse(tag), HttpStatus.OK); + return new ResponseEntity<>(MgmtTagMapper.toResponse(tag), HttpStatus.OK); } @Override - public ResponseEntity> createDistributionSetTags(final List tags) { + public ResponseEntity> createDistributionSetTags(final List tags) { LOG.debug("creating {} ds tags", tags.size()); final List createdTags = this.tagManagement - .createDistributionSetTags(TagMapper.mapDistributionSetTagFromRequest(tags)); + .createDistributionSetTags(MgmtTagMapper.mapDistributionSetTagFromRequest(tags)); - return new ResponseEntity<>(TagMapper.toResponseDistributionSetTag(createdTags), HttpStatus.CREATED); + return new ResponseEntity<>(MgmtTagMapper.toResponseDistributionSetTag(createdTags), HttpStatus.CREATED); } @Override - public ResponseEntity updateDistributionSetTag(final Long distributionsetTagId, - final TagRequestBodyPut restDSTagRest) { + public ResponseEntity updateDistributionSetTag(final Long distributionsetTagId, + final MgmtTagRequestBodyPut restDSTagRest) { LOG.debug("update {} ds tag", restDSTagRest); final DistributionSetTag distributionSetTag = findDistributionTagById(distributionsetTagId); - TagMapper.updateTag(restDSTagRest, distributionSetTag); + MgmtTagMapper.updateTag(restDSTagRest, distributionSetTag); final DistributionSetTag updateDistributionSetTag = this.tagManagement .updateDistributionSetTag(distributionSetTag); LOG.debug("ds tag updated"); - return new ResponseEntity<>(TagMapper.toResponse(updateDistributionSetTag), HttpStatus.OK); + return new ResponseEntity<>(MgmtTagMapper.toResponse(updateDistributionSetTag), HttpStatus.OK); } @Override @@ -120,15 +121,15 @@ public class DistributionSetTagResource implements DistributionSetTagRestApi { } @Override - public ResponseEntity> getAssignedDistributionSets(final Long distributionsetTagId) { + public ResponseEntity> getAssignedDistributionSets(final Long distributionsetTagId) { final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); return new ResponseEntity<>( - DistributionSetMapper.toResponseDistributionSets(tag.getAssignedToDistributionSet()), HttpStatus.OK); + MgmtDistributionSetMapper.toResponseDistributionSets(tag.getAssignedToDistributionSet()), HttpStatus.OK); } @Override - public ResponseEntity toggleTagAssignment(final Long distributionsetTagId, - final List assignedDSRequestBodies) { + public ResponseEntity toggleTagAssignment(final Long distributionsetTagId, + final List assignedDSRequestBodies) { LOG.debug("Toggle distribution set assignment {} for ds tag {}", assignedDSRequestBodies.size(), distributionsetTagId); @@ -137,11 +138,11 @@ public class DistributionSetTagResource implements DistributionSetTagRestApi { final DistributionSetTagAssignmentResult assigmentResult = this.distributionSetManagement .toggleTagAssignment(findDistributionSetIds(assignedDSRequestBodies), tag.getName()); - final DistributionSetTagAssigmentResultRest tagAssigmentResultRest = new DistributionSetTagAssigmentResultRest(); + final MgmtDistributionSetTagAssigmentResult tagAssigmentResultRest = new MgmtDistributionSetTagAssigmentResult(); tagAssigmentResultRest.setAssignedDistributionSets( - DistributionSetMapper.toResponseDistributionSets(assigmentResult.getAssignedEntity())); + MgmtDistributionSetMapper.toResponseDistributionSets(assigmentResult.getAssignedEntity())); tagAssigmentResultRest.setUnassignedDistributionSets( - DistributionSetMapper.toResponseDistributionSets(assigmentResult.getUnassignedEntity())); + MgmtDistributionSetMapper.toResponseDistributionSets(assigmentResult.getUnassignedEntity())); LOG.debug("Toggled assignedDS {} and unassignedDS{}", assigmentResult.getAssigned(), assigmentResult.getUnassigned()); @@ -150,15 +151,15 @@ public class DistributionSetTagResource implements DistributionSetTagRestApi { } @Override - public ResponseEntity> assignDistributionSets(final Long distributionsetTagId, - final List assignedDSRequestBodies) { + public ResponseEntity> assignDistributionSets(final Long distributionsetTagId, + final List assignedDSRequestBodies) { LOG.debug("Assign DistributionSet {} for ds tag {}", assignedDSRequestBodies.size(), distributionsetTagId); final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); final List assignedDs = this.distributionSetManagement .assignTag(findDistributionSetIds(assignedDSRequestBodies), tag); LOG.debug("Assignd DistributionSet {}", assignedDs.size()); - return new ResponseEntity<>(DistributionSetMapper.toResponseDistributionSets(assignedDs), HttpStatus.OK); + return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDistributionSets(assignedDs), HttpStatus.OK); } @Override @@ -193,7 +194,7 @@ public class DistributionSetTagResource implements DistributionSetTagRestApi { } private List findDistributionSetIds( - final List assignedDistributionSetRequestBodies) { + final List assignedDistributionSetRequestBodies) { return assignedDistributionSetRequestBodies.stream().map(request -> request.getDistributionSetId()) .collect(Collectors.toList()); } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java similarity index 60% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java index 409caf01d..244f07095 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; @@ -14,38 +14,39 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; import java.util.ArrayList; import java.util.List; +import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRest; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; -import org.eclipse.hawkbit.rest.resource.api.DistributionSetTypeRestApi; -import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRest; /** * A mapper which maps repository model to RESTful model representation and * back. * */ -final class DistributionSetTypeMapper { +final class MgmtDistributionSetTypeMapper { // private constructor, utility class - private DistributionSetTypeMapper() { + private MgmtDistributionSetTypeMapper() { } static List smFromRequest(final SoftwareManagement softwareManagement, - final Iterable smTypesRest) { + final Iterable smTypesRest) { final List mappedList = new ArrayList<>(); - for (final DistributionSetTypeRequestBodyPost smRest : smTypesRest) { + for (final MgmtDistributionSetTypeRequestBodyPost smRest : smTypesRest) { mappedList.add(fromRequest(softwareManagement, smRest)); } return mappedList; } static DistributionSetType fromRequest(final SoftwareManagement softwareManagement, - final DistributionSetTypeRequestBodyPost smsRest) { + final MgmtDistributionSetTypeRequestBodyPost smsRest) { final DistributionSetType result = new DistributionSetType(smsRest.getKey(), smsRest.getName(), smsRest.getDescription()); @@ -75,37 +76,37 @@ final class DistributionSetTypeMapper { return result; } - static List toTypesResponse(final List types) { - final List response = new ArrayList<>(); + static List toTypesResponse(final List types) { + final List response = new ArrayList<>(); for (final DistributionSetType dsType : types) { response.add(toResponse(dsType)); } return response; } - static List toListResponse(final List types) { - final List response = new ArrayList<>(); + static List toListResponse(final List types) { + final List response = new ArrayList<>(); for (final DistributionSetType dsType : types) { response.add(toResponse(dsType)); } return response; } - static DistributionSetTypeRest toResponse(final DistributionSetType type) { - final DistributionSetTypeRest result = new DistributionSetTypeRest(); + static MgmtDistributionSetTypeRest toResponse(final DistributionSetType type) { + final MgmtDistributionSetTypeRest result = new MgmtDistributionSetTypeRest(); - RestModelMapper.mapNamedToNamed(result, type); + MgmtRestModelMapper.mapNamedToNamed(result, type); result.setKey(type.getKey()); result.setModuleId(type.getId()); - result.add(linkTo(methodOn(DistributionSetTypeRestApi.class).getDistributionSetType(result.getModuleId())) + result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(result.getModuleId())) .withRel("self")); - result.add(linkTo(methodOn(DistributionSetTypeRestApi.class).getMandatoryModules(result.getModuleId())) - .withRel(RestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULES)); + result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getMandatoryModules(result.getModuleId())) + .withRel(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULES)); - result.add(linkTo(methodOn(DistributionSetTypeRestApi.class).getOptionalModules(result.getModuleId())) - .withRel(RestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULES)); + result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getOptionalModules(result.getModuleId())) + .withRel(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULES)); return result; } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResource.java similarity index 74% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResource.java index f7346a6ff..0e5adccdc 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResource.java @@ -6,12 +6,21 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import java.util.List; +import org.eclipse.hawkbit.mgmt.json.model.MgmtId; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPut; +import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRest; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetTypeFields; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.Artifact; @@ -19,13 +28,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; -import org.eclipse.hawkbit.rest.resource.api.DistributionSetTypeRestApi; -import org.eclipse.hawkbit.rest.resource.model.IdRest; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyPut; -import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRest; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -45,7 +47,7 @@ import org.springframework.web.bind.annotation.RestController; * */ @RestController -public class DistributionSetTypeResource implements DistributionSetTypeRestApi { +public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeRestApi { @Autowired private SoftwareManagement softwareManagement; @@ -54,11 +56,11 @@ public class DistributionSetTypeResource implements DistributionSetTypeRestApi { private DistributionSetManagement distributionSetManagement; @Override - public ResponseEntity> getDistributionSetTypes( - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + public ResponseEntity> getDistributionSetTypes( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); @@ -77,17 +79,17 @@ public class DistributionSetTypeResource implements DistributionSetTypeRestApi { countModulesAll = distributionSetManagement.countDistributionSetTypesAll(); } - final List rest = DistributionSetTypeMapper + final List rest = MgmtDistributionSetTypeMapper .toListResponse(findModuleTypessAll.getContent()); return new ResponseEntity<>(new PagedList<>(rest, countModulesAll), HttpStatus.OK); } @Override - public ResponseEntity getDistributionSetType( + public ResponseEntity getDistributionSetType( @PathVariable final Long distributionSetTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); - return new ResponseEntity<>(DistributionSetTypeMapper.toResponse(foundType), HttpStatus.OK); + return new ResponseEntity<>(MgmtDistributionSetTypeMapper.toResponse(foundType), HttpStatus.OK); } @Override @@ -100,9 +102,9 @@ public class DistributionSetTypeResource implements DistributionSetTypeRestApi { } @Override - public ResponseEntity updateDistributionSetType( + public ResponseEntity updateDistributionSetType( @PathVariable final Long distributionSetTypeId, - @RequestBody final DistributionSetTypeRequestBodyPut restDistributionSetType) { + @RequestBody final MgmtDistributionSetTypeRequestBodyPut restDistributionSetType) { final DistributionSetType type = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); // only description can be modified @@ -113,17 +115,17 @@ public class DistributionSetTypeResource implements DistributionSetTypeRestApi { final DistributionSetType updatedDistributionSetType = distributionSetManagement .updateDistributionSetType(type); - return new ResponseEntity<>(DistributionSetTypeMapper.toResponse(updatedDistributionSetType), HttpStatus.OK); + return new ResponseEntity<>(MgmtDistributionSetTypeMapper.toResponse(updatedDistributionSetType), HttpStatus.OK); } @Override - public ResponseEntity> createDistributionSetTypes( - @RequestBody final List distributionSetTypes) { + public ResponseEntity> createDistributionSetTypes( + @RequestBody final List distributionSetTypes) { final List createdSoftwareModules = distributionSetManagement.createDistributionSetTypes( - DistributionSetTypeMapper.smFromRequest(softwareManagement, distributionSetTypes)); + MgmtDistributionSetTypeMapper.smFromRequest(softwareManagement, distributionSetTypes)); - return new ResponseEntity<>(DistributionSetTypeMapper.toTypesResponse(createdSoftwareModules), + return new ResponseEntity<>(MgmtDistributionSetTypeMapper.toTypesResponse(createdSoftwareModules), HttpStatus.CREATED); } @@ -137,16 +139,16 @@ public class DistributionSetTypeResource implements DistributionSetTypeRestApi { } @Override - public ResponseEntity> getMandatoryModules( + public ResponseEntity> getMandatoryModules( @PathVariable final Long distributionSetTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); - return new ResponseEntity<>(SoftwareModuleTypeMapper.toListResponse(foundType.getMandatoryModuleTypes()), + return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toListResponse(foundType.getMandatoryModuleTypes()), HttpStatus.OK); } @Override - public ResponseEntity getMandatoryModule(@PathVariable final Long distributionSetTypeId, + public ResponseEntity getMandatoryModule(@PathVariable final Long distributionSetTypeId, @PathVariable final Long softwareModuleTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); @@ -158,11 +160,11 @@ public class DistributionSetTypeResource implements DistributionSetTypeRestApi { "Software module with given ID is not part of this distribution set type!"); } - return new ResponseEntity<>(SoftwareModuleTypeMapper.toResponse(foundSmType), HttpStatus.OK); + return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toResponse(foundSmType), HttpStatus.OK); } @Override - public ResponseEntity getOptionalModule(@PathVariable final Long distributionSetTypeId, + public ResponseEntity getOptionalModule(@PathVariable final Long distributionSetTypeId, @PathVariable final Long softwareModuleTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); @@ -174,16 +176,16 @@ public class DistributionSetTypeResource implements DistributionSetTypeRestApi { "Software module with given ID is not part of this distribution set type!"); } - return new ResponseEntity<>(SoftwareModuleTypeMapper.toResponse(foundSmType), HttpStatus.OK); + return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toResponse(foundSmType), HttpStatus.OK); } @Override - public ResponseEntity> getOptionalModules( + public ResponseEntity> getOptionalModules( @PathVariable final Long distributionSetTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); - return new ResponseEntity<>(SoftwareModuleTypeMapper.toListResponse(foundType.getOptionalModuleTypes()), + return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toListResponse(foundType.getOptionalModuleTypes()), HttpStatus.OK); } @@ -228,7 +230,7 @@ public class DistributionSetTypeResource implements DistributionSetTypeRestApi { @Override public ResponseEntity addMandatoryModule(@PathVariable final Long distributionSetTypeId, - @RequestBody final IdRest smtId) { + @RequestBody final MgmtId smtId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); @@ -243,7 +245,7 @@ public class DistributionSetTypeResource implements DistributionSetTypeRestApi { @Override public ResponseEntity addOptionalModule(@PathVariable final Long distributionSetTypeId, - @RequestBody final IdRest smtId) { + @RequestBody final MgmtId smtId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DownloadArtifactResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadArtifactResource.java similarity index 79% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DownloadArtifactResource.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadArtifactResource.java index 00f8f4756..ec06c3c8a 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DownloadArtifactResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadArtifactResource.java @@ -6,34 +6,30 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.eclipse.hawkbit.artifact.repository.model.DbArtifact; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDownloadArtifactRestApi; import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; -import org.eclipse.hawkbit.rest.resource.helper.RestResourceConversionHelper; +import org.eclipse.hawkbit.rest.util.RestResourceConversionHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; /** - * @author Jonathan Knoblauch * */ @RestController -@RequestMapping(RestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) -public class DownloadArtifactResource { +public class MgmtDownloadArtifactResource implements MgmtDownloadArtifactRestApi { @Autowired private SoftwareManagement softwareManagement; @@ -55,11 +51,10 @@ public class DownloadArtifactResource { * * @return responseEntity with status ok if successful */ - @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/artifacts/{artifactId}/download") + @Override @ResponseBody - public ResponseEntity downloadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, - @PathVariable("artifactId") final Long artifactId, final HttpServletResponse servletResponse, - final HttpServletRequest request) { + public ResponseEntity downloadArtifact(final Long softwareModuleId, final Long artifactId, + final HttpServletResponse servletResponse, final HttpServletRequest request) { final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId); if (null == module || !module.getLocalArtifact(artifactId).isPresent()) { diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DownloadResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadResource.java similarity index 83% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DownloadResource.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadResource.java index 14b1dcbc6..ec2eced90 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DownloadResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadResource.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import java.io.IOException; @@ -17,6 +17,7 @@ import org.eclipse.hawkbit.artifact.repository.ArtifactRepository; import org.eclipse.hawkbit.artifact.repository.model.DbArtifact; import org.eclipse.hawkbit.cache.CacheConstants; import org.eclipse.hawkbit.cache.DownloadArtifactCache; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDownloadRestApi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -25,10 +26,6 @@ import org.springframework.cache.Cache; import org.springframework.cache.Cache.ValueWrapper; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; /** @@ -37,11 +34,10 @@ import org.springframework.web.bind.annotation.RestController; * * */ -@RequestMapping(RestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE) @RestController -public class DownloadResource { +public class MgmtDownloadResource implements MgmtDownloadRestApi { - private static final Logger LOGGER = LoggerFactory.getLogger(DownloadResource.class); + private static final Logger LOGGER = LoggerFactory.getLogger(MgmtDownloadResource.class); @Autowired private ArtifactRepository artifactRepository; @@ -60,9 +56,8 @@ public class DownloadResource { * @return {@link ResponseEntity} with status {@link HttpStatus#OK} if * successful */ - @RequestMapping(method = RequestMethod.GET, value = RestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING) - @ResponseBody - public ResponseEntity downloadArtifactByDownloadId(@PathVariable final String downloadId, + @Override + public ResponseEntity downloadArtifactByDownloadId(final String downloadId, final HttpServletResponse response) { try { final ValueWrapper cacheWrapper = cache.get(downloadId); diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java new file mode 100644 index 000000000..deee0e461 --- /dev/null +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java @@ -0,0 +1,81 @@ +/** + * 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.mgmt.rest.resource; + +import org.eclipse.hawkbit.mgmt.json.model.MgmtBaseEntity; +import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; +import org.eclipse.hawkbit.repository.model.Action.ActionType; +import org.eclipse.hawkbit.repository.model.NamedEntity; +import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity; + +/** + * A mapper which maps repository model to RESTful model representation and + * back. + * + * + * + * + */ +final class MgmtRestModelMapper { + + // private constructor, utility class + private MgmtRestModelMapper() { + + } + + static void mapBaseToBase(final MgmtBaseEntity response, final TenantAwareBaseEntity base) { + response.setCreatedBy(base.getCreatedBy()); + response.setLastModifiedBy(base.getLastModifiedBy()); + if (base.getCreatedAt() != null) { + response.setCreatedAt(base.getCreatedAt()); + } + if (base.getLastModifiedAt() != null) { + response.setLastModifiedAt(base.getLastModifiedAt()); + } + } + + static void mapNamedToNamed(final MgmtNamedEntity response, final NamedEntity base) { + mapBaseToBase(response, base); + + response.setName(base.getName()); + response.setDescription(base.getDescription()); + } + + /** + * Convert a action rest type to a action repository type. + * + * @param actionTypeRest + * the rest type + * @return or the action repository type + */ + /** + * Convert a action rest type to a action repository type. + * + * @param actionTypeRest + * the rest type + * @return or the action repository type + */ + public static ActionType convertActionType(final MgmtActionType actionTypeRest) { + if (actionTypeRest == null) { + return null; + } + + switch (actionTypeRest) { + case SOFT: + return ActionType.SOFT; + case FORCED: + return ActionType.FORCED; + case TIMEFORCED: + return ActionType.TIMEFORCED; + default: + throw new IllegalStateException("Action Type is not supported"); + } + } +} diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RolloutMapper.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutMapper.java similarity index 67% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RolloutMapper.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutMapper.java index c6be219ba..4dcaf0bf1 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RolloutMapper.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutMapper.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; @@ -14,6 +14,14 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; import java.util.ArrayList; import java.util.List; +import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutCondition.Condition; +import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutErrorAction.ErrorAction; +import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutResponseBody; +import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutRestRequestBody; +import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutSuccessAction.SuccessAction; +import org.eclipse.hawkbit.mgmt.json.model.rolloutgroup.MgmtRolloutGroupResponseBody; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi; import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.Rollout; @@ -23,14 +31,6 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondit import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessAction; import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; -import org.eclipse.hawkbit.rest.resource.api.RolloutRestApi; -import org.eclipse.hawkbit.rest.resource.helper.RestResourceConversionHelper; -import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutCondition.Condition; -import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutErrorAction.ErrorAction; -import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutResponseBody; -import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutRestRequestBody; -import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutSuccessAction.SuccessAction; -import org.eclipse.hawkbit.rest.resource.model.rolloutgroup.RolloutGroupResponseBody; /** * A mapper which maps repository model to RESTful model representation and @@ -38,22 +38,22 @@ import org.eclipse.hawkbit.rest.resource.model.rolloutgroup.RolloutGroupResponse * * */ -final class RolloutMapper { +final class MgmtRolloutMapper { private static final String NOT_SUPPORTED = " is not supported"; - private RolloutMapper() { + private MgmtRolloutMapper() { // Utility class } - static List toResponseRollout(final List rollouts) { - final List result = new ArrayList<>(rollouts.size()); + static List toResponseRollout(final List rollouts) { + final List result = new ArrayList<>(rollouts.size()); rollouts.forEach(r -> result.add(toResponseRollout(r))); return result; } - static RolloutResponseBody toResponseRollout(final Rollout rollout) { - final RolloutResponseBody body = new RolloutResponseBody(); + static MgmtRolloutResponseBody toResponseRollout(final Rollout rollout) { + final MgmtRolloutResponseBody body = new MgmtRolloutResponseBody(); body.setCreatedAt(rollout.getCreatedAt()); body.setCreatedBy(rollout.getCreatedBy()); body.setDescription(rollout.getDescription()); @@ -71,25 +71,26 @@ final class RolloutMapper { rollout.getTotalTargetCountStatus().getTotalTargetCountByStatus(status)); } - body.add(linkTo(methodOn(RolloutRestApi.class).getRollout(rollout.getId())).withRel("self")); - body.add(linkTo(methodOn(RolloutRestApi.class).start(rollout.getId(), false)).withRel("start")); - body.add(linkTo(methodOn(RolloutRestApi.class).start(rollout.getId(), true)).withRel("startAsync")); - body.add(linkTo(methodOn(RolloutRestApi.class).pause(rollout.getId())).withRel("pause")); - body.add(linkTo(methodOn(RolloutRestApi.class).resume(rollout.getId())).withRel("resume")); - body.add(linkTo(methodOn(RolloutRestApi.class).getRolloutGroups(rollout.getId(), - Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET), - Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)).withRel("groups")); + body.add(linkTo(methodOn(MgmtRolloutRestApi.class).getRollout(rollout.getId())).withRel("self")); + body.add(linkTo(methodOn(MgmtRolloutRestApi.class).start(rollout.getId(), false)).withRel("start")); + body.add(linkTo(methodOn(MgmtRolloutRestApi.class).start(rollout.getId(), true)).withRel("startAsync")); + body.add(linkTo(methodOn(MgmtRolloutRestApi.class).pause(rollout.getId())).withRel("pause")); + body.add(linkTo(methodOn(MgmtRolloutRestApi.class).resume(rollout.getId())).withRel("resume")); + body.add(linkTo(methodOn(MgmtRolloutRestApi.class).getRolloutGroups(rollout.getId(), + Integer.parseInt(MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET), + Integer.parseInt(MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)) + .withRel("groups")); return body; } - static Rollout fromRequest(final RolloutRestRequestBody restRequest, final DistributionSet distributionSet, + static Rollout fromRequest(final MgmtRolloutRestRequestBody restRequest, final DistributionSet distributionSet, final String filterQuery) { final Rollout rollout = new Rollout(); rollout.setName(restRequest.getName()); rollout.setDescription(restRequest.getDescription()); rollout.setDistributionSet(distributionSet); rollout.setTargetFilterQuery(filterQuery); - final ActionType convertActionType = RestResourceConversionHelper.convertActionType(restRequest.getType()); + final ActionType convertActionType = MgmtRestModelMapper.convertActionType(restRequest.getType()); if (convertActionType != null) { rollout.setActionType(convertActionType); } @@ -100,14 +101,14 @@ final class RolloutMapper { return rollout; } - static List toResponseRolloutGroup(final List rollouts) { - final List result = new ArrayList<>(rollouts.size()); + static List toResponseRolloutGroup(final List rollouts) { + final List result = new ArrayList<>(rollouts.size()); rollouts.forEach(r -> result.add(toResponseRolloutGroup(r))); return result; } - static RolloutGroupResponseBody toResponseRolloutGroup(final RolloutGroup rolloutGroup) { - final RolloutGroupResponseBody body = new RolloutGroupResponseBody(); + static MgmtRolloutGroupResponseBody toResponseRolloutGroup(final RolloutGroup rolloutGroup) { + final MgmtRolloutGroupResponseBody body = new MgmtRolloutGroupResponseBody(); body.setCreatedAt(rolloutGroup.getCreatedAt()); body.setCreatedBy(rolloutGroup.getCreatedBy()); body.setDescription(rolloutGroup.getDescription()); @@ -116,9 +117,8 @@ final class RolloutMapper { body.setName(rolloutGroup.getName()); body.setRolloutGroupId(rolloutGroup.getId()); body.setStatus(rolloutGroup.getStatus().toString().toLowerCase()); - body.add(linkTo( - methodOn(RolloutRestApi.class).getRolloutGroup(rolloutGroup.getRollout().getId(), rolloutGroup.getId())) - .withRel("self")); + body.add(linkTo(methodOn(MgmtRolloutRestApi.class).getRolloutGroup(rolloutGroup.getRollout().getId(), + rolloutGroup.getId())).withRel("self")); return body; } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RolloutResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java similarity index 81% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RolloutResource.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java index 78cfefa0d..ba1017cf3 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RolloutResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java @@ -6,11 +6,18 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import java.util.List; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutResponseBody; +import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutRestRequestBody; +import org.eclipse.hawkbit.mgmt.json.model.rolloutgroup.MgmtRolloutGroupResponseBody; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi; import org.eclipse.hawkbit.repository.DistributionSetManagement; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.RolloutFields; import org.eclipse.hawkbit.repository.RolloutGroupFields; import org.eclipse.hawkbit.repository.RolloutGroupManagement; @@ -27,12 +34,6 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessActi import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; -import org.eclipse.hawkbit.rest.resource.api.RolloutRestApi; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutResponseBody; -import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutRestRequestBody; -import org.eclipse.hawkbit.rest.resource.model.rolloutgroup.RolloutGroupResponseBody; -import org.eclipse.hawkbit.rest.resource.model.target.TargetRest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -48,7 +49,7 @@ import org.springframework.web.bind.annotation.RestController; * */ @RestController -public class RolloutResource implements RolloutRestApi { +public class MgmtRolloutResource implements MgmtRolloutRestApi { private static final String DOES_NOT_EXIST = "} does not exist"; @@ -62,7 +63,7 @@ public class RolloutResource implements RolloutRestApi { private DistributionSetManagement distributionSetManagement; @Override - public ResponseEntity> getRollouts(final int pagingOffsetParam, + public ResponseEntity> getRollouts(final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); @@ -79,18 +80,18 @@ public class RolloutResource implements RolloutRestApi { findModulesAll = this.rolloutManagement.findAll(pageable); } - final List rest = RolloutMapper.toResponseRollout(findModulesAll.getContent()); + final List rest = MgmtRolloutMapper.toResponseRollout(findModulesAll.getContent()); return new ResponseEntity<>(new PagedList<>(rest, findModulesAll.getTotalElements()), HttpStatus.OK); } @Override - public ResponseEntity getRollout(final Long rolloutId) { + public ResponseEntity getRollout(final Long rolloutId) { final Rollout findRolloutById = findRolloutOrThrowException(rolloutId); - return new ResponseEntity<>(RolloutMapper.toResponseRollout(findRolloutById), HttpStatus.OK); + return new ResponseEntity<>(MgmtRolloutMapper.toResponseRollout(findRolloutById), HttpStatus.OK); } @Override - public ResponseEntity create(@RequestBody final RolloutRestRequestBody rolloutRequestBody) { + public ResponseEntity create(@RequestBody final MgmtRolloutRestRequestBody rolloutRequestBody) { // first check the given RSQL query if it's well formed, otherwise and // exception is thrown @@ -111,20 +112,20 @@ public class RolloutResource implements RolloutRestApi { RolloutGroupErrorAction errorAction = null; String errorActionExpr = null; if (rolloutRequestBody.getSuccessCondition() != null) { - successCondition = RolloutMapper + successCondition = MgmtRolloutMapper .mapFinishCondition(rolloutRequestBody.getSuccessCondition().getCondition()); successConditionExpr = rolloutRequestBody.getSuccessCondition().getExpression(); } if (rolloutRequestBody.getSuccessAction() != null) { - successAction = RolloutMapper.map(rolloutRequestBody.getSuccessAction().getAction()); + successAction = MgmtRolloutMapper.map(rolloutRequestBody.getSuccessAction().getAction()); successActionExpr = rolloutRequestBody.getSuccessAction().getExpression(); } if (rolloutRequestBody.getErrorCondition() != null) { - errorCondition = RolloutMapper.mapErrorCondition(rolloutRequestBody.getErrorCondition().getCondition()); + errorCondition = MgmtRolloutMapper.mapErrorCondition(rolloutRequestBody.getErrorCondition().getCondition()); errorConditionExpr = rolloutRequestBody.getErrorCondition().getExpression(); } if (rolloutRequestBody.getErrorAction() != null) { - errorAction = RolloutMapper.map(rolloutRequestBody.getErrorAction().getAction()); + errorAction = MgmtRolloutMapper.map(rolloutRequestBody.getErrorAction().getAction()); errorActionExpr = rolloutRequestBody.getErrorAction().getExpression(); } @@ -133,11 +134,11 @@ public class RolloutResource implements RolloutRestApi { .successAction(successAction, successActionExpr).errorCondition(errorCondition, errorConditionExpr) .errorAction(errorAction, errorActionExpr).build(); final Rollout rollout = this.rolloutManagement.createRollout( - RolloutMapper.fromRequest(rolloutRequestBody, distributionSet, + MgmtRolloutMapper.fromRequest(rolloutRequestBody, distributionSet, rolloutRequestBody.getTargetFilterQuery()), rolloutRequestBody.getAmountGroups(), rolloutGroupConditions); - return ResponseEntity.status(HttpStatus.CREATED).body(RolloutMapper.toResponseRollout(rollout)); + return ResponseEntity.status(HttpStatus.CREATED).body(MgmtRolloutMapper.toResponseRollout(rollout)); } @Override @@ -166,7 +167,7 @@ public class RolloutResource implements RolloutRestApi { } @Override - public ResponseEntity> getRolloutGroups(final Long rolloutId, + public ResponseEntity> getRolloutGroups(final Long rolloutId, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { final Rollout rollout = findRolloutOrThrowException(rolloutId); @@ -184,20 +185,20 @@ public class RolloutResource implements RolloutRestApi { findRolloutGroupsAll = this.rolloutGroupManagement.findRolloutGroupsByRolloutId(rolloutId, pageable); } - final List rest = RolloutMapper + final List rest = MgmtRolloutMapper .toResponseRolloutGroup(findRolloutGroupsAll.getContent()); return new ResponseEntity<>(new PagedList<>(rest, findRolloutGroupsAll.getTotalElements()), HttpStatus.OK); } @Override - public ResponseEntity getRolloutGroup(final Long rolloutId, final Long groupId) { + public ResponseEntity getRolloutGroup(final Long rolloutId, final Long groupId) { findRolloutOrThrowException(rolloutId); final RolloutGroup rolloutGroup = findRolloutGroupOrThrowException(groupId); - return ResponseEntity.ok(RolloutMapper.toResponseRolloutGroup(rolloutGroup)); + return ResponseEntity.ok(MgmtRolloutMapper.toResponseRolloutGroup(rolloutGroup)); } @Override - public ResponseEntity> getRolloutGroupTargets(final Long rolloutId, final Long groupId, + public ResponseEntity> getRolloutGroupTargets(final Long rolloutId, final Long groupId, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { findRolloutOrThrowException(rolloutId); final RolloutGroup rolloutGroup = findRolloutGroupOrThrowException(groupId); @@ -218,8 +219,8 @@ public class RolloutResource implements RolloutRestApi { pageable); rolloutGroupTargets = pageTargets; } - final List rest = TargetMapper.toResponse(rolloutGroupTargets.getContent()); - return new ResponseEntity<>(new PagedList(rest, rolloutGroupTargets.getTotalElements()), + final List rest = MgmtTargetMapper.toResponse(rolloutGroupTargets.getContent()); + return new ResponseEntity<>(new PagedList(rest, rolloutGroupTargets.getTotalElements()), HttpStatus.OK); } @@ -239,7 +240,7 @@ public class RolloutResource implements RolloutRestApi { return rolloutGroup; } - private DistributionSet findDistributionSetOrThrowException(final RolloutRestRequestBody rolloutRequestBody) { + private DistributionSet findDistributionSetOrThrowException(final MgmtRolloutRestRequestBody rolloutRequestBody) { final DistributionSet ds = this.distributionSetManagement .findDistributionSetById(rolloutRequestBody.getDistributionSetId()); if (ds == null) { diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java similarity index 63% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java index 01dfae9cd..b31fe068a 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; @@ -14,6 +14,14 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; import java.util.ArrayList; import java.util.List; +import org.eclipse.hawkbit.mgmt.json.model.MetadataRest; +import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact; +import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifactHash; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestAPI; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.Artifact; @@ -21,21 +29,14 @@ import org.eclipse.hawkbit.repository.model.LocalArtifact; 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.rest.resource.api.SoftwareModuleRestAPI; -import org.eclipse.hawkbit.rest.resource.api.SoftwareModuleTypeRestApi; -import org.eclipse.hawkbit.rest.resource.model.MetadataRest; -import org.eclipse.hawkbit.rest.resource.model.artifact.ArtifactHash; -import org.eclipse.hawkbit.rest.resource.model.artifact.ArtifactRest; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest; /** * A mapper which maps repository model to RESTful model representation and * back. * */ -public final class SoftwareModuleMapper { - private SoftwareModuleMapper() { +public final class MgmtSoftwareModuleMapper { + private MgmtSoftwareModuleMapper() { // Utility class } @@ -51,7 +52,7 @@ public final class SoftwareModuleMapper { return smType; } - static SoftwareModule fromRequest(final SoftwareModuleRequestBodyPost smsRest, + static SoftwareModule fromRequest(final MgmtSoftwareModuleRequestBodyPost smsRest, final SoftwareManagement softwareManagement) { return new SoftwareModule(getSoftwareModuleTypeFromKeyString(smsRest.getType(), softwareManagement), smsRest.getName(), smsRest.getVersion(), smsRest.getDescription(), smsRest.getVendor()); @@ -69,10 +70,10 @@ public final class SoftwareModuleMapper { return mappedList; } - static List smFromRequest(final Iterable smsRest, + static List smFromRequest(final Iterable smsRest, final SoftwareManagement softwareManagement) { final List mappedList = new ArrayList<>(); - for (final SoftwareModuleRequestBodyPost smRest : smsRest) { + for (final MgmtSoftwareModuleRequestBodyPost smRest : smsRest) { mappedList.add(fromRequest(smRest, softwareManagement)); } return mappedList; @@ -85,11 +86,11 @@ public final class SoftwareModuleMapper { * the modules * @return the response */ - public static List toResponse(final List baseSoftareModules) { - final List mappedList = new ArrayList<>(); + public static List toResponse(final List baseSoftareModules) { + final List mappedList = new ArrayList<>(); if (baseSoftareModules != null) { for (final SoftwareModule target : baseSoftareModules) { - final SoftwareModuleRest response = toResponse(target); + final MgmtSoftwareModule response = toResponse(target); mappedList.add(response); } @@ -97,8 +98,8 @@ public final class SoftwareModuleMapper { return mappedList; } - static List toResponseSoftwareModules(final Iterable softwareModules) { - final List response = new ArrayList<>(); + static List toResponseSoftwareModules(final Iterable softwareModules) { + final List response = new ArrayList<>(); for (final SoftwareModule softwareModule : softwareModules) { response.add(toResponse(softwareModule)); } @@ -127,30 +128,30 @@ public final class SoftwareModuleMapper { * the sw module * @return the response */ - public static SoftwareModuleRest toResponse(final SoftwareModule baseSofwareModule) { + public static MgmtSoftwareModule toResponse(final SoftwareModule baseSofwareModule) { if (baseSofwareModule == null) { return null; } - final SoftwareModuleRest response = new SoftwareModuleRest(); - RestModelMapper.mapNamedToNamed(response, baseSofwareModule); + final MgmtSoftwareModule response = new MgmtSoftwareModule(); + MgmtRestModelMapper.mapNamedToNamed(response, baseSofwareModule); response.setModuleId(baseSofwareModule.getId()); response.setVersion(baseSofwareModule.getVersion()); response.setType(baseSofwareModule.getType().getKey()); response.setVendor(baseSofwareModule.getVendor()); - response.add(linkTo(methodOn(SoftwareModuleRestAPI.class).getArtifacts(response.getModuleId())) - .withRel(RestConstants.SOFTWAREMODULE_V1_ARTIFACT)); - response.add(linkTo(methodOn(SoftwareModuleRestAPI.class).getSoftwareModule(response.getModuleId())) + response.add(linkTo(methodOn(MgmtSoftwareModuleRestAPI.class).getArtifacts(response.getModuleId())) + .withRel(MgmtRestConstants.SOFTWAREMODULE_V1_ARTIFACT)); + response.add(linkTo(methodOn(MgmtSoftwareModuleRestAPI.class).getSoftwareModule(response.getModuleId())) .withRel("self")); response.add(linkTo( - methodOn(SoftwareModuleTypeRestApi.class).getSoftwareModuleType(baseSofwareModule.getType().getId())) - .withRel(RestConstants.SOFTWAREMODULE_V1_TYPE)); + methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(baseSofwareModule.getType().getId())) + .withRel(MgmtRestConstants.SOFTWAREMODULE_V1_TYPE)); - response.add(linkTo(methodOn(SoftwareModuleResource.class).getMetadata(response.getModuleId(), - Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET), - Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)) + response.add(linkTo(methodOn(MgmtSoftwareModuleResource.class).getMetadata(response.getModuleId(), + Integer.parseInt(MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET), + Integer.parseInt(MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)) .withRel("metadata")); return response; } @@ -159,27 +160,27 @@ public final class SoftwareModuleMapper { * @param artifact * @return */ - static ArtifactRest toResponse(final Artifact artifact) { - final ArtifactRest.ArtifactType type = artifact instanceof LocalArtifact ? ArtifactRest.ArtifactType.LOCAL - : ArtifactRest.ArtifactType.EXTERNAL; + static MgmtArtifact toResponse(final Artifact artifact) { + final MgmtArtifact.ArtifactType type = artifact instanceof LocalArtifact ? MgmtArtifact.ArtifactType.LOCAL + : MgmtArtifact.ArtifactType.EXTERNAL; - final ArtifactRest artifactRest = new ArtifactRest(); + final MgmtArtifact artifactRest = new MgmtArtifact(); artifactRest.setType(type); artifactRest.setArtifactId(artifact.getId()); artifactRest.setSize(artifact.getSize()); - artifactRest.setHashes(new ArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash())); + artifactRest.setHashes(new MgmtArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash())); if (artifact instanceof LocalArtifact) { artifactRest.setProvidedFilename(((LocalArtifact) artifact).getFilename()); } - RestModelMapper.mapBaseToBase(artifactRest, artifact); + MgmtRestModelMapper.mapBaseToBase(artifactRest, artifact); - artifactRest.add(linkTo(methodOn(SoftwareModuleRestAPI.class).getArtifact(artifact.getSoftwareModule().getId(), + artifactRest.add(linkTo(methodOn(MgmtSoftwareModuleRestAPI.class).getArtifact(artifact.getSoftwareModule().getId(), artifact.getId())).withRel("self")); if (artifact instanceof LocalArtifact) { - artifactRest.add(linkTo(methodOn(DownloadArtifactResource.class) + artifactRest.add(linkTo(methodOn(MgmtDownloadArtifactResource.class) .downloadArtifact(artifact.getSoftwareModule().getId(), artifact.getId(), null, null)) .withRel("download")); } @@ -187,12 +188,12 @@ public final class SoftwareModuleMapper { return artifactRest; } - static List artifactsToResponse(final List artifacts) { - final List mappedList = new ArrayList<>(); + static List artifactsToResponse(final List artifacts) { + final List mappedList = new ArrayList<>(); if (artifacts != null) { for (final Artifact artifact : artifacts) { - final ArtifactRest response = toResponse(artifact); + final MgmtArtifact response = toResponse(artifact); mappedList.add(response); } } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java similarity index 71% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java index 830443cbd..f4135744b 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java @@ -6,12 +6,21 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import java.io.IOException; import java.util.List; +import org.eclipse.hawkbit.mgmt.json.model.MetadataRest; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPut; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestAPI; import org.eclipse.hawkbit.repository.ArtifactManagement; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareModuleFields; import org.eclipse.hawkbit.repository.SoftwareModuleMetadataFields; @@ -21,13 +30,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; -import org.eclipse.hawkbit.rest.resource.api.SoftwareModuleRestAPI; -import org.eclipse.hawkbit.rest.resource.model.MetadataRest; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.artifact.ArtifactRest; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRequestBodyPut; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -49,8 +51,8 @@ import org.springframework.web.multipart.MultipartFile; * */ @RestController -public class SoftwareModuleResource implements SoftwareModuleRestAPI { - private static final Logger LOG = LoggerFactory.getLogger(SoftwareModuleResource.class); +public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestAPI { + private static final Logger LOG = LoggerFactory.getLogger(MgmtSoftwareModuleResource.class); @Autowired private ArtifactManagement artifactManagement; @@ -59,7 +61,7 @@ public class SoftwareModuleResource implements SoftwareModuleRestAPI { private SoftwareManagement softwareManagement; @Override - public ResponseEntity uploadArtifact(@PathVariable final Long softwareModuleId, + public ResponseEntity uploadArtifact(@PathVariable final Long softwareModuleId, @RequestParam("file") final MultipartFile file, @RequestParam(value = "filename", required = false) final String optionalFileName, @RequestParam(value = "md5sum", required = false) final String md5Sum, @@ -85,23 +87,23 @@ public class SoftwareModuleResource implements SoftwareModuleRestAPI { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } - return new ResponseEntity<>(SoftwareModuleMapper.toResponse(result), HttpStatus.CREATED); + return new ResponseEntity<>(MgmtSoftwareModuleMapper.toResponse(result), HttpStatus.CREATED); } @Override - public ResponseEntity> getArtifacts(@PathVariable final Long softwareModuleId) { + public ResponseEntity> getArtifacts(@PathVariable final Long softwareModuleId) { final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null); - return new ResponseEntity<>(SoftwareModuleMapper.artifactsToResponse(module.getArtifacts()), HttpStatus.OK); + return new ResponseEntity<>(MgmtSoftwareModuleMapper.artifactsToResponse(module.getArtifacts()), HttpStatus.OK); } @Override - public ResponseEntity getArtifact(@PathVariable final Long softwareModuleId, + public ResponseEntity getArtifact(@PathVariable final Long softwareModuleId, @PathVariable final Long artifactId) { final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId); - return new ResponseEntity<>(SoftwareModuleMapper.toResponse(module.getLocalArtifact(artifactId).get()), + return new ResponseEntity<>(MgmtSoftwareModuleMapper.toResponse(module.getLocalArtifact(artifactId).get()), HttpStatus.OK); } @@ -117,11 +119,11 @@ public class SoftwareModuleResource implements SoftwareModuleRestAPI { } @Override - public ResponseEntity> getSoftwareModules( - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + public ResponseEntity> getSoftwareModules( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); @@ -140,32 +142,32 @@ public class SoftwareModuleResource implements SoftwareModuleRestAPI { countModulesAll = softwareManagement.countSoftwareModulesAll(); } - final List rest = SoftwareModuleMapper.toResponse(findModulesAll.getContent()); + final List rest = MgmtSoftwareModuleMapper.toResponse(findModulesAll.getContent()); return new ResponseEntity<>(new PagedList<>(rest, countModulesAll), HttpStatus.OK); } @Override - public ResponseEntity getSoftwareModule(@PathVariable final Long softwareModuleId) { + public ResponseEntity getSoftwareModule(@PathVariable final Long softwareModuleId) { final SoftwareModule findBaseSoftareModule = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null); - return new ResponseEntity<>(SoftwareModuleMapper.toResponse(findBaseSoftareModule), HttpStatus.OK); + return new ResponseEntity<>(MgmtSoftwareModuleMapper.toResponse(findBaseSoftareModule), HttpStatus.OK); } @Override - public ResponseEntity> createSoftwareModules( - @RequestBody final List softwareModules) { + public ResponseEntity> createSoftwareModules( + @RequestBody final List softwareModules) { LOG.debug("creating {} softwareModules", softwareModules.size()); final Iterable createdSoftwareModules = softwareManagement - .createSoftwareModule(SoftwareModuleMapper.smFromRequest(softwareModules, softwareManagement)); + .createSoftwareModule(MgmtSoftwareModuleMapper.smFromRequest(softwareModules, softwareManagement)); LOG.debug("{} softwareModules created, return status {}", softwareModules.size(), HttpStatus.CREATED); - return new ResponseEntity<>(SoftwareModuleMapper.toResponseSoftwareModules(createdSoftwareModules), + return new ResponseEntity<>(MgmtSoftwareModuleMapper.toResponseSoftwareModules(createdSoftwareModules), HttpStatus.CREATED); } @Override - public ResponseEntity updateSoftwareModule(@PathVariable final Long softwareModuleId, - @RequestBody final SoftwareModuleRequestBodyPut restSoftwareModule) { + public ResponseEntity updateSoftwareModule(@PathVariable final Long softwareModuleId, + @RequestBody final MgmtSoftwareModuleRequestBodyPut restSoftwareModule) { final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null); // only description and vendor can be modified @@ -177,7 +179,7 @@ public class SoftwareModuleResource implements SoftwareModuleRestAPI { } final SoftwareModule updateSoftwareModule = softwareManagement.updateSoftwareModule(module); - return new ResponseEntity<>(SoftwareModuleMapper.toResponse(updateSoftwareModule), HttpStatus.OK); + return new ResponseEntity<>(MgmtSoftwareModuleMapper.toResponse(updateSoftwareModule), HttpStatus.OK); } @Override @@ -191,10 +193,10 @@ public class SoftwareModuleResource implements SoftwareModuleRestAPI { @Override public ResponseEntity> getMetadata(@PathVariable final Long softwareModuleId, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { // check if software module exists otherwise throw exception immediately findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null); @@ -214,7 +216,7 @@ public class SoftwareModuleResource implements SoftwareModuleRestAPI { } return new ResponseEntity<>( - new PagedList<>(SoftwareModuleMapper.toResponseSwMetadata(metaDataPage.getContent()), + new PagedList<>(MgmtSoftwareModuleMapper.toResponseSwMetadata(metaDataPage.getContent()), metaDataPage.getTotalElements()), HttpStatus.OK); } @@ -226,7 +228,7 @@ public class SoftwareModuleResource implements SoftwareModuleRestAPI { // immediately final SoftwareModule sw = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null); final SoftwareModuleMetadata findOne = softwareManagement.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sw, metadataKey)); - return ResponseEntity. ok(SoftwareModuleMapper.toResponseSwMetadata(findOne)); + return ResponseEntity. ok(MgmtSoftwareModuleMapper.toResponseSwMetadata(findOne)); } @Override @@ -236,7 +238,7 @@ public class SoftwareModuleResource implements SoftwareModuleRestAPI { final SoftwareModule sw = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null); final SoftwareModuleMetadata updated = softwareManagement .updateSoftwareModuleMetadata(new SoftwareModuleMetadata(metadataKey, sw, metadata.getValue())); - return ResponseEntity.ok(SoftwareModuleMapper.toResponseSwMetadata(updated)); + return ResponseEntity.ok(MgmtSoftwareModuleMapper.toResponseSwMetadata(updated)); } @Override @@ -255,9 +257,9 @@ public class SoftwareModuleResource implements SoftwareModuleRestAPI { final SoftwareModule sw = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null); final List created = softwareManagement - .createSoftwareModuleMetadata(SoftwareModuleMapper.fromRequestSwMetadata(sw, metadataRest)); + .createSoftwareModuleMetadata(MgmtSoftwareModuleMapper.fromRequestSwMetadata(sw, metadataRest)); - return new ResponseEntity<>(SoftwareModuleMapper.toResponseSwMetadata(created), HttpStatus.CREATED); + return new ResponseEntity<>(MgmtSoftwareModuleMapper.toResponseSwMetadata(created), HttpStatus.CREATED); } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeMapper.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java similarity index 62% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeMapper.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java index b6525948c..5b16436a9 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeMapper.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; @@ -15,10 +15,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; -import org.eclipse.hawkbit.rest.resource.api.SoftwareModuleTypeRestApi; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRest; /** * A mapper which maps repository model to RESTful model representation and @@ -28,52 +28,52 @@ import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModule * * */ -final class SoftwareModuleTypeMapper { +final class MgmtSoftwareModuleTypeMapper { // private constructor, utility class - private SoftwareModuleTypeMapper() { + private MgmtSoftwareModuleTypeMapper() { } - static List smFromRequest(final Iterable smTypesRest) { + static List smFromRequest(final Iterable smTypesRest) { final List mappedList = new ArrayList<>(); - for (final SoftwareModuleTypeRequestBodyPost smRest : smTypesRest) { + for (final MgmtSoftwareModuleTypeRequestBodyPost smRest : smTypesRest) { mappedList.add(fromRequest(smRest)); } return mappedList; } - static SoftwareModuleType fromRequest(final SoftwareModuleTypeRequestBodyPost smsRest) { + static SoftwareModuleType fromRequest(final MgmtSoftwareModuleTypeRequestBodyPost smsRest) { return new SoftwareModuleType(smsRest.getKey(), smsRest.getName(), smsRest.getDescription(), smsRest.getMaxAssignments()); } - static List toTypesResponse(final List types) { - final List response = new ArrayList<>(); + static List toTypesResponse(final List types) { + final List response = new ArrayList<>(); for (final SoftwareModuleType softwareModule : types) { response.add(toResponse(softwareModule)); } return response; } - static List toListResponse(final Collection types) { - final List response = new ArrayList<>(); + static List toListResponse(final Collection types) { + final List response = new ArrayList<>(); for (final SoftwareModuleType softwareModule : types) { response.add(toResponse(softwareModule)); } return response; } - static SoftwareModuleTypeRest toResponse(final SoftwareModuleType type) { - final SoftwareModuleTypeRest result = new SoftwareModuleTypeRest(); + static MgmtSoftwareModuleType toResponse(final SoftwareModuleType type) { + final MgmtSoftwareModuleType result = new MgmtSoftwareModuleType(); - RestModelMapper.mapNamedToNamed(result, type); + MgmtRestModelMapper.mapNamedToNamed(result, type); result.setKey(type.getKey()); result.setMaxAssignments(type.getMaxAssignments()); result.setModuleId(type.getId()); - result.add(linkTo(methodOn(SoftwareModuleTypeRestApi.class).getSoftwareModuleType(result.getModuleId())) + result.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(result.getModuleId())) .withRel("self")); return result; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java similarity index 73% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResource.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java index e3498f141..ab23046b3 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java @@ -6,10 +6,16 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import java.util.List; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPut; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareModuleTypeFields; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; @@ -17,11 +23,6 @@ import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; -import org.eclipse.hawkbit.rest.resource.api.SoftwareModuleTypeRestApi; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRequestBodyPost; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRequestBodyPut; -import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -37,12 +38,12 @@ import org.springframework.web.bind.annotation.RestController; * */ @RestController -public class SoftwareModuleTypeResource implements SoftwareModuleTypeRestApi { +public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRestApi { @Autowired private SoftwareManagement softwareManagement; @Override - public ResponseEntity> getTypes(final int pagingOffsetParam, + public ResponseEntity> getTypes(final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); @@ -62,16 +63,16 @@ public class SoftwareModuleTypeResource implements SoftwareModuleTypeRestApi { countModulesAll = this.softwareManagement.countSoftwareModuleTypesAll(); } - final List rest = SoftwareModuleTypeMapper + final List rest = MgmtSoftwareModuleTypeMapper .toListResponse(findModuleTypessAll.getContent()); return new ResponseEntity<>(new PagedList<>(rest, countModulesAll), HttpStatus.OK); } @Override - public ResponseEntity getSoftwareModuleType(final Long softwareModuleTypeId) { + public ResponseEntity getSoftwareModuleType(final Long softwareModuleTypeId) { final SoftwareModuleType foundType = findSoftwareModuleTypeWithExceptionIfNotFound(softwareModuleTypeId); - return new ResponseEntity<>(SoftwareModuleTypeMapper.toResponse(foundType), HttpStatus.OK); + return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toResponse(foundType), HttpStatus.OK); } @Override @@ -84,8 +85,8 @@ public class SoftwareModuleTypeResource implements SoftwareModuleTypeRestApi { } @Override - public ResponseEntity updateSoftwareModuleType(final Long softwareModuleTypeId, - final SoftwareModuleTypeRequestBodyPut restSoftwareModuleType) { + public ResponseEntity updateSoftwareModuleType(final Long softwareModuleTypeId, + final MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType) { final SoftwareModuleType type = findSoftwareModuleTypeWithExceptionIfNotFound(softwareModuleTypeId); // only description can be modified @@ -94,17 +95,17 @@ public class SoftwareModuleTypeResource implements SoftwareModuleTypeRestApi { } final SoftwareModuleType updatedSoftwareModuleType = this.softwareManagement.updateSoftwareModuleType(type); - return new ResponseEntity<>(SoftwareModuleTypeMapper.toResponse(updatedSoftwareModuleType), HttpStatus.OK); + return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toResponse(updatedSoftwareModuleType), HttpStatus.OK); } @Override - public ResponseEntity> createSoftwareModuleTypes( - final List softwareModuleTypes) { + public ResponseEntity> createSoftwareModuleTypes( + final List softwareModuleTypes) { final List createdSoftwareModules = this.softwareManagement - .createSoftwareModuleType(SoftwareModuleTypeMapper.smFromRequest(softwareModuleTypes)); + .createSoftwareModuleType(MgmtSoftwareModuleTypeMapper.smFromRequest(softwareModuleTypes)); - return new ResponseEntity<>(SoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules), + return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules), HttpStatus.CREATED); } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TagMapper.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTagMapper.java similarity index 61% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TagMapper.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTagMapper.java index f9f0caba0..3ab2016ec 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TagMapper.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTagMapper.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; @@ -14,111 +14,111 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; import java.util.ArrayList; import java.util.List; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.Tag; import org.eclipse.hawkbit.repository.model.TargetTag; -import org.eclipse.hawkbit.rest.resource.api.DistributionSetTagRestApi; -import org.eclipse.hawkbit.rest.resource.api.TargetTagRestApi; -import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut; -import org.eclipse.hawkbit.rest.resource.model.tag.TagRest; /** * A mapper which maps repository model to RESTful model representation and * back. * */ -final class TagMapper { - private TagMapper() { +final class MgmtTagMapper { + private MgmtTagMapper() { // Utility class } - static List toResponse(final List targetTags) { - final List tagsRest = new ArrayList<>(); + static List toResponse(final List targetTags) { + final List tagsRest = new ArrayList<>(); if (targetTags == null) { return tagsRest; } for (final TargetTag target : targetTags) { - final TagRest response = toResponse(target); + final MgmtTag response = toResponse(target); tagsRest.add(response); } return tagsRest; } - static TagRest toResponse(final TargetTag targetTag) { - final TagRest response = new TagRest(); + static MgmtTag toResponse(final TargetTag targetTag) { + final MgmtTag response = new MgmtTag(); if (targetTag == null) { return response; } mapTag(response, targetTag); - response.add(linkTo(methodOn(TargetTagRestApi.class).getTargetTag(targetTag.getId())).withRel("self")); + response.add(linkTo(methodOn(MgmtTargetTagRestApi.class).getTargetTag(targetTag.getId())).withRel("self")); - response.add(linkTo(methodOn(TargetTagRestApi.class).getAssignedTargets(targetTag.getId())) + response.add(linkTo(methodOn(MgmtTargetTagRestApi.class).getAssignedTargets(targetTag.getId())) .withRel("assignedTargets")); return response; } - static List toResponseDistributionSetTag(final List distributionSetTags) { - final List tagsRest = new ArrayList<>(); + static List toResponseDistributionSetTag(final List distributionSetTags) { + final List tagsRest = new ArrayList<>(); if (distributionSetTags == null) { return tagsRest; } for (final DistributionSetTag distributionSetTag : distributionSetTags) { - final TagRest response = toResponse(distributionSetTag); + final MgmtTag response = toResponse(distributionSetTag); tagsRest.add(response); } return tagsRest; } - static TagRest toResponse(final DistributionSetTag distributionSetTag) { - final TagRest response = new TagRest(); + static MgmtTag toResponse(final DistributionSetTag distributionSetTag) { + final MgmtTag response = new MgmtTag(); if (distributionSetTag == null) { return null; } mapTag(response, distributionSetTag); - response.add(linkTo(methodOn(DistributionSetTagRestApi.class).getDistributionSetTag(distributionSetTag.getId())) + response.add(linkTo(methodOn(MgmtDistributionSetTagRestApi.class).getDistributionSetTag(distributionSetTag.getId())) .withRel("self")); response.add(linkTo( - methodOn(DistributionSetTagRestApi.class).getAssignedDistributionSets(distributionSetTag.getId())) + methodOn(MgmtDistributionSetTagRestApi.class).getAssignedDistributionSets(distributionSetTag.getId())) .withRel("assignedDistributionSets")); return response; } - static List mapTargeTagFromRequest(final Iterable tags) { + static List mapTargeTagFromRequest(final Iterable tags) { final List mappedList = new ArrayList<>(); - for (final TagRequestBodyPut targetTagRest : tags) { + for (final MgmtTagRequestBodyPut targetTagRest : tags) { mappedList.add( new TargetTag(targetTagRest.getName(), targetTagRest.getDescription(), targetTagRest.getColour())); } return mappedList; } - static List mapDistributionSetTagFromRequest(final Iterable tags) { + static List mapDistributionSetTagFromRequest(final Iterable tags) { final List mappedList = new ArrayList<>(); - for (final TagRequestBodyPut targetTagRest : tags) { + for (final MgmtTagRequestBodyPut targetTagRest : tags) { mappedList.add(new DistributionSetTag(targetTagRest.getName(), targetTagRest.getDescription(), targetTagRest.getColour())); } return mappedList; } - private static void mapTag(final TagRest response, final Tag tag) { - RestModelMapper.mapNamedToNamed(response, tag); + private static void mapTag(final MgmtTag response, final Tag tag) { + MgmtRestModelMapper.mapNamedToNamed(response, tag); response.setTagId(tag.getId()); response.setColour(tag.getColour()); } - static void updateTag(final TagRequestBodyPut response, final Tag tag) { + static void updateTag(final MgmtTagRequestBodyPut response, final Tag tag) { if (response.getDescription() != null) { tag.setDescription(response.getDescription()); } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetMapper.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java similarity index 65% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetMapper.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java index c8a39a2f3..afb941bc1 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetMapper.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; @@ -17,27 +17,29 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import org.eclipse.hawkbit.mgmt.json.model.MgmtPollStatus; +import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction; +import org.eclipse.hawkbit.mgmt.json.model.action.MgmtActionStatus; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi; import org.eclipse.hawkbit.repository.ActionFields; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetInfo.PollStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; -import org.eclipse.hawkbit.rest.resource.api.TargetRestApi; -import org.eclipse.hawkbit.rest.resource.model.PollStatusRest; -import org.eclipse.hawkbit.rest.resource.model.action.ActionRest; -import org.eclipse.hawkbit.rest.resource.model.action.ActionStatusRest; -import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody; -import org.eclipse.hawkbit.rest.resource.model.target.TargetRest; +import org.eclipse.hawkbit.rest.data.SortDirection; /** * A mapper which maps repository model to RESTful model representation and * back. * */ -public final class TargetMapper { +public final class MgmtTargetMapper { - private TargetMapper() { + private MgmtTargetMapper() { // Utility class } @@ -47,17 +49,17 @@ public final class TargetMapper { * @param response * the target response */ - public static void addTargetLinks(final TargetRest response) { - response.add(linkTo(methodOn(TargetRestApi.class).getAssignedDistributionSet(response.getControllerId())) - .withRel(RestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET)); - response.add(linkTo(methodOn(TargetRestApi.class).getInstalledDistributionSet(response.getControllerId())) - .withRel(RestConstants.TARGET_V1_INSTALLED_DISTRIBUTION_SET)); - response.add(linkTo(methodOn(TargetRestApi.class).getAttributes(response.getControllerId())) - .withRel(RestConstants.TARGET_V1_ATTRIBUTES)); - response.add(linkTo(methodOn(TargetRestApi.class).getActionHistory(response.getControllerId(), 0, - RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, + public static void addTargetLinks(final MgmtTarget response) { + response.add(linkTo(methodOn(MgmtTargetRestApi.class).getAssignedDistributionSet(response.getControllerId())) + .withRel(MgmtRestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET)); + response.add(linkTo(methodOn(MgmtTargetRestApi.class).getInstalledDistributionSet(response.getControllerId())) + .withRel(MgmtRestConstants.TARGET_V1_INSTALLED_DISTRIBUTION_SET)); + response.add(linkTo(methodOn(MgmtTargetRestApi.class).getAttributes(response.getControllerId())) + .withRel(MgmtRestConstants.TARGET_V1_ATTRIBUTES)); + response.add(linkTo(methodOn(MgmtTargetRestApi.class).getActionHistory(response.getControllerId(), 0, + MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, ActionFields.ID.getFieldName() + ":" + SortDirection.DESC, null)) - .withRel(RestConstants.TARGET_V1_ACTIONS)); + .withRel(MgmtRestConstants.TARGET_V1_ACTIONS)); } /** @@ -68,10 +70,10 @@ public final class TargetMapper { * @param targetRest * the response */ - public static void addPollStatus(final Target target, final TargetRest targetRest) { + public static void addPollStatus(final Target target, final MgmtTarget targetRest) { final PollStatus pollStatus = target.getTargetInfo().getPollStatus(); if (pollStatus != null) { - final PollStatusRest pollStatusRest = new PollStatusRest(); + final MgmtPollStatus pollStatusRest = new MgmtPollStatus(); pollStatusRest.setLastRequestAt( Date.from(pollStatus.getLastPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime()); pollStatusRest.setNextExpectedRequestAt( @@ -88,11 +90,11 @@ public final class TargetMapper { * the targets * @return the response */ - public static List toResponseWithLinksAndPollStatus(final Iterable targets) { - final List mappedList = new ArrayList<>(); + public static List toResponseWithLinksAndPollStatus(final Iterable targets) { + final List mappedList = new ArrayList<>(); if (targets != null) { for (final Target target : targets) { - final TargetRest response = toResponse(target); + final MgmtTarget response = toResponse(target); addPollStatus(target, response); addTargetLinks(response); mappedList.add(response); @@ -108,11 +110,11 @@ public final class TargetMapper { * list of targets * @return the response */ - public static List toResponse(final Iterable targets) { - final List mappedList = new ArrayList<>(); + public static List toResponse(final Iterable targets) { + final List mappedList = new ArrayList<>(); if (targets != null) { for (final Target target : targets) { - final TargetRest response = toResponse(target); + final MgmtTarget response = toResponse(target); mappedList.add(response); } } @@ -126,11 +128,11 @@ public final class TargetMapper { * the target * @return the response */ - public static TargetRest toResponse(final Target target) { + public static MgmtTarget toResponse(final Target target) { if (target == null) { return null; } - final TargetRest targetRest = new TargetRest(); + final MgmtTarget targetRest = new MgmtTarget(); targetRest.setControllerId(target.getControllerId()); targetRest.setDescription(target.getDescription()); targetRest.setName(target.getName()); @@ -161,32 +163,32 @@ public final class TargetMapper { targetRest.setInstalledAt(installationDate); } - targetRest.add(linkTo(methodOn(TargetRestApi.class).getTarget(target.getControllerId())).withRel("self")); + targetRest.add(linkTo(methodOn(MgmtTargetRestApi.class).getTarget(target.getControllerId())).withRel("self")); return targetRest; } - static List fromRequest(final Iterable targetsRest) { + static List fromRequest(final Iterable targetsRest) { final List mappedList = new ArrayList<>(); - for (final TargetRequestBody targetRest : targetsRest) { + for (final MgmtTargetRequestBody targetRest : targetsRest) { mappedList.add(fromRequest(targetRest)); } return mappedList; } - static Target fromRequest(final TargetRequestBody targetRest) { + static Target fromRequest(final MgmtTargetRequestBody targetRest) { final Target target = new Target(targetRest.getControllerId()); target.setDescription(targetRest.getDescription()); target.setName(targetRest.getName()); return target; } - static List toActionStatusRestResponse(final List actionStatus) { - final List mappedList = new ArrayList<>(); + static List toActionStatusRestResponse(final List actionStatus) { + final List mappedList = new ArrayList<>(); if (actionStatus != null) { for (final ActionStatus status : actionStatus) { - final ActionStatusRest response = toResponse(status); + final MgmtActionStatus response = toResponse(status); mappedList.add(response); } } @@ -194,30 +196,30 @@ public final class TargetMapper { return mappedList; } - static ActionRest toResponse(final String targetId, final Action action, final boolean isActive) { - final ActionRest result = new ActionRest(); + static MgmtAction toResponse(final String targetId, final Action action, final boolean isActive) { + final MgmtAction result = new MgmtAction(); result.setActionId(action.getId()); result.setType(getType(action)); if (isActive) { - result.setStatus(ActionRest.ACTION_PENDING); + result.setStatus(MgmtAction.ACTION_PENDING); } else { - result.setStatus(ActionRest.ACTION_FINISHED); + result.setStatus(MgmtAction.ACTION_FINISHED); } - RestModelMapper.mapBaseToBase(result, action); + MgmtRestModelMapper.mapBaseToBase(result, action); - result.add(linkTo(methodOn(TargetRestApi.class).getAction(targetId, action.getId())).withRel("self")); + result.add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(targetId, action.getId())).withRel("self")); return result; } - static List toResponse(final String targetId, final List actions) { - final List mappedList = new ArrayList<>(); + static List toResponse(final String targetId, final List actions) { + final List mappedList = new ArrayList<>(); for (final Action action : actions) { - final ActionRest response = toResponse(targetId, action, action.isActive()); + final MgmtAction response = toResponse(targetId, action, action.isActive()); mappedList.add(response); } return mappedList; @@ -228,22 +230,22 @@ public final class TargetMapper { switch (type) { case CANCELED: - result = ActionStatusRest.AS_CANCELED; + result = MgmtActionStatus.AS_CANCELED; break; case ERROR: - result = ActionStatusRest.AS_ERROR; + result = MgmtActionStatus.AS_ERROR; break; case FINISHED: - result = ActionStatusRest.AS_FINISHED; + result = MgmtActionStatus.AS_FINISHED; break; case RETRIEVED: - result = ActionStatusRest.AS_RETRIEVED; + result = MgmtActionStatus.AS_RETRIEVED; break; case RUNNING: - result = ActionStatusRest.AS_RUNNING; + result = MgmtActionStatus.AS_RUNNING; break; case WARNING: - result = ActionStatusRest.AS_WARNING; + result = MgmtActionStatus.AS_WARNING; break; default: return type.name().toLowerCase(); @@ -256,9 +258,9 @@ public final class TargetMapper { private static String getType(final Action action) { if (!action.isCancelingOrCanceled()) { - return ActionRest.ACTION_UPDATE; + return MgmtAction.ACTION_UPDATE; } else if (action.isCancelingOrCanceled()) { - return ActionRest.ACTION_CANCEL; + return MgmtAction.ACTION_CANCEL; } return null; @@ -290,8 +292,8 @@ public final class TargetMapper { return result; } - private static ActionStatusRest toResponse(final ActionStatus actionStatus) { - final ActionStatusRest result = new ActionStatusRest(); + private static MgmtActionStatus toResponse(final ActionStatus actionStatus) { + final MgmtActionStatus result = new MgmtActionStatus(); result.setMessages(actionStatus.getMessages()); result.setReportedAt(actionStatus.getCreatedAt()); diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java similarity index 73% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java index 4b068a41e..449c57362 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; @@ -15,9 +15,21 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction; +import org.eclipse.hawkbit.mgmt.json.model.action.MgmtActionStatus; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtDistributionSetAssigment; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAttributes; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi; import org.eclipse.hawkbit.repository.ActionFields; import org.eclipse.hawkbit.repository.ActionStatusFields; import org.eclipse.hawkbit.repository.DeploymentManagement; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.TargetFields; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; @@ -26,17 +38,7 @@ import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; -import org.eclipse.hawkbit.rest.resource.api.DistributionSetRestApi; -import org.eclipse.hawkbit.rest.resource.api.TargetRestApi; -import org.eclipse.hawkbit.rest.resource.helper.RestResourceConversionHelper; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.action.ActionRest; -import org.eclipse.hawkbit.rest.resource.model.action.ActionStatusRest; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest; -import org.eclipse.hawkbit.rest.resource.model.target.DistributionSetAssigmentRest; -import org.eclipse.hawkbit.rest.resource.model.target.TargetAttributes; -import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody; -import org.eclipse.hawkbit.rest.resource.model.target.TargetRest; +import org.eclipse.hawkbit.rest.data.SortDirection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -54,8 +56,8 @@ import org.springframework.web.bind.annotation.RestController; * REST Resource handling target CRUD operations. */ @RestController -public class TargetResource implements TargetRestApi { - private static final Logger LOG = LoggerFactory.getLogger(TargetResource.class); +public class MgmtTargetResource implements MgmtTargetRestApi { + private static final Logger LOG = LoggerFactory.getLogger(MgmtTargetResource.class); @Autowired private TargetManagement targetManagement; @@ -64,18 +66,18 @@ public class TargetResource implements TargetRestApi { private DeploymentManagement deploymentManagement; @Override - public ResponseEntity getTarget(final String targetId) { + public ResponseEntity getTarget(final String targetId) { final Target findTarget = findTargetWithExceptionIfNotFound(targetId); // to single response include poll status - final TargetRest response = TargetMapper.toResponse(findTarget); - TargetMapper.addPollStatus(findTarget, response); - TargetMapper.addTargetLinks(response); + final MgmtTarget response = MgmtTargetMapper.toResponse(findTarget); + MgmtTargetMapper.addPollStatus(findTarget, response); + MgmtTargetMapper.addTargetLinks(response); return new ResponseEntity<>(response, HttpStatus.OK); } @Override - public ResponseEntity> getTargets(final int pagingOffsetParam, final int pagingLimitParam, + public ResponseEntity> getTargets(final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); @@ -95,20 +97,21 @@ public class TargetResource implements TargetRestApi { countTargetsAll = this.targetManagement.countTargetsAll(); } - final List rest = TargetMapper.toResponse(findTargetsAll.getContent()); - return new ResponseEntity<>(new PagedList(rest, countTargetsAll), HttpStatus.OK); + final List rest = MgmtTargetMapper.toResponse(findTargetsAll.getContent()); + return new ResponseEntity<>(new PagedList(rest, countTargetsAll), HttpStatus.OK); } @Override - public ResponseEntity> createTargets(final List targets) { + public ResponseEntity> createTargets(final List targets) { LOG.debug("creating {} targets", targets.size()); - final Iterable createdTargets = this.targetManagement.createTargets(TargetMapper.fromRequest(targets)); + final Iterable createdTargets = this.targetManagement + .createTargets(MgmtTargetMapper.fromRequest(targets)); LOG.debug("{} targets created, return status {}", targets.size(), HttpStatus.CREATED); - return new ResponseEntity<>(TargetMapper.toResponse(createdTargets), HttpStatus.CREATED); + return new ResponseEntity<>(MgmtTargetMapper.toResponse(createdTargets), HttpStatus.CREATED); } @Override - public ResponseEntity updateTarget(final String targetId, final TargetRequestBody targetRest) { + public ResponseEntity updateTarget(final String targetId, final MgmtTargetRequestBody targetRest) { final Target existingTarget = findTargetWithExceptionIfNotFound(targetId); LOG.debug("updating target {}", existingTarget.getId()); if (targetRest.getDescription() != null) { @@ -119,7 +122,7 @@ public class TargetResource implements TargetRestApi { } final Target updateTarget = this.targetManagement.updateTarget(existingTarget); - return new ResponseEntity<>(TargetMapper.toResponse(updateTarget), HttpStatus.OK); + return new ResponseEntity<>(MgmtTargetMapper.toResponse(updateTarget), HttpStatus.OK); } @Override @@ -131,21 +134,21 @@ public class TargetResource implements TargetRestApi { } @Override - public ResponseEntity getAttributes(final String targetId) { + public ResponseEntity getAttributes(final String targetId) { final Target foundTarget = findTargetWithExceptionIfNotFound(targetId); final Map controllerAttributes = foundTarget.getTargetInfo().getControllerAttributes(); if (controllerAttributes.isEmpty()) { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } - final TargetAttributes result = new TargetAttributes(); + final MgmtTargetAttributes result = new MgmtTargetAttributes(); result.putAll(controllerAttributes); return new ResponseEntity<>(result, HttpStatus.OK); } @Override - public ResponseEntity> getActionHistory(final String targetId, final int pagingOffsetParam, + public ResponseEntity> getActionHistory(final String targetId, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { final Target foundTarget = findTargetWithExceptionIfNotFound(targetId); @@ -167,12 +170,12 @@ public class TargetResource implements TargetRestApi { } return new ResponseEntity<>( - new PagedList<>(TargetMapper.toResponse(targetId, activeActions.getContent()), totalActionCount), + new PagedList<>(MgmtTargetMapper.toResponse(targetId, activeActions.getContent()), totalActionCount), HttpStatus.OK); } @Override - public ResponseEntity getAction(final String targetId, final Long actionId) { + public ResponseEntity getAction(final String targetId, final Long actionId) { final Target target = findTargetWithExceptionIfNotFound(targetId); final Action action = findActionWithExceptionIfNotFound(actionId); @@ -181,21 +184,21 @@ public class TargetResource implements TargetRestApi { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } - final ActionRest result = TargetMapper.toResponse(targetId, action, action.isActive()); + final MgmtAction result = MgmtTargetMapper.toResponse(targetId, action, action.isActive()); if (!action.isCancelingOrCanceled()) { result.add(linkTo( - methodOn(DistributionSetRestApi.class).getDistributionSet(action.getDistributionSet().getId())) + methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(action.getDistributionSet().getId())) .withRel("distributionset")); } else if (action.isCancelingOrCanceled()) { - result.add(linkTo(methodOn(TargetRestApi.class).getAction(targetId, action.getId())) - .withRel(RestConstants.TARGET_V1_CANCELED_ACTION)); + result.add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(targetId, action.getId())) + .withRel(MgmtRestConstants.TARGET_V1_CANCELED_ACTION)); } - result.add(linkTo(methodOn(TargetRestApi.class).getActionStatusList(targetId, action.getId(), 0, - RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, + result.add(linkTo(methodOn(MgmtTargetRestApi.class).getActionStatusList(targetId, action.getId(), 0, + MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, ActionStatusFields.ID.getFieldName() + ":" + SortDirection.DESC)) - .withRel(RestConstants.TARGET_V1_ACTION_STATUS)); + .withRel(MgmtRestConstants.TARGET_V1_ACTION_STATUS)); return new ResponseEntity<>(result, HttpStatus.OK); } @@ -212,13 +215,13 @@ public class TargetResource implements TargetRestApi { this.deploymentManagement.cancelAction(action, target); } // both functions will throw an exception, when action is in wrong - // state, which is mapped by ResponseExceptionHandler. + // state, which is mapped by MgmtResponseExceptionHandler. return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @Override - public ResponseEntity> getActionStatusList(final String targetId, final Long actionId, + public ResponseEntity> getActionStatusList(final String targetId, final Long actionId, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { final Target target = findTargetWithExceptionIfNotFound(targetId); @@ -236,15 +239,17 @@ public class TargetResource implements TargetRestApi { final Page statusList = this.deploymentManagement.findActionStatusByAction( new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting), action, true); - return new ResponseEntity<>(new PagedList<>(TargetMapper.toActionStatusRestResponse(statusList.getContent()), - statusList.getTotalElements()), HttpStatus.OK); + return new ResponseEntity<>( + new PagedList<>(MgmtTargetMapper.toActionStatusRestResponse(statusList.getContent()), + statusList.getTotalElements()), + HttpStatus.OK); } @Override - public ResponseEntity getAssignedDistributionSet(final String targetId) { + public ResponseEntity getAssignedDistributionSet(final String targetId) { final Target findTarget = findTargetWithExceptionIfNotFound(targetId); - final DistributionSetRest distributionSetRest = DistributionSetMapper + final MgmtDistributionSet distributionSetRest = MgmtDistributionSetMapper .toResponse(findTarget.getAssignedDistributionSet()); final HttpStatus retStatus; if (distributionSetRest == null) { @@ -257,11 +262,11 @@ public class TargetResource implements TargetRestApi { @Override public ResponseEntity postAssignedDistributionSet(final String targetId, - final DistributionSetAssigmentRest dsId) { + final MgmtDistributionSetAssigment dsId) { findTargetWithExceptionIfNotFound(targetId); - final ActionType type = (dsId.getType() != null) - ? RestResourceConversionHelper.convertActionType(dsId.getType()) : ActionType.FORCED; + final ActionType type = (dsId.getType() != null) ? MgmtRestModelMapper.convertActionType(dsId.getType()) + : ActionType.FORCED; final Iterator changed = this.deploymentManagement .assignDistributionSet(dsId.getId(), type, dsId.getForcetime(), targetId).getAssignedEntity() .iterator(); @@ -276,9 +281,9 @@ public class TargetResource implements TargetRestApi { } @Override - public ResponseEntity getInstalledDistributionSet(final String targetId) { + public ResponseEntity getInstalledDistributionSet(final String targetId) { final Target findTarget = findTargetWithExceptionIfNotFound(targetId); - final DistributionSetRest distributionSetRest = DistributionSetMapper + final MgmtDistributionSet distributionSetRest = MgmtDistributionSetMapper .toResponse(findTarget.getTargetInfo().getInstalledDistributionSet()); final HttpStatus retStatus; if (distributionSetRest == null) { diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java similarity index 69% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java index 1a9155828..d98518208 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java @@ -6,11 +6,19 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import java.util.List; import java.util.stream.Collectors; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtAssignedTargetRequestBody; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut; +import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTargetTagAssigmentResult; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.TagFields; import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.TargetManagement; @@ -19,13 +27,6 @@ import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; -import org.eclipse.hawkbit.rest.resource.api.TargetTagRestApi; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.tag.AssignedTargetRequestBody; -import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut; -import org.eclipse.hawkbit.rest.resource.model.tag.TagRest; -import org.eclipse.hawkbit.rest.resource.model.tag.TargetTagAssigmentResultRest; -import org.eclipse.hawkbit.rest.resource.model.target.TargetRest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -43,8 +44,8 @@ import org.springframework.web.bind.annotation.RestController; * */ @RestController -public class TargetTagResource implements TargetTagRestApi { - private static final Logger LOG = LoggerFactory.getLogger(TargetTagResource.class); +public class MgmtTargetTagResource implements MgmtTargetTagRestApi { + private static final Logger LOG = LoggerFactory.getLogger(MgmtTargetTagResource.class); @Autowired private TagManagement tagManagement; @@ -53,7 +54,7 @@ public class TargetTagResource implements TargetTagRestApi { private TargetManagement targetManagement; @Override - public ResponseEntity> getTargetTags(final int pagingOffsetParam, final int pagingLimitParam, + public ResponseEntity> getTargetTags(final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); @@ -75,35 +76,35 @@ public class TargetTagResource implements TargetTagRestApi { } - final List rest = TagMapper.toResponse(findTargetsAll.getContent()); + final List rest = MgmtTagMapper.toResponse(findTargetsAll.getContent()); return new ResponseEntity<>(new PagedList<>(rest, countTargetsAll), HttpStatus.OK); } @Override - public ResponseEntity getTargetTag(final Long targetTagId) { + public ResponseEntity getTargetTag(final Long targetTagId) { final TargetTag tag = findTargetTagById(targetTagId); - return new ResponseEntity<>(TagMapper.toResponse(tag), HttpStatus.OK); + return new ResponseEntity<>(MgmtTagMapper.toResponse(tag), HttpStatus.OK); } @Override - public ResponseEntity> createTargetTags(@RequestBody final List tags) { + public ResponseEntity> createTargetTags(@RequestBody final List tags) { LOG.debug("creating {} target tags", tags.size()); final List createdTargetTags = this.tagManagement - .createTargetTags(TagMapper.mapTargeTagFromRequest(tags)); - return new ResponseEntity<>(TagMapper.toResponse(createdTargetTags), HttpStatus.CREATED); + .createTargetTags(MgmtTagMapper.mapTargeTagFromRequest(tags)); + return new ResponseEntity<>(MgmtTagMapper.toResponse(createdTargetTags), HttpStatus.CREATED); } @Override - public ResponseEntity updateTagretTag(final Long targetTagId, final TagRequestBodyPut restTargetTagRest) { + public ResponseEntity updateTagretTag(final Long targetTagId, final MgmtTagRequestBodyPut restTargetTagRest) { LOG.debug("update {} target tag", restTargetTagRest); final TargetTag targetTag = findTargetTagById(targetTagId); - TagMapper.updateTag(restTargetTagRest, targetTag); + MgmtTagMapper.updateTag(restTargetTagRest, targetTag); final TargetTag updateTargetTag = this.tagManagement.updateTargetTag(targetTag); LOG.debug("target tag updated"); - return new ResponseEntity<>(TagMapper.toResponse(updateTargetTag), HttpStatus.OK); + return new ResponseEntity<>(MgmtTagMapper.toResponse(updateTargetTag), HttpStatus.OK); } @Override @@ -117,35 +118,35 @@ public class TargetTagResource implements TargetTagRestApi { } @Override - public ResponseEntity> getAssignedTargets(final Long targetTagId) { + public ResponseEntity> getAssignedTargets(final Long targetTagId) { final TargetTag targetTag = findTargetTagById(targetTagId); - return new ResponseEntity<>(TargetMapper.toResponseWithLinksAndPollStatus(targetTag.getAssignedToTargets()), + return new ResponseEntity<>(MgmtTargetMapper.toResponseWithLinksAndPollStatus(targetTag.getAssignedToTargets()), HttpStatus.OK); } @Override - public ResponseEntity toggleTagAssignment(final Long targetTagId, - final List assignedTargetRequestBodies) { + public ResponseEntity toggleTagAssignment(final Long targetTagId, + final List assignedTargetRequestBodies) { LOG.debug("Toggle Target assignment {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId); final TargetTag targetTag = findTargetTagById(targetTagId); final TargetTagAssignmentResult assigmentResult = this.targetManagement .toggleTagAssignment(findTargetControllerIds(assignedTargetRequestBodies), targetTag.getName()); - final TargetTagAssigmentResultRest tagAssigmentResultRest = new TargetTagAssigmentResultRest(); - tagAssigmentResultRest.setAssignedTargets(TargetMapper.toResponse(assigmentResult.getAssignedEntity())); - tagAssigmentResultRest.setUnassignedTargets(TargetMapper.toResponse(assigmentResult.getUnassignedEntity())); + final MgmtTargetTagAssigmentResult tagAssigmentResultRest = new MgmtTargetTagAssigmentResult(); + tagAssigmentResultRest.setAssignedTargets(MgmtTargetMapper.toResponse(assigmentResult.getAssignedEntity())); + tagAssigmentResultRest.setUnassignedTargets(MgmtTargetMapper.toResponse(assigmentResult.getUnassignedEntity())); return new ResponseEntity<>(tagAssigmentResultRest, HttpStatus.OK); } @Override - public ResponseEntity> assignTargets(final Long targetTagId, - final List assignedTargetRequestBodies) { + public ResponseEntity> assignTargets(final Long targetTagId, + final List assignedTargetRequestBodies) { LOG.debug("Assign Targets {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId); final TargetTag targetTag = findTargetTagById(targetTagId); final List assignedTarget = this.targetManagement .assignTag(findTargetControllerIds(assignedTargetRequestBodies), targetTag); - return new ResponseEntity<>(TargetMapper.toResponseWithLinksAndPollStatus(assignedTarget), HttpStatus.OK); + return new ResponseEntity<>(MgmtTargetMapper.toResponseWithLinksAndPollStatus(assignedTarget), HttpStatus.OK); } @Override @@ -176,7 +177,7 @@ public class TargetTagResource implements TargetTagRestApi { return tag; } - private List findTargetControllerIds(final List assignedTargetRequestBodies) { + private List findTargetControllerIds(final List assignedTargetRequestBodies) { return assignedTargetRequestBodies.stream().map(request -> request.getControllerId()) .collect(Collectors.toList()); } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/PagingUtility.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/PagingUtility.java similarity index 91% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/PagingUtility.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/PagingUtility.java index ac45796e5..abd9e9ec4 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/PagingUtility.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/PagingUtility.java @@ -6,8 +6,9 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.ActionFields; import org.eclipse.hawkbit.repository.ActionStatusFields; import org.eclipse.hawkbit.repository.DistributionSetFields; @@ -19,6 +20,7 @@ import org.eclipse.hawkbit.repository.SoftwareModuleFields; import org.eclipse.hawkbit.repository.SoftwareModuleMetadataFields; import org.eclipse.hawkbit.repository.SoftwareModuleTypeFields; import org.eclipse.hawkbit.repository.TargetFields; +import org.eclipse.hawkbit.rest.util.SortUtility; import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Direction; @@ -35,16 +37,16 @@ public final class PagingUtility { static int sanitizeOffsetParam(final int offset) { if (offset < 0) { - return Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET); + return Integer.parseInt(MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET); } return offset; } static int sanitizePageLimitParam(final int pageLimit) { if (pageLimit < 1) { - return Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT); - } else if (pageLimit > RestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT) { - return RestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT; + return Integer.parseInt(MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT); + } else if (pageLimit > MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT) { + return MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT; } return pageLimit; } diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/JsonBuilder.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/JsonBuilder.java new file mode 100644 index 000000000..5a9f2785a --- /dev/null +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/JsonBuilder.java @@ -0,0 +1,466 @@ +/** + * 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.mgmt.rest.resource; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.apache.commons.lang3.RandomStringUtils; +import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.DistributionSetType; +import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupConditions; +import org.eclipse.hawkbit.repository.model.SoftwareModule; +import org.eclipse.hawkbit.repository.model.SoftwareModuleType; +import org.eclipse.hawkbit.repository.model.Target; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +/** + * Builder class for building certain json strings. + * + * + * + */ +public abstract class JsonBuilder { + + public static String softwareModules(final List modules) throws JSONException { + final StringBuilder builder = new StringBuilder(); + + builder.append("["); + int i = 0; + for (final SoftwareModule module : modules) { + try { + builder.append(new JSONObject().put("name", module.getName()) + .put("description", module.getDescription()).put("type", module.getType().getKey()) + .put("id", Long.MAX_VALUE).put("vendor", module.getVendor()) + .put("version", module.getVersion()).put("createdAt", "0").put("updatedAt", "0") + .put("createdBy", "fghdfkjghdfkjh").put("updatedBy", "fghdfkjghdfkjh").toString()); + } catch (final Exception e) { + e.printStackTrace(); + } + + if (++i < modules.size()) { + builder.append(","); + } + } + + builder.append("]"); + + return builder.toString(); + + } + + public static String softwareModulesCreatableFieldsOnly(final List modules) throws JSONException { + final StringBuilder builder = new StringBuilder(); + + builder.append("["); + int i = 0; + for (final SoftwareModule module : modules) { + try { + builder.append(new JSONObject().put("name", module.getName()) + .put("description", module.getDescription()).put("type", module.getType().getKey()) + .put("vendor", module.getVendor()).put("version", module.getVersion()).toString()); + } catch (final Exception e) { + e.printStackTrace(); + } + + if (++i < modules.size()) { + builder.append(","); + } + } + + builder.append("]"); + + return builder.toString(); + + } + + public static String softwareModuleUpdatableFieldsOnly(final SoftwareModule module) throws JSONException { + final StringBuilder builder = new StringBuilder(); + + builder.append(new JSONObject().put("description", module.getDescription()).put("vendor", module.getVendor()) + .toString()); + + return builder.toString(); + + } + + public static String softwareModuleTypes(final List types) throws JSONException { + final StringBuilder builder = new StringBuilder(); + + builder.append("["); + int i = 0; + for (final SoftwareModuleType module : types) { + try { + builder.append(new JSONObject().put("name", module.getName()) + .put("description", module.getDescription()).put("id", Long.MAX_VALUE) + .put("key", module.getKey()).put("maxAssignments", module.getMaxAssignments()) + .put("createdAt", "0").put("updatedAt", "0").put("createdBy", "fghdfkjghdfkjh") + .put("updatedBy", "fghdfkjghdfkjh").toString()); + } catch (final Exception e) { + e.printStackTrace(); + } + + if (++i < types.size()) { + builder.append(","); + } + } + + builder.append("]"); + + return builder.toString(); + + } + + public static String softwareModuleTypesCreatableFieldsOnly(final List types) + throws JSONException { + final StringBuilder builder = new StringBuilder(); + + builder.append("["); + int i = 0; + for (final SoftwareModuleType module : types) { + try { + builder.append(new JSONObject().put("name", module.getName()) + .put("description", module.getDescription()).put("key", module.getKey()) + .put("maxAssignments", module.getMaxAssignments()).toString()); + } catch (final Exception e) { + e.printStackTrace(); + } + + if (++i < types.size()) { + builder.append(","); + } + } + + builder.append("]"); + + return builder.toString(); + + } + + /** + * builds a json string for the feedback for the execution "proceeding". + * + * @param id + * of the Action feedback refers to + * @return the built string + * @throws JSONException + */ + public static String deploymentActionInProgressFeedback(final String id) throws JSONException { + return deploymentActionFeedback(id, "proceeding"); + } + + /** + * builds a certain json string for a action feedback. + * + * @param id + * of the action the feedback refers to + * @param execution + * see ExecutionStatus + * @return the build json string + * @throws JSONException + */ + public static String deploymentActionFeedback(final String id, final String execution) throws JSONException { + return deploymentActionFeedback(id, execution, "none", RandomStringUtils.randomAscii(1000)); + + } + + public static String deploymentActionFeedback(final String id, final String execution, final String message) + throws JSONException { + return deploymentActionFeedback(id, execution, "none", message); + + } + + public static String deploymentActionFeedback(final String id, final String execution, final String finished, + final String message) throws JSONException { + final List messages = new ArrayList(); + messages.add(message); + + return new JSONObject() + .put("id", id) + .put("time", "20140511T121314") + .put("status", + new JSONObject() + .put("execution", execution) + .put("result", + new JSONObject().put("finished", finished).put("progress", + new JSONObject().put("cnt", 2).put("of", 5))).put("details", messages)) + .toString(); + + } + + /** + * @param types + * @return + */ + public static String distributionSetTypes(final List types) { + final StringBuilder builder = new StringBuilder(); + + builder.append("["); + int i = 0; + for (final DistributionSetType module : types) { + + try { + + final JSONArray osmTypes = new JSONArray(); + module.getOptionalModuleTypes().forEach(smt -> osmTypes.put(new JSONObject().put("id", smt.getId()))); + + final JSONArray msmTypes = new JSONArray(); + module.getMandatoryModuleTypes().forEach(smt -> msmTypes.put(new JSONObject().put("id", smt.getId()))); + + builder.append(new JSONObject().put("name", module.getName()) + .put("description", module.getDescription()).put("id", Long.MAX_VALUE) + .put("key", module.getKey()).put("createdAt", "0").put("updatedAt", "0") + .put("createdBy", "fghdfkjghdfkjh").put("optionalmodules", osmTypes) + .put("mandatorymodules", msmTypes).put("updatedBy", "fghdfkjghdfkjh").toString()); + } catch (final Exception e) { + e.printStackTrace(); + } + + if (++i < types.size()) { + builder.append(","); + } + } + + builder.append("]"); + + return builder.toString(); + } + + public static String distributionSetTypesCreateValidFieldsOnly(final List types) { + final StringBuilder builder = new StringBuilder(); + + builder.append("["); + int i = 0; + for (final DistributionSetType module : types) { + + try { + + final JSONArray osmTypes = new JSONArray(); + module.getOptionalModuleTypes().forEach(smt -> osmTypes.put(new JSONObject().put("id", smt.getId()))); + + final JSONArray msmTypes = new JSONArray(); + module.getMandatoryModuleTypes().forEach(smt -> msmTypes.put(new JSONObject().put("id", smt.getId()))); + + builder.append(new JSONObject().put("name", module.getName()) + .put("description", module.getDescription()).put("key", module.getKey()) + .put("optionalmodules", osmTypes).put("mandatorymodules", msmTypes).toString()); + } catch (final Exception e) { + e.printStackTrace(); + } + + if (++i < types.size()) { + builder.append(","); + } + } + + builder.append("]"); + + return builder.toString(); + } + + public static String distributionSets(final List sets) throws JSONException { + final StringBuilder builder = new StringBuilder(); + + builder.append("["); + int i = 0; + for (final DistributionSet set : sets) { + try { + builder.append(distributionSet(set)); + } catch (final Exception e) { + e.printStackTrace(); + } + + if (++i < sets.size()) { + builder.append(","); + } + } + + builder.append("]"); + + return builder.toString(); + + } + + public static String distributionSetsCreateValidFieldsOnly(final List sets) throws JSONException { + final StringBuilder builder = new StringBuilder(); + + builder.append("["); + int i = 0; + for (final DistributionSet set : sets) { + try { + builder.append(distributionSetCreateValidFieldsOnly(set)); + } catch (final Exception e) { + e.printStackTrace(); + } + + if (++i < sets.size()) { + builder.append(","); + } + } + + builder.append("]"); + + return builder.toString(); + + } + + public static String distributionSetCreateValidFieldsOnly(final DistributionSet set) throws JSONException { + + final List modules = set.getModules().stream().map(module -> { + try { + return new JSONObject().put("id", module.getId()); + } catch (final Exception e) { + e.printStackTrace(); + } + + return null; + }).collect(Collectors.toList()); + + return new JSONObject().put("name", set.getName()).put("description", set.getDescription()) + .put("type", set.getType() == null ? null : set.getType().getKey()).put("version", set.getVersion()) + .put("requiredMigrationStep", set.isRequiredMigrationStep()).put("modules", modules).toString(); + + } + + public static String distributionSetUpdateValidFieldsOnly(final DistributionSet set) throws JSONException { + + final List modules = set.getModules().stream().map(module -> { + try { + return new JSONObject().put("id", module.getId()); + } catch (final Exception e) { + e.printStackTrace(); + } + + return null; + }).collect(Collectors.toList()); + + return new JSONObject().put("name", set.getName()).put("description", set.getDescription()) + .put("version", set.getVersion()).toString(); + + } + + public static String distributionSet(final DistributionSet set) throws JSONException { + + final List modules = set.getModules().stream().map(module -> { + try { + return new JSONObject().put("id", module.getId()); + } catch (final Exception e) { + e.printStackTrace(); + } + + return null; + }).collect(Collectors.toList()); + + return new JSONObject().put("name", set.getName()).put("description", set.getDescription()) + .put("type", set.getType() == null ? null : set.getType().getKey()).put("id", Long.MAX_VALUE) + .put("version", set.getVersion()).put("createdAt", "0").put("updatedAt", "0") + .put("createdBy", "fghdfkjghdfkjh").put("updatedBy", "fghdfkjghdfkjh") + .put("requiredMigrationStep", set.isRequiredMigrationStep()).put("modules", modules).toString(); + + } + + /** + * @param targets + * @return + */ + public static String targets(final List targets) { + final StringBuilder builder = new StringBuilder(); + + builder.append("["); + int i = 0; + for (final Target target : targets) { + try { + builder.append(new JSONObject().put("controllerId", target.getControllerId()) + .put("description", target.getDescription()).put("name", target.getName()) + .put("createdAt", "0").put("updatedAt", "0").put("createdBy", "fghdfkjghdfkjh") + .put("updatedBy", "fghdfkjghdfkjh").toString()); + } catch (final Exception e) { + e.printStackTrace(); + } + + if (++i < targets.size()) { + builder.append(","); + } + } + + builder.append("]"); + + return builder.toString(); + } + + public static String rollout(final String name, final String description, final int groupSize, + final long distributionSetId, final String targetFilterQuery, final RolloutGroupConditions conditions) { + final JSONObject json = new JSONObject(); + json.put("name", name); + json.put("description", description); + json.put("amountGroups", groupSize); + json.put("distributionSetId", distributionSetId); + json.put("targetFilterQuery", targetFilterQuery); + + if (conditions != null) { + final JSONObject successCondition = new JSONObject(); + json.put("successCondition", successCondition); + successCondition.put("condition", conditions.getSuccessCondition().toString()); + successCondition.put("expression", conditions.getSuccessConditionExp().toString()); + + final JSONObject successAction = new JSONObject(); + json.put("successAction", successAction); + successAction.put("action", conditions.getSuccessAction().toString()); + successAction.put("expression", conditions.getSuccessActionExp().toString()); + + final JSONObject errorCondition = new JSONObject(); + json.put("errorCondition", errorCondition); + errorCondition.put("condition", conditions.getErrorCondition().toString()); + errorCondition.put("expression", conditions.getErrorConditionExp().toString()); + + final JSONObject errorAction = new JSONObject(); + json.put("errorAction", errorAction); + errorAction.put("action", conditions.getErrorAction().toString()); + errorAction.put("expression", conditions.getErrorActionExp().toString()); + } + + return json.toString(); + } + + public static String cancelActionFeedback(final String id, final String execution) throws JSONException { + return cancelActionFeedback(id, execution, RandomStringUtils.randomAscii(1000)); + + } + + public static String cancelActionFeedback(final String id, final String execution, final String message) + throws JSONException { + final List messages = new ArrayList(); + messages.add(message); + return new JSONObject() + .put("id", id) + .put("time", "20140511T121314") + .put("status", + new JSONObject().put("execution", execution) + .put("result", new JSONObject().put("finished", "success")).put("details", messages)) + .toString(); + + } + + public static String configData(final String id, final Map attributes, final String execution) + throws JSONException { + return new JSONObject() + .put("id", id) + .put("time", "20140511T121314") + .put("status", + new JSONObject().put("execution", execution) + .put("result", new JSONObject().put("finished", "success")) + .put("details", new ArrayList())).put("data", attributes).toString(); + + } + +} diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java similarity index 92% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java rename to hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java index 6254da992..b7839f7f6 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; @@ -27,9 +27,9 @@ import java.util.List; import java.util.Set; import org.eclipse.hawkbit.AbstractIntegrationTest; -import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.WithUser; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.ActionRepository; import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement; @@ -60,7 +60,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @Features("Component Tests - Management API") @Stories("Distribution Set Resource") -public class DistributionSetResourceTest extends AbstractIntegrationTest { +public class MgmtDistributionSetResourceTest extends AbstractIntegrationTest { @Test @Description("This test verifies the call of all Software Modules that are assiged to a Distribution Set through the RESTful API.") @@ -68,7 +68,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { // Create DistributionSet with three software modules final DistributionSet set = TestDataUtil.generateDistributionSet("SMTest", softwareManagement, distributionSetManagement); - mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(set.getModules().size()))); } @@ -89,7 +89,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { smList.put(new JSONObject().put("id", Long.valueOf(smID))); } // post assignment - mvc.perform(post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") + mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") .contentType(MediaType.APPLICATION_JSON).content(smList.toString())).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); @@ -101,18 +101,19 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { list.put(new JSONObject().put("id", Long.valueOf(targetId))); } deploymentManagement.assignDistributionSet(disSet.getId(), knownTargetIds[0]); - mvc.perform(post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets") - .contentType(MediaType.APPLICATION_JSON).content(list.toString())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) + mvc.perform( + post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets") + .contentType(MediaType.APPLICATION_JSON).content(list.toString())) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) .andExpect(jsonPath("$.total", equalTo(knownTargetIds.length))); // try to delete the Software Module from DistSet that has been assigned // to the target. - mvc.perform(delete( - RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM/" + smIDs.get(0)) - .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isLocked()) + mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM/" + + smIDs.get(0)).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isLocked()) .andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.entitiylocked"))); } @@ -132,7 +133,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { smList.put(new JSONObject().put("id", Long.valueOf(smID))); } // post assignment - mvc.perform(post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") + mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") .contentType(MediaType.APPLICATION_JSON).content(smList.toString())).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); @@ -145,9 +146,11 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } // assign DisSet to target and test assignment deploymentManagement.assignDistributionSet(disSet.getId(), knownTargetIds[0]); - mvc.perform(post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets") - .contentType(MediaType.APPLICATION_JSON).content(list.toString())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) + mvc.perform( + post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets") + .contentType(MediaType.APPLICATION_JSON).content(list.toString())) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) .andExpect(jsonPath("$.total", equalTo(knownTargetIds.length))); @@ -161,7 +164,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { smList2.put(new JSONObject().put("id", Long.valueOf(smID))); } - mvc.perform(post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") + mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") .contentType(MediaType.APPLICATION_JSON).content(smList2.toString())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isLocked()) .andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.entitiylocked"))); @@ -175,7 +178,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { final DistributionSet disSet = TestDataUtil.generateDistributionSetWithNoSoftwareModules("Jupiter", "398,88", distributionSetManagement); // Test if size is 0 - mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(disSet.getModules().size()))); // create Software Modules @@ -194,11 +197,11 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { list.put(new JSONObject().put("id", Long.valueOf(smID))); } // post assignment - mvc.perform(post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") + mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") .contentType(MediaType.APPLICATION_JSON).content(list.toString())).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // Test if size is 3 - mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(smIDs.size()))); } @@ -211,16 +214,16 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { final DistributionSet set = TestDataUtil.generateDistributionSet("Venus", softwareManagement, distributionSetManagement); int amountOfSM = set.getModules().size(); - mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(amountOfSM))); // test the removal of all software modules one by one for (final Iterator iter = set.getModules().iterator(); iter.hasNext();) { final Long smId = iter.next().getId(); mvc.perform(delete( - RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM/" + smId)) + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM/" + smId)) .andExpect(status().isOk()); - mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(--amountOfSM))); } @@ -242,8 +245,8 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { // assign already one target to DS deploymentManagement.assignDistributionSet(createdDs.getId(), knownTargetIds[0]); - mvc.perform( - post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets") + mvc.perform(post( + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets") .contentType(MediaType.APPLICATION_JSON).content(list.toString())) .andExpect(status().isOk()).andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) @@ -263,8 +266,8 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { targetManagement.createTarget(new Target(knownTargetId)); deploymentManagement.assignDistributionSet(createdDs.getId(), knownTargetId); - mvc.perform( - get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")) + mvc.perform(get( + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")) .andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(1))) .andExpect(jsonPath("$.content[0].controllerId", equalTo(knownTargetId))); } @@ -274,8 +277,8 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { public void getAssignedTargetsOfDistributionSetIsEmpty() throws Exception { final Set createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1); final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next(); - mvc.perform( - get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")) + mvc.perform(get( + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")) .andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(0))) .andExpect(jsonPath("$.total", equalTo(0))); } @@ -297,8 +300,8 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { sendUpdateActionStatusToTargets(controllerManagament, targetManagement, actionRepository, createdDs, Lists.newArrayList(createTarget), Status.FINISHED, "some message"); - mvc.perform( - get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/installedTargets")) + mvc.perform(get( + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/installedTargets")) .andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(1))) .andExpect(jsonPath("$.content[0].controllerId", equalTo(knownTargetId))); } @@ -308,11 +311,11 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { public void getDistributionSetsWithoutAddtionalRequestParameters() throws Exception { final int sets = 5; createDistributionSetsAlphabetical(sets); - mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(sets))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(sets))); + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(sets))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(sets))); } @Test @@ -321,12 +324,12 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { final int sets = 5; final int limitSize = 1; createDistributionSetsAlphabetical(sets); - mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); } @Test @@ -336,13 +339,13 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { final int offsetParam = 2; final int expectedSize = sets - offsetParam; createDistributionSetsAlphabetical(sets); - mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) - .param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(sets))) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(sets))) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); } @Test @@ -825,9 +828,9 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { final String rsqlFindTargetId1 = "controllerId==1"; - mvc.perform( - get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets?q=" - + rsqlFindTargetId1).contentType(MediaType.APPLICATION_JSON).content(list.toString())) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + + "/assignedTargets?q=" + rsqlFindTargetId1).contentType(MediaType.APPLICATION_JSON) + .content(list.toString())) .andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) .andExpect(jsonPath("size", equalTo(1))).andExpect(jsonPath("content[0].controllerId", equalTo("1"))); } diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java similarity index 94% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResourceTest.java rename to hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java index 9f3d2a89d..b2f309995 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; @@ -24,8 +24,8 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.hawkbit.AbstractIntegrationTest; -import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.WithUser; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModule; @@ -44,12 +44,12 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; /** - * Test for {@link DistributionSetTypeResource}. + * Test for {@link MgmtDistributionSetTypeResource}. * */ @Features("Component Tests - Management API") @Stories("Distribution Set Type Resource") -public class DistributionSetTypeResourceTest extends AbstractIntegrationTest { +public class MgmtDistributionSetTypeResourceTest extends AbstractIntegrationTest { @Test @WithUser(principal = "uploadTester", allSpPermissions = true) @@ -101,7 +101,7 @@ public class DistributionSetTypeResourceTest extends AbstractIntegrationTest { // descending mvc.perform(get("/rest/v1/distributionsettypes").accept(MediaType.APPLICATION_JSON) - .param(RestConstants.REQUEST_PARAMETER_SORTING, "KEY:DESC")).andDo(MockMvcResultPrinter.print()) + .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "KEY:DESC")).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$content.[0].id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$content.[0].name", equalTo("TestName123"))) @@ -114,7 +114,7 @@ public class DistributionSetTypeResourceTest extends AbstractIntegrationTest { // ascending mvc.perform(get("/rest/v1/distributionsettypes").accept(MediaType.APPLICATION_JSON) - .param(RestConstants.REQUEST_PARAMETER_SORTING, "KEY:ASC")).andDo(MockMvcResultPrinter.print()) + .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "KEY:ASC")).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$content.[3].id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$content.[3].name", equalTo("TestName123"))) @@ -439,11 +439,11 @@ public class DistributionSetTypeResourceTest extends AbstractIntegrationTest { @Description("Checks the correct behaviour of /rest/v1/distributionsettypes GET requests with paging.") public void getDistributionSetTypesWithoutAddtionalRequestParameters() throws Exception { final int types = 3; - mvc.perform(get(RestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(types))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(types))); + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(types))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(types))); } @Test @@ -451,12 +451,12 @@ public class DistributionSetTypeResourceTest extends AbstractIntegrationTest { public void getDistributionSetTypesWithPagingLimitRequestParameter() throws Exception { final int types = 3; final int limitSize = 1; - mvc.perform(get(RestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); } @Test @@ -465,13 +465,13 @@ public class DistributionSetTypeResourceTest extends AbstractIntegrationTest { final int types = 3; final int offsetParam = 2; final int expectedSize = types - offsetParam; - mvc.perform(get(RestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) - .param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(types))) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(types))) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); } @Test diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DownloadResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadResourceTest.java similarity index 84% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DownloadResourceTest.java rename to hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadResourceTest.java index ee0fa52fe..2311b098c 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DownloadResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadResourceTest.java @@ -6,17 +6,17 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB; -import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.cache.CacheConstants; import org.eclipse.hawkbit.cache.DownloadArtifactCache; import org.eclipse.hawkbit.cache.DownloadType; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.SoftwareModule; @@ -32,7 +32,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @Features("Component Tests - Management API") @Stories("Download Resource") -public class DownloadResourceTest extends AbstractIntegrationTestWithMongoDB { +public class MgmtDownloadResourceTest extends AbstractIntegrationTestWithMongoDB { @Autowired @Qualifier(CacheConstants.DOWNLOAD_ID_CACHE) @@ -58,7 +58,7 @@ public class DownloadResourceTest extends AbstractIntegrationTestWithMongoDB { @Description("This test verifies the call of download artifact without a valid download id fails.") public void testNoDownloadIdAvailable() throws Exception { mvc.perform( - get(RestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE + RestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING, + get(MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE + MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING, downloadIdNotAvailable)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); @@ -68,13 +68,13 @@ public class DownloadResourceTest extends AbstractIntegrationTestWithMongoDB { @Description("This test verifies the call of download artifact works and the download id will be removed.") public void testDownload() throws Exception { mvc.perform( - get(RestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE + RestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING, + get(MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE + MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING, downloadIdSha1)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); // because cache is empty mvc.perform( - get(RestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE + RestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING, + get(MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE + MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING, downloadIdSha1)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java similarity index 96% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java rename to hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java index f27eb5186..f33ceb942 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; import static org.hamcrest.Matchers.equalTo; @@ -22,9 +22,10 @@ import java.util.List; import java.util.concurrent.Callable; import org.eclipse.hawkbit.AbstractIntegrationTest; -import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.WithUser; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.resource.MgmtRolloutResource; import org.eclipse.hawkbit.repository.RolloutGroupManagement; import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; @@ -45,11 +46,11 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; /** - * Tests for covering the {@link RolloutResource}. + * Tests for covering the {@link MgmtRolloutResource}. */ @Features("Component Tests - Management API") @Stories("Rollout Resource") -public class RolloutResourceTest extends AbstractIntegrationTest { +public class MgmtRolloutResourceTest extends AbstractIntegrationTest { @Autowired private RolloutManagement rolloutManagement; @@ -449,7 +450,7 @@ public class RolloutResourceTest extends AbstractIntegrationTest { // starting rollout mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId()) - .param(RestConstants.REQUEST_PARAMETER_ASYNC, "true")).andDo(MockMvcResultPrinter.print()) + .param(MgmtRestConstants.REQUEST_PARAMETER_ASYNC, "true")).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // check if running @@ -477,18 +478,18 @@ public class RolloutResourceTest extends AbstractIntegrationTest { createRollout("rollout3", 5, dsA.getId(), "controllerId==rollout3*"); createRollout("other1", 5, dsA.getId(), "controllerId==other1*"); - mvc.perform(get("/rest/v1/rollouts").param(RestConstants.REQUEST_PARAMETER_SEARCH, "name==*2")) + mvc.perform(get("/rest/v1/rollouts").param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==*2")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$content", hasSize(1))).andExpect(jsonPath("$total", equalTo(1))) .andExpect(jsonPath("$content[0].name", equalTo(rollout2.getName()))); - mvc.perform(get("/rest/v1/rollouts").param(RestConstants.REQUEST_PARAMETER_SEARCH, "name==rollout*")) + mvc.perform(get("/rest/v1/rollouts").param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==rollout*")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$content", hasSize(3))).andExpect(jsonPath("$total", equalTo(3))); - mvc.perform(get("/rest/v1/rollouts").param(RestConstants.REQUEST_PARAMETER_SEARCH, "name==*1")) + mvc.perform(get("/rest/v1/rollouts").param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==*1")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$content", hasSize(2))).andExpect(jsonPath("$total", equalTo(2))); @@ -509,18 +510,18 @@ public class RolloutResourceTest extends AbstractIntegrationTest { // retrieve rollout groups from created rollout mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups", rollout.getId()) - .param(RestConstants.REQUEST_PARAMETER_SEARCH, "name==group-1")).andDo(MockMvcResultPrinter.print()) + .param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==group-1")).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$content", hasSize(1))).andExpect(jsonPath("$total", equalTo(1))) .andExpect(jsonPath("$content[0].name", equalTo("group-1"))); mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups", rollout.getId()) - .param(RestConstants.REQUEST_PARAMETER_SEARCH, "name==group*")).andDo(MockMvcResultPrinter.print()) + .param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==group*")).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$content", hasSize(4))).andExpect(jsonPath("$total", equalTo(4))); mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups", rollout.getId()) - .param(RestConstants.REQUEST_PARAMETER_SEARCH, "name==group-1,name==group-2")) + .param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==group-1,name==group-2")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$content", hasSize(2))).andExpect(jsonPath("$total", equalTo(2))); diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java similarity index 96% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java rename to hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java index 1d2222c9a..f6a945a29 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; @@ -34,10 +34,11 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.RandomStringUtils; import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB; import org.eclipse.hawkbit.HashGeneratorUtils; -import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.WithUser; import org.eclipse.hawkbit.exception.SpServerError; +import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.DistributionSet; @@ -45,8 +46,7 @@ import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey; -import org.eclipse.hawkbit.rest.resource.model.ExceptionInfo; -import org.eclipse.hawkbit.rest.resource.model.artifact.ArtifactRest; +import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -64,12 +64,12 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; /** - * Tests for {@link SoftwareModuleResource} {@link RestController}. + * Tests for {@link MgmtSoftwareModuleResource} {@link RestController}. * */ @Features("Component Tests - Management API") @Stories("Software Module Resource") -public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongoDB { +public class MgmtSoftwareModuleResourceTest extends AbstractIntegrationTestWithMongoDB { @Before public void assertPreparationOfRepo() { @@ -142,7 +142,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo .andExpect(jsonPath("$providedFilename", equalTo("origFilename"))).andReturn(); // check rest of response compared to DB - final ArtifactRest artResult = ResourceUtility + final MgmtArtifact artResult = ResourceUtility .convertArtifactResponse(mvcResult.getResponse().getContentAsString()); final Long artId = ((LocalArtifact) softwareManagement.findSoftwareModuleWithDetails(sm.getId()).getArtifacts() .get(0)).getId(); @@ -473,11 +473,11 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo public void getSoftwareModulesWithoutAddtionalRequestParameters() throws Exception { final int modules = 5; createSoftwareModulesAlphabetical(modules); - mvc.perform(get(RestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(modules))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(modules))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(modules))); + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(modules))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(modules))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(modules))); } @Test @@ -486,12 +486,12 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo final int modules = 5; final int limitSize = 1; createSoftwareModulesAlphabetical(modules); - mvc.perform(get(RestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) + mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(modules))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(modules))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); } @Test @@ -501,13 +501,13 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo final int offsetParam = 2; final int expectedSize = modules - offsetParam; createSoftwareModulesAlphabetical(modules); - mvc.perform(get(RestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) - .param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(modules))) + mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(modules))) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(modules))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(modules))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); } @Test diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java similarity index 91% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResourceTest.java rename to hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java index a85e25bed..d8d113fbc 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; @@ -24,8 +24,8 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.hawkbit.AbstractIntegrationTest; -import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.WithUser; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.json.JSONException; @@ -41,12 +41,12 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; /** - * Test for {@link SoftwareModuleTypeResource}. + * Test for {@link MgmtSoftwareModuleTypeResource}. * */ @Features("Component Tests - Management API") @Stories("Software Module Type Resource") -public class SoftwareModuleTypeResourceTest extends AbstractIntegrationTest { +public class MgmtSoftwareModuleTypeResourceTest extends AbstractIntegrationTest { @Test @WithUser(principal = "uploadTester", allSpPermissions = true) @@ -101,7 +101,7 @@ public class SoftwareModuleTypeResourceTest extends AbstractIntegrationTest { // descending mvc.perform(get("/rest/v1/softwaremoduletypes").accept(MediaType.APPLICATION_JSON) - .param(RestConstants.REQUEST_PARAMETER_SORTING, "MAXASSIGNMENTS:DESC")) + .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "MAXASSIGNMENTS:DESC")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$content.[0].id", equalTo(testType.getId().intValue()))) @@ -116,7 +116,7 @@ public class SoftwareModuleTypeResourceTest extends AbstractIntegrationTest { // ascending mvc.perform(get("/rest/v1/softwaremoduletypes").accept(MediaType.APPLICATION_JSON) - .param(RestConstants.REQUEST_PARAMETER_SORTING, "MAXASSIGNMENTS:ASC")) + .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "MAXASSIGNMENTS:ASC")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$content.[3].id", equalTo(testType.getId().intValue()))) @@ -252,11 +252,11 @@ public class SoftwareModuleTypeResourceTest extends AbstractIntegrationTest { @Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes GET requests with paging.") public void getSoftwareModuleTypesWithoutAddtionalRequestParameters() throws Exception { final int types = 3; - mvc.perform(get(RestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(types))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(types))); + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(types))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(types))); } @Test @@ -264,12 +264,12 @@ public class SoftwareModuleTypeResourceTest extends AbstractIntegrationTest { public void getSoftwareModuleTypesWithPagingLimitRequestParameter() throws Exception { final int types = 3; final int limitSize = 1; - mvc.perform(get(RestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) + mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); } @Test @@ -278,13 +278,13 @@ public class SoftwareModuleTypeResourceTest extends AbstractIntegrationTest { final int types = 3; final int offsetParam = 2; final int expectedSize = types - offsetParam; - mvc.perform(get(RestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) - .param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(types))) + mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(types))) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) + .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); } @Test diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java similarity index 84% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java rename to hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java index 8d27d5114..6954aee31 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; @@ -30,11 +30,11 @@ import java.util.Map; import java.util.stream.Collectors; import org.eclipse.hawkbit.AbstractIntegrationTest; -import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.WithUser; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.im.authentication.SpPermission; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.ActionFields; import org.eclipse.hawkbit.repository.ActionStatusFields; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; @@ -46,7 +46,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetInfo; -import org.eclipse.hawkbit.rest.resource.model.ExceptionInfo; +import org.eclipse.hawkbit.rest.exception.MessageNotReadableException; +import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.eclipse.hawkbit.util.IpUtil; import org.json.JSONException; import org.json.JSONObject; @@ -68,12 +69,12 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; /** - * Spring MVC Tests against the TargetResource. + * Spring MVC Tests against the MgmtTargetResource. * */ @Features("Component Tests - Management API") @Stories("Target Resource") -public class TargetResourceTest extends AbstractIntegrationTest { +public class MgmtTargetResourceTest extends AbstractIntegrationTest { private static final String TARGET_DESCRIPTION_TEST = "created in test"; @@ -117,10 +118,10 @@ public class TargetResourceTest extends AbstractIntegrationTest { .get(0).getActionStatus().stream().sorted((e1, e2) -> Long.compare(e2.getId(), e1.getId())) .collect(Collectors.toList()).get(0); - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + actions.get(0).getId() + "/status") - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize)) - .param(RestConstants.REQUEST_PARAMETER_SORTING, "ID:DESC")) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actions.get(0).getId() + "/status") + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize)) + .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:DESC")) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(3))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) @@ -139,7 +140,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String knownControllerId = "knownControllerId"; targetManagement.createTarget(new Target(knownControllerId)); - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId)) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("securityToken").doesNotExist()); } @@ -152,7 +153,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String knownControllerId = "knownControllerId"; final Target createTarget = targetManagement.createTarget(new Target(knownControllerId)); - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId)) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("securityToken", equalTo(createTarget.getSecurityToken()))); } @@ -168,7 +169,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { createTarget(knownControllerId2); // test - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(2))) .andExpect(jsonPath("size", equalTo(2))) .andExpect(jsonPath("$content.[?(@.controllerId==" + knownControllerId1 + ")][0].ipAddress", @@ -204,22 +205,22 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String rsqlFinishedStatus = "status==finished"; final String rsqlPendingOrFinishedStatus = rsqlFinishedStatus + "," + rsqlPendingStatus; // pending status one result - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions?q=" + rsqlPendingStatus, + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions?q=" + rsqlPendingStatus, createTarget.getControllerId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(1))).andExpect(jsonPath("size", equalTo(1))) .andExpect(jsonPath("content[0].status", equalTo("pending"))); // finished status none result - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions?q=" + rsqlFinishedStatus, + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions?q=" + rsqlFinishedStatus, createTarget.getControllerId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(0))).andExpect(jsonPath("size", equalTo(0))); // pending or finished status one result - mvc.perform( - get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions?q=" + rsqlPendingOrFinishedStatus, - createTarget.getControllerId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) - .andExpect(jsonPath("size", equalTo(1))).andExpect(jsonPath("content[0].status", equalTo("pending"))); + mvc.perform(get( + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions?q=" + rsqlPendingOrFinishedStatus, + createTarget.getControllerId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))).andExpect(jsonPath("size", equalTo(1))) + .andExpect(jsonPath("content[0].status", equalTo("pending"))); } @Test @@ -229,7 +230,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { final Target tA = createTargetAndStartAction(); // test - cancel the active action - mvc.perform(delete(RestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", + mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", tA.getControllerId(), tA.getActions().get(0).getId())).andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -261,7 +262,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { assertThat(cancelActions).hasSize(1); // test - cancel an cancel action returns forbidden - mvc.perform(delete(RestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", + mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", tA.getControllerId(), cancelActions.get(0).getId())).andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); } @@ -282,7 +283,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { assertThat(cancelActions.get(0).isCancelingOrCanceled()).isTrue(); // test - force quit an canceled action should return 204 - mvc.perform(delete(RestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}?force=true", + mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}?force=true", tA.getControllerId(), cancelActions.get(0).getId())).andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); } @@ -294,7 +295,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { final Target tA = createTargetAndStartAction(); // test - cancel an cancel action returns forbidden - mvc.perform(delete(RestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}?force=true", + mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}?force=true", tA.getControllerId(), tA.getActions().get(0).getId())).andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); } @@ -305,7 +306,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String knownControllerId = "knownControllerIdDelete"; targetManagement.createTarget(new Target(knownControllerId)); - mvc.perform(delete(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId)) + mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId)) .andExpect(status().isOk()); final Target findTargetByControllerID = targetManagement.findTargetByControllerID(knownControllerId); @@ -317,7 +318,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { public void deleteTargetWhichDoesNotExistsLeadsToEntityNotFound() throws Exception { final String knownControllerId = "knownControllerIdDelete"; - mvc.perform(delete(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId)) + mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId)) .andExpect(status().isNotFound()); } @@ -325,7 +326,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { @Description("Ensures that update is refused with not found if target does not exist.") public void updateTargetWhichDoesNotExistsLeadsToEntityNotFound() throws Exception { final String knownControllerId = "knownControllerIdUpdate"; - mvc.perform(put(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content("{}") + mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content("{}") .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); } @@ -344,7 +345,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { t.setName(knownNameNotModiy); targetManagement.createTarget(t); - mvc.perform(put(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body) + mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body) .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("$.controllerId", equalTo(knownControllerId))) .andExpect(jsonPath("$.description", equalTo(knownNewDescription))) @@ -364,7 +365,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String idC = "c"; final String linksHrefPrefix = "http://localhost/rest/v1/targets/"; createTargetsAlphabetical(knownTargetAmount); - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING)).andExpect(status().isOk()) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)).andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(knownTargetAmount))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(knownTargetAmount))) @@ -404,8 +405,9 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String idA = "a"; final String linksHrefPrefix = "http://localhost/rest/v1/targets/"; - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING).param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - String.valueOf(limitSize))).andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) + .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(knownTargetAmount))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))) @@ -431,9 +433,9 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String linksHrefPrefix = "http://localhost/rest/v1/targets/"; createTargetsAlphabetical(knownTargetAmount); - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING) - .param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(knownTargetAmount))) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(knownTargetAmount))) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(knownTargetAmount))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) @@ -472,7 +474,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { createSingleTarget(knownControllerId, knownName); final String hrefPrefix = "http://localhost/rest/v1/targets/" + knownControllerId + "/"; // test - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId)) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath(JSON_PATH_NAME, equalTo(knownName))) .andExpect(jsonPath(JSON_PATH_CONTROLLERID, equalTo(knownControllerId))) @@ -491,7 +493,8 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String targetIdNotExists = "bubu"; // test - final MvcResult mvcResult = mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + targetIdNotExists)) + final MvcResult mvcResult = mvc + .perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + targetIdNotExists)) .andExpect(status().isNotFound()).andReturn(); // verify response json exception message @@ -509,7 +512,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { // test - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/assignedDS")) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/assignedDS")) .andExpect(status().isNoContent()).andExpect(content().string("")); } @@ -529,7 +532,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { final SoftwareModule os = ds.findFirstModuleByType(osType); final SoftwareModule jvm = ds.findFirstModuleByType(runtimeType); final SoftwareModule bApp = ds.findFirstModuleByType(appType); - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/assignedDS")) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/assignedDS")) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath(JSON_PATH_ID, equalTo(ds.getId().intValue()))) .andExpect(jsonPath(JSON_PATH_NAME, equalTo(ds.getName()))) @@ -579,7 +582,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { // test - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/installedDS")) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/installedDS")) .andExpect(status().isNoContent()).andExpect(content().string("")); } @@ -602,7 +605,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { final SoftwareModule os = ds.findFirstModuleByType(osType); final SoftwareModule jvm = ds.findFirstModuleByType(runtimeType); final SoftwareModule bApp = ds.findFirstModuleByType(appType); - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/installedDS")) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/installedDS")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath(JSON_PATH_ID, equalTo(ds.getId().intValue()))) .andExpect(jsonPath(JSON_PATH_NAME, equalTo(ds.getName()))) @@ -646,7 +649,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { public void createTargetWithoutPayloadBadRequest() throws Exception { final MvcResult mvcResult = mvc - .perform(post(RestConstants.TARGET_V1_REQUEST_MAPPING).contentType(MediaType.APPLICATION_JSON)) + .perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn(); assertThat(targetManagement.countTargetsAll()).isEqualTo(0); @@ -663,7 +666,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String notJson = "abc"; final MvcResult mvcResult = mvc - .perform(post(RestConstants.TARGET_V1_REQUEST_MAPPING).content(notJson) + .perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content(notJson) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn(); @@ -743,7 +746,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String knownDescription = "someDescription"; final String createTargetsJson = getCreateTargetsListJsonString(knownControllerId, knownName, knownDescription); - mvc.perform(post(RestConstants.TARGET_V1_REQUEST_MAPPING).content(createTargetsJson) + mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content(createTargetsJson) .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().is2xxSuccessful()); @@ -764,12 +767,12 @@ public class TargetResourceTest extends AbstractIntegrationTest { // create a taret first to provoke a already exists error - mvc.perform(post(RestConstants.TARGET_V1_REQUEST_MAPPING).content(createTargetsJson) + mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content(createTargetsJson) .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().is2xxSuccessful()); // create another one to retrieve the entity already exists exception final MvcResult mvcResult = mvc - .perform(post(RestConstants.TARGET_V1_REQUEST_MAPPING).content(createTargetsJson) + .perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content(createTargetsJson) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().is(HttpStatus.CONFLICT.value())).andReturn(); @@ -792,7 +795,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String createTargetsJson = getCreateTargetsListJsonStringWithAdditionalNotExistingAttribute( knownControllerId, knownName, knownDescription); - mvc.perform(post(RestConstants.TARGET_V1_REQUEST_MAPPING).content(createTargetsJson) + mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content(createTargetsJson) .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().is2xxSuccessful()); @@ -810,10 +813,10 @@ public class TargetResourceTest extends AbstractIntegrationTest { final Target target = new Target(knownTargetId); targetManagement.createTarget(target); - mvc.perform(get( - RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("size", equalTo(0))) - .andExpect(jsonPath("content", hasSize(0))).andExpect(jsonPath("total", equalTo(0))); + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(0))).andExpect(jsonPath("content", hasSize(0))) + .andExpect(jsonPath("total", equalTo(0))); } @Test @@ -821,9 +824,10 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + actions.get(0).getId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("id", equalTo(actions.get(0).getId().intValue()))) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actions.get(0).getId())) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andExpect(jsonPath("id", equalTo(actions.get(0).getId().intValue()))) .andExpect(jsonPath("type", equalTo("cancel"))).andExpect(jsonPath("status", equalTo("pending"))) .andExpect(jsonPath("_links.self.href", equalTo(generateActionSelfLink(knownTargetId, actions.get(0))))) .andExpect(jsonPath("_links.canceledaction.href", @@ -837,9 +841,8 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); - mvc.perform(get( - RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS) - .param(RestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("content.[1].id", equalTo(actions.get(1).getId().intValue()))) .andExpect(jsonPath("content.[1].type", equalTo("update"))) @@ -866,9 +869,10 @@ public class TargetResourceTest extends AbstractIntegrationTest { .sorted((e1, e2) -> Long.compare(e2.getId(), e1.getId())).collect(Collectors.toList()); // sort is default descending order, latest status first - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + RestConstants.TARGET_V1_ACTION_STATUS)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + + MgmtRestConstants.TARGET_V1_ACTION_STATUS)).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("content.[0].id", equalTo(actionStatus.get(0).getId().intValue()))) .andExpect(jsonPath("content.[0].type", equalTo("canceling"))) .andExpect(jsonPath("content.[0].messages", hasItem("manual cancelation requested"))) @@ -890,9 +894,10 @@ public class TargetResourceTest extends AbstractIntegrationTest { .sorted((e1, e2) -> Long.compare(e1.getId(), e2.getId())).collect(Collectors.toList()); // descending order - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + RestConstants.TARGET_V1_ACTION_STATUS) - .param(RestConstants.REQUEST_PARAMETER_SORTING, "REPORTEDAT:DESC")) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + + MgmtRestConstants.TARGET_V1_ACTION_STATUS).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, + "REPORTEDAT:DESC")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("content.[0].id", equalTo(actionStatus.get(1).getId().intValue()))) .andExpect(jsonPath("content.[0].type", equalTo("canceling"))) @@ -906,9 +911,10 @@ public class TargetResourceTest extends AbstractIntegrationTest { .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(2))); // ascending order - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + RestConstants.TARGET_V1_ACTION_STATUS) - .param(RestConstants.REQUEST_PARAMETER_SORTING, "REPORTEDAT:ASC")) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + + MgmtRestConstants.TARGET_V1_ACTION_STATUS).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, + "REPORTEDAT:ASC")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("content.[1].id", equalTo(actionStatus.get(1).getId().intValue()))) .andExpect(jsonPath("content.[1].type", equalTo("canceling"))) @@ -932,9 +938,10 @@ public class TargetResourceTest extends AbstractIntegrationTest { .sorted((e1, e2) -> Long.compare(e1.getId(), e2.getId())).collect(Collectors.toList()); // Page 1 - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + RestConstants.TARGET_V1_ACTION_STATUS) - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1))) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + + MgmtRestConstants.TARGET_V1_ACTION_STATUS).param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, + String.valueOf(1))) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("content.[0].id", equalTo(actionStatus.get(1).getId().intValue()))) .andExpect(jsonPath("content.[0].type", equalTo("canceling"))) @@ -945,10 +952,11 @@ public class TargetResourceTest extends AbstractIntegrationTest { .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(1))); // Page 2 - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + RestConstants.TARGET_V1_ACTION_STATUS) - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) - .param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + + MgmtRestConstants.TARGET_V1_ACTION_STATUS) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("content.[0].id", equalTo(actionStatus.get(0).getId().intValue()))) .andExpect(jsonPath("content.[0].type", equalTo("running"))) @@ -964,10 +972,10 @@ public class TargetResourceTest extends AbstractIntegrationTest { final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); // page 1: one entry - mvc.perform(get( - RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS) - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) - .param(RestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) + .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("content.[0].id", equalTo(actions.get(0).getId().intValue()))) .andExpect(jsonPath("content.[0].type", equalTo("cancel"))) @@ -979,12 +987,12 @@ public class TargetResourceTest extends AbstractIntegrationTest { .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(1))); // page 2: one entry - mvc.perform(get( - RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS) - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) - .param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1)) - .param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1)) - .param(RestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1)) + .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1)) + .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("content.[0].id", equalTo(actions.get(1).getId().intValue()))) .andExpect(jsonPath("content.[0].type", equalTo("update"))) @@ -997,19 +1005,19 @@ public class TargetResourceTest extends AbstractIntegrationTest { } private String generateActionSelfLink(final String knownTargetId, final Action action) { - return "http://localhost" + RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + action.getId(); + return "http://localhost" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId(); } private String generateCanceledactionreferenceLink(final String knownTargetId, final Action action) { - return "http://localhost" + RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + action.getId(); + return "http://localhost" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId(); } private String generateStatusreferenceLink(final String knownTargetId, final Action action) { - return "http://localhost" + RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + RestConstants.TARGET_V1_ACTION_STATUS - + "?offset=0&limit=50&sort=id:DESC"; + return "http://localhost" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + + MgmtRestConstants.TARGET_V1_ACTION_STATUS + "?offset=0&limit=50&sort=id:DESC"; } private List generateTargetWithTwoUpdatesWithOneOverride(final String knownTargetId) @@ -1047,9 +1055,10 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + actions.get(1).getId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("id", equalTo(actions.get(1).getId().intValue()))) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actions.get(1).getId())) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andExpect(jsonPath("id", equalTo(actions.get(1).getId().intValue()))) .andExpect(jsonPath("type", equalTo("update"))).andExpect(jsonPath("status", equalTo("pending"))) .andExpect(jsonPath("_links.self.href", equalTo(generateActionSelfLink(knownTargetId, actions.get(1))))) .andExpect(jsonPath("_links.distributionset.href", @@ -1066,7 +1075,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement, distributionSetManagement); - mvc.perform(post(RestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") + mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); @@ -1084,7 +1093,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String body = new JSONObject().put("id", set.getId()).put("type", "timeforced") .put("forcetime", forceTime).toString(); - mvc.perform(post(RestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS").content(body) + mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS").content(body) .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); @@ -1101,25 +1110,25 @@ public class TargetResourceTest extends AbstractIntegrationTest { final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement, distributionSetManagement); - mvc.perform(post(RestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") + mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); targetManagement.createTarget(new Target("fsdfsd")); - mvc.perform(post(RestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") + mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); - mvc.perform(post(RestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS").content("{\"id\":12345678}") - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isNotFound()); + mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") + .content("{\"id\":12345678}").contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); - mvc.perform(delete(RestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") + mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(put(RestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") + mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed()); @@ -1130,28 +1139,28 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String knownTargetId = "targetId"; // target does not exist - mvc.perform(get( - RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS)).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); final Long actionId = actions.get(0).getId(); // should work now - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + actionId)).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // action does not exist - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/12321")).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/12321")).andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); // not allowed methods - mvc.perform(put(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + actionId)).andDo(MockMvcResultPrinter.print()) + mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(post(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + actionId)).andDo(MockMvcResultPrinter.print()) + mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); } @@ -1160,31 +1169,31 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String knownTargetId = "targetId"; // target does not exist - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/1/status")).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/1/status")).andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); final Long actionId = actions.get(0).getId(); // should work now - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // action does not exist - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/12321/status")).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/12321/status")).andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); // not allowed methods - mvc.perform(delete(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")).andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(put(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")).andDo(MockMvcResultPrinter.print()) + mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")).andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(post(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + RestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")).andDo(MockMvcResultPrinter.print()) + mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")).andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); } @@ -1200,7 +1209,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { controllerManagament.updateControllerAttributes(knownTargetId, knownControllerAttrs); // test query target over rest resource - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/attributes")) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/attributes")) .andDo(MockMvcResultPrinter.print()).andExpect(status().is2xxSuccessful()) .andExpect(jsonPath("$.a", equalTo("1"))).andExpect(jsonPath("$.b", equalTo("2"))); } @@ -1213,7 +1222,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { targetManagement.createTarget(target); // test query target over rest resource - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/attributes")) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/attributes")) .andDo(MockMvcResultPrinter.print()).andExpect(status().is(HttpStatus.NO_CONTENT.value())); } @@ -1224,7 +1233,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { final String rsqlFindAOrB = "controllerId==a,controllerId==b"; - mvc.perform(get(RestConstants.TARGET_V1_REQUEST_MAPPING + "?q=" + rsqlFindAOrB)) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "?q=" + rsqlFindAOrB)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("size", equalTo(2))) .andExpect(jsonPath("total", equalTo(2))).andExpect(jsonPath("content[0].controllerId", equalTo("a"))) .andExpect(jsonPath("content[1].controllerId", equalTo("b"))); diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MockMvcResultPrinter.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MockMvcResultPrinter.java new file mode 100644 index 000000000..7d07b3bd3 --- /dev/null +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MockMvcResultPrinter.java @@ -0,0 +1,55 @@ +/** + * 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.mgmt.rest.resource; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.ResultHandler; +import org.springframework.test.web.servlet.result.PrintingResultHandler; +import org.springframework.util.CollectionUtils; + +public abstract class MockMvcResultPrinter { + private static final Logger LOG = LoggerFactory.getLogger(MockMvcResultPrinter.class); + + private MockMvcResultPrinter() { + } + + /** + * Print {@link MvcResult} details to the "standard" output stream. + */ + public static ResultHandler print() { + return new ConsolePrintingResultHandler(); + } + + /** + * An {@link PrintingResultHandler} that writes to the "standard" output + * stream + */ + private static class ConsolePrintingResultHandler extends PrintingResultHandler { + + public ConsolePrintingResultHandler() { + super(new ResultValuePrinter() { + + @Override + public void printHeading(final String heading) { + LOG.debug(String.format("%20s:", heading)); + } + + @Override + public void printValue(final String label, Object value) { + if (value != null && value.getClass().isArray()) { + value = CollectionUtils.arrayToList(value); + } + LOG.debug(String.format("%20s = %s", label, value)); + } + }); + } + } +} diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/ResourceUtility.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/ResourceUtility.java similarity index 77% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/ResourceUtility.java rename to hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/ResourceUtility.java index 9e99031e9..e94d1b857 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/ResourceUtility.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/ResourceUtility.java @@ -6,13 +6,13 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import java.io.IOException; -import org.eclipse.hawkbit.rest.resource.model.ExceptionInfo; -import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.artifact.ArtifactRest; +import org.eclipse.hawkbit.mgmt.json.model.PagedList; +import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact; +import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; @@ -33,9 +33,9 @@ public final class ResourceUtility { return mapper.readValue(jsonExceptionResponse, ExceptionInfo.class); } - static ArtifactRest convertArtifactResponse(final String jsonResponse) + static MgmtArtifact convertArtifactResponse(final String jsonResponse) throws JsonParseException, JsonMappingException, IOException { - return mapper.readValue(jsonResponse, ArtifactRest.class); + return mapper.readValue(jsonResponse, MgmtArtifact.class); } diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SMRessourceMisingMongoDbConnectionTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/SMRessourceMisingMongoDbConnectionTest.java similarity index 93% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SMRessourceMisingMongoDbConnectionTest.java rename to hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/SMRessourceMisingMongoDbConnectionTest.java index 664dc861c..4f80728f1 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SMRessourceMisingMongoDbConnectionTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/SMRessourceMisingMongoDbConnectionTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.fileUpload; @@ -14,10 +14,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import org.apache.commons.lang3.RandomStringUtils; import org.eclipse.hawkbit.AbstractIntegrationTest; -import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.repository.model.SoftwareModule; -import org.eclipse.hawkbit.rest.resource.model.ExceptionInfo; +import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.junit.BeforeClass; import org.junit.Test; import org.springframework.mock.web.MockMultipartFile; @@ -28,7 +27,8 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; /** - * Tests {@link SoftwareModuleResource} in case of missing MongoDB connection. + * Tests {@link MgmtSoftwareModuleResource} in case of missing MongoDB + * connection. * */ @Features("Component Tests - Management API") diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SuccessCondition.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/SuccessCondition.java similarity index 91% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SuccessCondition.java rename to hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/SuccessCondition.java index be6e166ef..cafc36b0b 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SuccessCondition.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/SuccessCondition.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource; /** * diff --git a/hawkbit-rest-resource/src/test/resources/application-test.properties b/hawkbit-mgmt-resource/src/test/resources/application-test.properties similarity index 100% rename from hawkbit-rest-resource/src/test/resources/application-test.properties rename to hawkbit-mgmt-resource/src/test/resources/application-test.properties diff --git a/hawkbit-rest-resource/src/test/resources/log4j2.xml b/hawkbit-mgmt-resource/src/test/resources/log4j2.xml similarity index 100% rename from hawkbit-rest-resource/src/test/resources/log4j2.xml rename to hawkbit-mgmt-resource/src/test/resources/log4j2.xml diff --git a/hawkbit-rest-core/pom.xml b/hawkbit-rest-core/pom.xml new file mode 100644 index 000000000..9048cf677 --- /dev/null +++ b/hawkbit-rest-core/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + + org.eclipse.hawkbit + hawkbit-parent + 0.2.0-SNAPSHOT + + hawkbit-rest-core + hawkBit :: REST Resources + + + + + org.eclipse.hawkbit + hawkbit-repository + ${project.version} + + + org.eclipse.hawkbit + hawkbit-core + ${project.version} + + + + javax.servlet + javax.servlet-api + provided + + + org.apache.tomcat.embed + tomcat-embed-core + provided + + + org.springframework.data + spring-data-commons + + + org.springframework + spring-web + + + + + org.easytesting + fest-assert + test + + + ru.yandex.qatools.allure + allure-junit-adaptor + test + + + \ No newline at end of file diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortDirection.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/data/SortDirection.java similarity index 89% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortDirection.java rename to hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/data/SortDirection.java index 344c27ce7..ca33d25b3 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortDirection.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/data/SortDirection.java @@ -6,7 +6,9 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.rest.data; + +import org.eclipse.hawkbit.rest.exception.SortParameterUnsupportedDirectionException; /** * A definition of possible sorting direction. diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/MessageNotReadableException.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/MessageNotReadableException.java similarity index 95% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/MessageNotReadableException.java rename to hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/MessageNotReadableException.java index 023b67352..3c5e0aee3 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/MessageNotReadableException.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/MessageNotReadableException.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.rest.exception; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.SpServerRtException; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/ResponseExceptionHandler.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/ResponseExceptionHandler.java similarity index 98% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/ResponseExceptionHandler.java rename to hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/ResponseExceptionHandler.java index 25ddc7c4c..0f8da9ebe 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/ResponseExceptionHandler.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/ResponseExceptionHandler.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.rest.exception; import java.util.EnumMap; import java.util.Map; @@ -16,7 +16,7 @@ import javax.servlet.http.HttpServletRequest; import org.apache.tomcat.util.http.fileupload.FileUploadBase.FileSizeLimitExceededException; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.SpServerRtException; -import org.eclipse.hawkbit.rest.resource.model.ExceptionInfo; +import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; @@ -86,7 +86,8 @@ public class ResponseExceptionHandler { * as entity. */ @ExceptionHandler(SpServerRtException.class) - public ResponseEntity handleSpServerRtExceptions(final HttpServletRequest request, final Exception ex) { + public ResponseEntity handleSpServerRtExceptions(final HttpServletRequest request, + final Exception ex) { LOG.debug("Handling exception of request {}", request.getRequestURL()); final ExceptionInfo response = new ExceptionInfo(); final HttpStatus responseStatus; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterSyntaxErrorException.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterSyntaxErrorException.java similarity index 95% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterSyntaxErrorException.java rename to hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterSyntaxErrorException.java index b6bacd9d2..a8d476ac1 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterSyntaxErrorException.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterSyntaxErrorException.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.rest.exception; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.SpServerRtException; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterUnsupportedDirectionException.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterUnsupportedDirectionException.java similarity index 97% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterUnsupportedDirectionException.java rename to hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterUnsupportedDirectionException.java index 60fa3d8df..b44b94917 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterUnsupportedDirectionException.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterUnsupportedDirectionException.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.rest.exception; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.SpServerRtException; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterUnsupportedFieldException.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterUnsupportedFieldException.java similarity index 97% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterUnsupportedFieldException.java rename to hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterUnsupportedFieldException.java index 20c6f03d6..c9ce0dcdd 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterUnsupportedFieldException.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterUnsupportedFieldException.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.rest.exception; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.SpServerRtException; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfo.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/json/model/ExceptionInfo.java similarity index 97% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfo.java rename to hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/json/model/ExceptionInfo.java index e2d808943..d68e0037f 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfo.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/json/model/ExceptionInfo.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model; +package org.eclipse.hawkbit.rest.json.model; import java.util.List; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/ByteRange.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/ByteRange.java similarity index 98% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/ByteRange.java rename to hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/ByteRange.java index df72e2c53..667fc197d 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/ByteRange.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/ByteRange.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.helper; +package org.eclipse.hawkbit.rest.util; /** * Byte range for resume download operations. diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/FileSteamingFailedException.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileSteamingFailedException.java similarity index 96% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/FileSteamingFailedException.java rename to hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileSteamingFailedException.java index e246bc6cd..abf7c0245 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/FileSteamingFailedException.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileSteamingFailedException.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.helper; +package org.eclipse.hawkbit.rest.util; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.SpServerRtException; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/RestResourceConversionHelper.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/RestResourceConversionHelper.java similarity index 94% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/RestResourceConversionHelper.java rename to hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/RestResourceConversionHelper.java index f09bd7401..827506048 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/RestResourceConversionHelper.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/RestResourceConversionHelper.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.helper; +package org.eclipse.hawkbit.rest.util; import static com.google.common.base.Preconditions.checkNotNull; @@ -23,9 +23,7 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.hawkbit.artifact.repository.model.DbArtifact; import org.eclipse.hawkbit.cache.CacheWriteNotify; -import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.LocalArtifact; -import org.eclipse.hawkbit.rest.resource.model.distributionset.ActionTypeRest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; @@ -38,9 +36,6 @@ import com.google.common.net.HttpHeaders; /** * Utility class for the Rest Source API. * - * - * - * */ public final class RestResourceConversionHelper { private static final Logger LOG = LoggerFactory.getLogger(RestResourceConversionHelper.class); @@ -346,28 +341,4 @@ public final class RestResourceConversionHelper { return Arrays.binarySearch(matchValues, toMatch) > -1 || Arrays.binarySearch(matchValues, "*") > -1; } - /** - * Convert a action rest type to a action repository type. - * - * @param actionTypeRest - * the rest type - * @return or the action repository type - */ - public static ActionType convertActionType(final ActionTypeRest actionTypeRest) { - if (actionTypeRest == null) { - return null; - } - - switch (actionTypeRest) { - case SOFT: - return ActionType.SOFT; - case FORCED: - return ActionType.FORCED; - case TIMEFORCED: - return ActionType.TIMEFORCED; - default: - throw new IllegalStateException("Action Type is not supported"); - } - - } } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortUtility.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/SortUtility.java similarity index 94% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortUtility.java rename to hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/SortUtility.java index f8b997bf9..d0abc47a7 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortUtility.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/SortUtility.java @@ -6,12 +6,15 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.rest.util; import java.util.List; import java.util.StringTokenizer; import org.eclipse.hawkbit.repository.FieldNameProvider; +import org.eclipse.hawkbit.rest.exception.SortParameterSyntaxErrorException; +import org.eclipse.hawkbit.rest.exception.SortParameterUnsupportedDirectionException; +import org.eclipse.hawkbit.rest.exception.SortParameterUnsupportedFieldException; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Order; diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/json/model/ExceptionInfoTest.java similarity index 95% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java rename to hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/json/model/ExceptionInfoTest.java index d240a814b..263bb75c5 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java +++ b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/json/model/ExceptionInfoTest.java @@ -6,13 +6,14 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model; +package org.eclipse.hawkbit.rest.json.model; import static org.fest.assertions.Assertions.assertThat; import java.util.ArrayList; import java.util.List; +import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.junit.Test; import ru.yandex.qatools.allure.annotations.Description; diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SortUtilityTest.java b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/SortUtilityTest.java similarity index 91% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SortUtilityTest.java rename to hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/SortUtilityTest.java index 09a90c39c..8f1b814bf 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SortUtilityTest.java +++ b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/SortUtilityTest.java @@ -6,14 +6,17 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.rest.util; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.fest.assertions.Assertions.assertThat; import static org.junit.Assert.fail; import java.util.List; import org.eclipse.hawkbit.repository.TargetFields; +import org.eclipse.hawkbit.rest.exception.SortParameterSyntaxErrorException; +import org.eclipse.hawkbit.rest.exception.SortParameterUnsupportedDirectionException; +import org.eclipse.hawkbit.rest.exception.SortParameterUnsupportedFieldException; import org.junit.Test; import org.springframework.data.domain.Sort.Order; diff --git a/hawkbit-rest-core/src/test/resources/application-test.properties b/hawkbit-rest-core/src/test/resources/application-test.properties new file mode 100644 index 000000000..92506caa4 --- /dev/null +++ b/hawkbit-rest-core/src/test/resources/application-test.properties @@ -0,0 +1,63 @@ +# +# 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 +# + +# used if IM profile is disabled +security.ignored=true + +# IM required for integration tests +spring.profiles.active=im,suiteembedded,artifactrepository,redis + +server.port=12222 + +spring.data.mongodb.uri=mongodb://localhost/spArtifactRepository${random.value} +spring.data.mongodb.port=28017 + + +# supported: H2, MYSQL +hawkbit.server.database=H2 +hawkbit.server.database.env=TEST +spring.main.show_banner=false + +hawkbit.server.ddi.security.authentication.header=true + +hawkbit.server.artifact.repo.upload.maxFileSize=5MB + +hawkbit.server.security.dos.maxStatusEntriesPerAction=100 + +hawkbit.server.security.dos.maxAttributeEntriesPerTarget=10 + +spring.jpa.database=${hawkbit.server.database} +#spring.jpa.show-sql=true + + +flyway.sqlMigrationSuffix=${spring.jpa.database}.sql + +# effective DB setting +spring.datasource.url=${${hawkbit.server.database}.spring.datasource.url} +spring.datasource.driverClassName=${${hawkbit.server.database}.spring.datasource.driverClassName} +spring.datasource.username=${${hawkbit.server.database}.spring.datasource.username} +spring.datasource.password=${${hawkbit.server.database}.spring.datasource.password} + +# H2 +##;AUTOCOMMIT=ON +H2.spring.datasource.url=jdbc:h2:mem:sp-db;DB_CLOSE_ON_EXIT=FALSE +#H2.spring.datasource.url=jdbc:h2:./db/sp-db;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE;MVCC=TRUE +H2.spring.datasource.driverClassName=org.h2.Driver +H2.spring.datasource.username=sa +H2.spring.datasource.password=sa + +# MYSQL +MYSQL.spring.datasource.url=jdbc:mysql://localhost:3306/sp_test +MYSQL.spring.datasource.driverClassName=org.mariadb.jdbc.Driver +MYSQL.spring.datasource.username=root +MYSQL.spring.datasource.password= + +# SP Controller configuration +hawkbit.controller.pollingTime=00:01:00 +hawkbit.controller.pollingOverdueTime=00:01:00 diff --git a/hawkbit-rest-core/src/test/resources/log4j2.xml b/hawkbit-rest-core/src/test/resources/log4j2.xml new file mode 100644 index 000000000..98ea99ac9 --- /dev/null +++ b/hawkbit-rest-core/src/test/resources/log4j2.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/OffsetBasedPageRequest.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/OffsetBasedPageRequest.java deleted file mode 100644 index 5ab6b33c6..000000000 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/OffsetBasedPageRequest.java +++ /dev/null @@ -1,69 +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.rest.resource; - -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort; - -/** - * An implementation of the {@link PageRequest} which is offset based by means - * the offset is given and not the page number as in the original - * {@link PageRequest} implemntation where the offset is generated. Due that the - * REST-API is working with {@code offset} and {@code limit} parameter we need - * an offset based page request for JPA. - * - * - * - * - */ -public final class OffsetBasedPageRequest extends PageRequest { - - private static final long serialVersionUID = 1L; - private final int offset; - - /** - * Creates a new {@link OffsetBasedPageRequest}. Offsets are zero indexed, - * thus providing 0 for {@code offset} will return the first entry. - * - * @param offset - * zero-based offset index. - * @param limit - * the limit of the page to be returned. - */ - public OffsetBasedPageRequest(final int offset, final int limit) { - this(offset, limit, null); - } - - /** - * Creates a new {@link OffsetBasedPageRequest}. Offsets are zero indexed, - * thus providing 0 for {@code offset} will return the first entry. - * - * @param offset - * zero-based offset index. - * @param limit - * the limit of the page to be returned. - * @param sort - * sort can be {@literal null}. - */ - public OffsetBasedPageRequest(final int offset, final int limit, final Sort sort) { - super(0, limit, sort); - this.offset = offset; - } - - @Override - public int getOffset() { - return offset; - } - - @Override - public String toString() { - return "OffsetBasedPageRequest [offset=" + offset + ", getPageSize()=" + getPageSize() + ", getPageNumber()=" - + getPageNumber() + "]"; - } -} diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RestModelMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RestModelMapper.java deleted file mode 100644 index 9616d0e86..000000000 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RestModelMapper.java +++ /dev/null @@ -1,48 +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.rest.resource; - -import org.eclipse.hawkbit.repository.model.NamedEntity; -import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity; -import org.eclipse.hawkbit.rest.resource.model.BaseEntityRest; -import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; - -/** - * A mapper which maps repository model to RESTful model representation and - * back. - * - * - * - * - */ -final class RestModelMapper { - - // private constructor, utility class - private RestModelMapper() { - - } - - static void mapBaseToBase(final BaseEntityRest response, final TenantAwareBaseEntity base) { - response.setCreatedBy(base.getCreatedBy()); - response.setLastModifiedBy(base.getLastModifiedBy()); - if (base.getCreatedAt() != null) { - response.setCreatedAt(base.getCreatedAt()); - } - if (base.getLastModifiedAt() != null) { - response.setLastModifiedAt(base.getLastModifiedAt()); - } - } - - static void mapNamedToNamed(final NamedEntityRest response, final NamedEntity base) { - mapBaseToBase(response, base); - - response.setName(base.getName()); - response.setDescription(base.getDescription()); - } -} diff --git a/hawkbit-rest-api/pom.xml b/hawkbit-system-api/pom.xml similarity index 83% rename from hawkbit-rest-api/pom.xml rename to hawkbit-system-api/pom.xml index 703d6caf3..b68b02b36 100644 --- a/hawkbit-rest-api/pom.xml +++ b/hawkbit-system-api/pom.xml @@ -16,15 +16,11 @@ hawkbit-parent 0.2.0-SNAPSHOT - hawkbit-rest-api - hawkBit :: REST API + hawkbit-system-api + hawkBit :: System REST API - - javax.validation - validation-api - org.springframework.hateoas spring-hateoas diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantConfigurationValueRest.java b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/system/SystemTenantConfigurationValue.java similarity index 94% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantConfigurationValueRest.java rename to hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/system/SystemTenantConfigurationValue.java index 47dcfebe0..c152de0c3 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantConfigurationValueRest.java +++ b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/system/SystemTenantConfigurationValue.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.system; +package org.eclipse.hawkbit.system.json.model.system; import org.springframework.hateoas.ResourceSupport; @@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class TenantConfigurationValueRest extends ResourceSupport { +public class SystemTenantConfigurationValue extends ResourceSupport { @JsonInclude(Include.ALWAYS) private Object value; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantConfigurationValueRequest.java b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/system/SystemTenantConfigurationValueRequest.java similarity index 80% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantConfigurationValueRequest.java rename to hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/system/SystemTenantConfigurationValueRequest.java index b0ae6e546..08bd06dd8 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantConfigurationValueRequest.java +++ b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/system/SystemTenantConfigurationValueRequest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.system; +package org.eclipse.hawkbit.system.json.model.system; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -18,21 +18,21 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class TenantConfigurationValueRequest { +public class SystemTenantConfigurationValueRequest { @JsonProperty(required = true) private Object value; /** * - * @return the value of the TenantConfigurationValueRequest + * @return the value of the SystemTenantConfigurationValueRequest */ public Object getValue() { return value; } /** - * Sets the TenantConfigurationValueRequest + * Sets the SystemTenantConfigurationValueRequest * * @param value */ diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/systemmanagement/CacheRest.java b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/systemmanagement/SystemCache.java similarity index 84% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/systemmanagement/CacheRest.java rename to hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/systemmanagement/SystemCache.java index 35d35c0b1..428483be9 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/systemmanagement/CacheRest.java +++ b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/systemmanagement/SystemCache.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.systemmanagement; +package org.eclipse.hawkbit.system.json.model.systemmanagement; import java.util.Collection; @@ -16,14 +16,11 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; /** * Model representation of an Cache entry as json. - * - * - * * */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class CacheRest { +public class SystemCache { private final String name; private final Collection keys; @@ -34,7 +31,7 @@ public class CacheRest { * @param cacheKeys * the keys which contains in the cache */ - public CacheRest(final String name, final Collection cacheKeys) { + public SystemCache(final String name, final Collection cacheKeys) { this.name = name; this.keys = cacheKeys; } @@ -60,6 +57,6 @@ public class CacheRest { */ @Override public String toString() { - return "CacheRest [name=" + name + ", keys=" + keys + "]"; + return "SystemCache [name=" + name + ", keys=" + keys + "]"; } } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/systemmanagement/SystemStatisticsRest.java b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/systemmanagement/SystemStatisticsRest.java similarity index 89% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/systemmanagement/SystemStatisticsRest.java rename to hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/systemmanagement/SystemStatisticsRest.java index c69201d69..8e1c80ded 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/systemmanagement/SystemStatisticsRest.java +++ b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/systemmanagement/SystemStatisticsRest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.systemmanagement; +package org.eclipse.hawkbit.system.json.model.systemmanagement; import java.util.List; @@ -28,7 +28,7 @@ public class SystemStatisticsRest { private long overallActions; private long overallTenants; - private List tenantStats; + private List tenantStats; public long getOverallTargets() { return overallTargets; @@ -75,11 +75,11 @@ public class SystemStatisticsRest { return this; } - public void setTenantStats(final List tenantStats) { + public void setTenantStats(final List tenantStats) { this.tenantStats = tenantStats; } - public List getTenantStats() { + public List getTenantStats() { return tenantStats; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/systemmanagement/TenantSystemUsageRest.java b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/systemmanagement/SystemTenantServiceUsage.java similarity index 91% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/systemmanagement/TenantSystemUsageRest.java rename to hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/systemmanagement/SystemTenantServiceUsage.java index bc8653b36..ab7b7e6b8 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/systemmanagement/TenantSystemUsageRest.java +++ b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/json/model/systemmanagement/SystemTenantServiceUsage.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource.model.systemmanagement; +package org.eclipse.hawkbit.system.json.model.systemmanagement; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -18,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class TenantSystemUsageRest { +public class SystemTenantServiceUsage { private final String tenantName; private long targets; @@ -31,7 +31,7 @@ public class TenantSystemUsageRest { * * @param tenantName */ - public TenantSystemUsageRest(final String tenantName) { + public SystemTenantServiceUsage(final String tenantName) { super(); this.tenantName = tenantName; } diff --git a/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/rest/api/SystemManagementRestApi.java b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/rest/api/SystemManagementRestApi.java new file mode 100644 index 000000000..9e7864439 --- /dev/null +++ b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/rest/api/SystemManagementRestApi.java @@ -0,0 +1,64 @@ +/** + * 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.system.rest.api; + +import java.util.Collection; + +import org.eclipse.hawkbit.system.json.model.systemmanagement.SystemCache; +import org.eclipse.hawkbit.system.json.model.systemmanagement.SystemStatisticsRest; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * {@link SystemManagement} capabilities by REST. + * + */ +@RequestMapping(SystemRestConstant.SYSTEM_ADMIN_MAPPING) +public interface SystemManagementRestApi { + + /** + * Deletes the tenant data of a given tenant. USE WITH CARE! + * + * @param tenant + * to delete + * @return HttpStatus.OK + */ + @RequestMapping(method = RequestMethod.DELETE, value = "/tenants/{tenant}") + ResponseEntity deleteTenant(@PathVariable final String tenant); + + /** + * Collects and returns system usage statistics. It provides a system wide + * overview and tenant based stats. + * + * @return system usage statistics + */ + @RequestMapping(method = RequestMethod.GET, value = "/usage", produces = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity getSystemUsageStats(); + + /** + * Returns a list of all caches. + * + * @return a list of caches for all tenants + */ + @RequestMapping(method = RequestMethod.GET, value = "/caches") + ResponseEntity> getCaches(); + + /** + * Invalidates all caches for all tenants. + * + * @return a list of cache names which has been invalidated + */ + @RequestMapping(method = RequestMethod.DELETE, value = "/caches") + ResponseEntity> invalidateCaches(); + +} diff --git a/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/rest/api/SystemRestApi.java b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/rest/api/SystemRestApi.java new file mode 100644 index 000000000..aa764d82a --- /dev/null +++ b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/rest/api/SystemRestApi.java @@ -0,0 +1,86 @@ +/** + * 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.system.rest.api; + +import java.util.Map; + +import org.eclipse.hawkbit.system.json.model.system.SystemTenantConfigurationValue; +import org.eclipse.hawkbit.system.json.model.system.SystemTenantConfigurationValueRequest; +import org.springframework.hateoas.ResourceSupport; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * REST Resource handling tenant specific configuration operations. + * + * + */ +@RequestMapping(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING) +public interface SystemRestApi { + + @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity getSystem(); + + /** + * @return a Map of all configuration values. + */ + @RequestMapping(method = RequestMethod.GET, value = "/configs", produces = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity> getSystemConfiguration(); + + /** + * Handles the DELETE request of deleting a tenant specific configuration + * value within SP. + * + * @param keyName + * the Name of the configuration key + * @return If the given configuration value exists and could be deleted Http + * OK. In any failure the JsonResponseExceptionHandler is handling + * the response. + */ + @RequestMapping(method = RequestMethod.DELETE, value = "/configs/{keyName}", produces = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity deleteConfigurationValue(@PathVariable final String keyName); + + /** + * Handles the GET request of deleting a tenant specific configuration value + * within SP. + * + * @param keyName + * the Name of the configuration key + * @return If the given configuration value exists and could be get Http OK. + * In any failure the JsonResponseExceptionHandler is handling the + * response. + */ + @RequestMapping(method = RequestMethod.GET, value = "/configs/{keyName}", produces = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity getConfigurationValue(@PathVariable final String keyName); + + /** + * Handles the GET request of deleting a tenant specific configuration value + * within SP. + * + * @param keyName + * the Name of the configuration key + * @param configurationValueRest + * the new value for the configuration + * @return If the given configuration value exists and could be get Http OK. + * In any failure the JsonResponseExceptionHandler is handling the + * response. + */ + @RequestMapping(method = RequestMethod.PUT, value = "/configs/{keyName}", consumes = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity updateConfigurationValue(@PathVariable final String keyName, + @RequestBody final SystemTenantConfigurationValueRequest configurationValueRest); + +} \ No newline at end of file diff --git a/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/rest/api/SystemRestConstant.java b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/rest/api/SystemRestConstant.java new file mode 100644 index 000000000..cb10ba8b2 --- /dev/null +++ b/hawkbit-system-api/src/main/java/org/eclipse/hawkbit/system/rest/api/SystemRestConstant.java @@ -0,0 +1,41 @@ +/** + * 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.system.rest.api; + +/** + * + */ +public final class SystemRestConstant { + + /** + * API version definition. We are using only major versions. + */ + public static final String API_VERSION = "v1"; + + /** + * The base URL mapping for the spring acuator management context path. + */ + public static final String BASE_SYSTEM_MAPPING = "/system"; + + /** + * The base URL mapping of the SP rest resources. + */ + public static final String BASE_V1_REQUEST_MAPPING = "/rest/" + API_VERSION; + + /** + * URL mapping for system admin operations. + */ + public static final String SYSTEM_ADMIN_MAPPING = BASE_SYSTEM_MAPPING + "/admin"; + + public static final String SYSTEM_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + BASE_SYSTEM_MAPPING; + + private SystemRestConstant() { + + } +} diff --git a/hawkbit-system-resource/pom.xml b/hawkbit-system-resource/pom.xml new file mode 100644 index 000000000..fed198db3 --- /dev/null +++ b/hawkbit-system-resource/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + + org.eclipse.hawkbit + hawkbit-parent + 0.2.0-SNAPSHOT + + hawkbit-system-resource + hawkBit :: REST Resources + + + + + org.eclipse.hawkbit + hawkbit-repository + ${project.version} + + + org.eclipse.hawkbit + hawkbit-system-api + ${project.version} + + + org.eclipse.hawkbit + hawkbit-rest-core + ${project.version} + + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.easytesting + fest-assert-core + test + + + org.eclipse.hawkbit + hawkbit-repository + ${project.version} + tests + test + + + org.easytesting + fest-assert + test + + + ru.yandex.qatools.allure + allure-junit-adaptor + test + + + \ No newline at end of file diff --git a/hawkbit-system-resource/src/main/java/org/eclipse/hawkbit/system/annotation/EnableSystemApi.java b/hawkbit-system-resource/src/main/java/org/eclipse/hawkbit/system/annotation/EnableSystemApi.java new file mode 100644 index 000000000..209dfdd95 --- /dev/null +++ b/hawkbit-system-resource/src/main/java/org/eclipse/hawkbit/system/annotation/EnableSystemApi.java @@ -0,0 +1,30 @@ +/** + * 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.system.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Controller; + +/** + * Annotation to enable {@link ComponentScan} in the resource package to setup + * all {@link Controller} annotated classes and setup the System API. + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Configuration +@ComponentScan +public @interface EnableSystemApi { + +} diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java b/hawkbit-system-resource/src/main/java/org/eclipse/hawkbit/system/rest/resource/SystemManagementResource.java similarity index 71% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java rename to hawkbit-system-resource/src/main/java/org/eclipse/hawkbit/system/rest/resource/SystemManagementResource.java index 27cfdb924..074cf444d 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java +++ b/hawkbit-system-resource/src/main/java/org/eclipse/hawkbit/system/rest/resource/SystemManagementResource.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.system.rest.resource; import java.util.Collection; import java.util.Collections; @@ -17,43 +17,32 @@ import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.report.model.SystemUsageReport; import org.eclipse.hawkbit.report.model.TenantUsage; import org.eclipse.hawkbit.repository.SystemManagement; -import org.eclipse.hawkbit.repository.TenantConfigurationManagement; -import org.eclipse.hawkbit.rest.resource.model.systemmanagement.CacheRest; -import org.eclipse.hawkbit.rest.resource.model.systemmanagement.SystemStatisticsRest; -import org.eclipse.hawkbit.rest.resource.model.systemmanagement.TenantSystemUsageRest; +import org.eclipse.hawkbit.system.json.model.systemmanagement.SystemCache; +import org.eclipse.hawkbit.system.json.model.systemmanagement.SystemStatisticsRest; +import org.eclipse.hawkbit.system.json.model.systemmanagement.SystemTenantServiceUsage; +import org.eclipse.hawkbit.system.rest.api.SystemManagementRestApi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; /** * {@link SystemManagement} capabilities by REST. * - * - * - * */ @RestController -@RequestMapping(RestConstants.SYSTEM_ADMIN_MAPPING) -public class SystemManagementResource { +public class SystemManagementResource implements SystemManagementRestApi { private static final Logger LOGGER = LoggerFactory.getLogger(SystemManagementResource.class); @Autowired private SystemManagement systemManagement; - @Autowired - private TenantConfigurationManagement tenantConfigurationManagement; - @Autowired private CacheManager cacheManager; @@ -64,10 +53,9 @@ public class SystemManagementResource { * to delete * @return HttpStatus.OK */ - @RequestMapping(method = RequestMethod.DELETE, value = "/tenants/{tenant}") - public ResponseEntity deleteTenant(@PathVariable final String tenant) { + @Override + public ResponseEntity deleteTenant(final String tenant) { systemManagement.deleteTenant(tenant); - return new ResponseEntity<>(HttpStatus.OK); } @@ -77,8 +65,7 @@ public class SystemManagementResource { * * @return system usage statistics */ - @RequestMapping(method = RequestMethod.GET, value = "/usage", produces = { "application/hal+json", - MediaType.APPLICATION_JSON_VALUE }) + @Override public ResponseEntity getSystemUsageStats() { final SystemUsageReport report = systemManagement.getSystemUsageStatistics(); @@ -93,8 +80,8 @@ public class SystemManagementResource { return ResponseEntity.ok(result); } - private static TenantSystemUsageRest convertTenant(final TenantUsage tenant) { - final TenantSystemUsageRest result = new TenantSystemUsageRest(tenant.getTenantName()); + private static SystemTenantServiceUsage convertTenant(final TenantUsage tenant) { + final SystemTenantServiceUsage result = new SystemTenantServiceUsage(tenant.getTenantName()); result.setActions(tenant.getActions()); result.setArtifacts(tenant.getArtifacts()); result.setOverallArtifactVolumeInBytes(tenant.getOverallArtifactVolumeInBytes()); @@ -108,9 +95,9 @@ public class SystemManagementResource { * * @return a list of caches for all tenants */ - @RequestMapping(method = RequestMethod.GET, value = "/caches") + @Override @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN) - public ResponseEntity> getCaches() { + public ResponseEntity> getCaches() { final Collection cacheNames = cacheManager.getCacheNames(); return ResponseEntity .ok(cacheNames.stream().map(cacheManager::getCache).map(this::cacheRest).collect(Collectors.toList())); @@ -121,8 +108,8 @@ public class SystemManagementResource { * * @return a list of cache names which has been invalidated */ - @RequestMapping(method = RequestMethod.DELETE, value = "/caches") @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN) + @Override public ResponseEntity> invalidateCaches() { final Collection cacheNames = cacheManager.getCacheNames(); LOGGER.info("Invalidating caches {}", cacheNames); @@ -130,20 +117,20 @@ public class SystemManagementResource { return ResponseEntity.ok(cacheNames); } - private CacheRest cacheRest(final Cache cache) { + private SystemCache cacheRest(final Cache cache) { final Object nativeCache = cache.getNativeCache(); if (nativeCache instanceof com.google.common.cache.Cache) { return guavaCache(cache, nativeCache); } else { - return new CacheRest(cache.getName(), Collections.emptyList()); + return new SystemCache(cache.getName(), Collections.emptyList()); } } @SuppressWarnings("unchecked") - private CacheRest guavaCache(final Cache cache, final Object nativeCache) { + private SystemCache guavaCache(final Cache cache, final Object nativeCache) { final com.google.common.cache.Cache guavaCache = (com.google.common.cache.Cache) nativeCache; final List keys = guavaCache.asMap().keySet().stream().map(key -> key.toString()) .collect(Collectors.toList()); - return new CacheRest(cache.getName(), keys); + return new SystemCache(cache.getName(), keys); } } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemMapper.java b/hawkbit-system-resource/src/main/java/org/eclipse/hawkbit/system/rest/resource/SystemMapper.java similarity index 81% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemMapper.java rename to hawkbit-system-resource/src/main/java/org/eclipse/hawkbit/system/rest/resource/SystemMapper.java index 0f8119b53..3a7b39029 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemMapper.java +++ b/hawkbit-system-resource/src/main/java/org/eclipse/hawkbit/system/rest/resource/SystemMapper.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.system.rest.resource; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; @@ -16,7 +16,7 @@ import java.util.Map; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; -import org.eclipse.hawkbit.rest.resource.model.system.TenantConfigurationValueRest; +import org.eclipse.hawkbit.system.json.model.system.SystemTenantConfigurationValue; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; /** @@ -34,10 +34,10 @@ public class SystemMapper { * instance of TenantConfigurationManagement * @return a map of all existing configuration values */ - public static Map toResponse( + public static Map toResponse( final TenantConfigurationManagement tenantConfigurationManagement) { - final Map configurationMap = new HashMap<>(); + final Map configurationMap = new HashMap<>(); for (final TenantConfigurationKey key : TenantConfigurationKey.values()) { configurationMap.put(key.getKeyName(), @@ -49,15 +49,15 @@ public class SystemMapper { /** * maps a TenantConfigurationValue from the repository model to a - * TenantConfigurationValueRest, the RESTful model. + * SystemTenantConfigurationValue, the RESTful model. * * @param repoConfValue * configuration value as repository model * @return configuration value as RESTful model */ - public static TenantConfigurationValueRest toResponse(final String key, + public static SystemTenantConfigurationValue toResponse(final String key, final TenantConfigurationValue repoConfValue) { - final TenantConfigurationValueRest restConfValue = new TenantConfigurationValueRest(); + final SystemTenantConfigurationValue restConfValue = new SystemTenantConfigurationValue(); restConfValue.setValue(repoConfValue.getValue()); restConfValue.setGlobal(repoConfValue.isGlobal()); diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemResource.java b/hawkbit-system-resource/src/main/java/org/eclipse/hawkbit/system/rest/resource/SystemResource.java similarity index 67% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemResource.java rename to hawkbit-system-resource/src/main/java/org/eclipse/hawkbit/system/rest/resource/SystemResource.java index 9f2201868..ca9b84df4 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemResource.java +++ b/hawkbit-system-resource/src/main/java/org/eclipse/hawkbit/system/rest/resource/SystemResource.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.system.rest.resource; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; @@ -15,20 +15,16 @@ import java.util.Map; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; -import org.eclipse.hawkbit.rest.resource.model.system.TenantConfigurationValueRequest; -import org.eclipse.hawkbit.rest.resource.model.system.TenantConfigurationValueRest; +import org.eclipse.hawkbit.system.json.model.system.SystemTenantConfigurationValue; +import org.eclipse.hawkbit.system.json.model.system.SystemTenantConfigurationValueRequest; +import org.eclipse.hawkbit.system.rest.api.SystemRestApi; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.hateoas.ResourceSupport; import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; /** @@ -39,15 +35,14 @@ import org.springframework.web.bind.annotation.RestController; * */ @RestController -@RequestMapping(RestConstants.SYSTEM_V1_REQUEST_MAPPING) -public class SystemResource { +public class SystemResource implements SystemRestApi { private static final Logger LOG = LoggerFactory.getLogger(SystemResource.class); @Autowired private TenantConfigurationManagement tenantConfigurationManagement; - @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) + @Override public ResponseEntity getSystem() { final ResourceSupport resourceSupport = new ResourceSupport(); resourceSupport.add(linkTo(methodOn(SystemResource.class).getSystemConfiguration()).withRel("configs")); @@ -57,9 +52,8 @@ public class SystemResource { /** * @return a Map of all configuration values. */ - @RequestMapping(method = RequestMethod.GET, value = "/configs", produces = { "application/hal+json", - MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> getSystemConfiguration() { + @Override + public ResponseEntity> getSystemConfiguration() { return new ResponseEntity<>(SystemMapper.toResponse(tenantConfigurationManagement), HttpStatus.OK); } @@ -73,9 +67,8 @@ public class SystemResource { * OK. In any failure the JsonResponseExceptionHandler is handling * the response. */ - @RequestMapping(method = RequestMethod.DELETE, value = "/configs/{keyName}", produces = { "application/hal+json", - MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity deleteConfigurationValue(@PathVariable final String keyName) { + @Override + public ResponseEntity deleteConfigurationValue(final String keyName) { final TenantConfigurationKey configKey = TenantConfigurationKey.fromKeyName(keyName); @@ -95,9 +88,8 @@ public class SystemResource { * In any failure the JsonResponseExceptionHandler is handling the * response. */ - @RequestMapping(method = RequestMethod.GET, value = "/configs/{keyName}", produces = { "application/hal+json", - MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getConfigurationValue(@PathVariable final String keyName) { + @Override + public ResponseEntity getConfigurationValue(final String keyName) { final TenantConfigurationKey configKey = TenantConfigurationKey.fromKeyName(keyName); @@ -118,10 +110,9 @@ public class SystemResource { * In any failure the JsonResponseExceptionHandler is handling the * response. */ - @RequestMapping(method = RequestMethod.PUT, value = "/configs/{keyName}", consumes = { "application/hal+json", - MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity updateConfigurationValue(@PathVariable final String keyName, - @RequestBody final TenantConfigurationValueRequest configurationValueRest) { + @Override + public ResponseEntity updateConfigurationValue(final String keyName, + final SystemTenantConfigurationValueRequest configurationValueRest) { final TenantConfigurationKey configKey = TenantConfigurationKey.fromKeyName(keyName); diff --git a/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/MockMvcResultPrinter.java b/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/MockMvcResultPrinter.java new file mode 100644 index 000000000..de82640dc --- /dev/null +++ b/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/MockMvcResultPrinter.java @@ -0,0 +1,55 @@ +/** + * 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.system.rest.resource; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.ResultHandler; +import org.springframework.test.web.servlet.result.PrintingResultHandler; +import org.springframework.util.CollectionUtils; + +public abstract class MockMvcResultPrinter { + private static final Logger LOG = LoggerFactory.getLogger(MockMvcResultPrinter.class); + + private MockMvcResultPrinter() { + } + + /** + * Print {@link MvcResult} details to the "standard" output stream. + */ + public static ResultHandler print() { + return new ConsolePrintingResultHandler(); + } + + /** + * An {@link PrintingResultHandler} that writes to the "standard" output + * stream + */ + private static class ConsolePrintingResultHandler extends PrintingResultHandler { + + public ConsolePrintingResultHandler() { + super(new ResultValuePrinter() { + + @Override + public void printHeading(final String heading) { + LOG.debug(String.format("%20s:", heading)); + } + + @Override + public void printValue(final String label, Object value) { + if (value != null && value.getClass().isArray()) { + value = CollectionUtils.arrayToList(value); + } + LOG.debug(String.format("%20s = %s", label, value)); + } + }); + } + } +} diff --git a/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/ResourceUtility.java b/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/ResourceUtility.java new file mode 100644 index 000000000..1b2772530 --- /dev/null +++ b/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/ResourceUtility.java @@ -0,0 +1,32 @@ +/** + * 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.system.rest.resource; + +import java.io.IOException; + +import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * Utility additions for the REST API tests. + * + * + */ +public final class ResourceUtility { + private static final ObjectMapper mapper = new ObjectMapper(); + + static ExceptionInfo convertException(final String jsonExceptionResponse) + throws JsonParseException, JsonMappingException, IOException { + return mapper.readValue(jsonExceptionResponse, ExceptionInfo.class); + } + +} diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SystemManagementResourceTest.java b/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/SystemManagementResourceTest.java similarity index 98% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SystemManagementResourceTest.java rename to hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/SystemManagementResourceTest.java index 76cd68d64..38a8f1b11 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SystemManagementResourceTest.java +++ b/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/SystemManagementResourceTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.system.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; @@ -21,7 +21,6 @@ import java.util.List; import java.util.Random; import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB; -import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.WithSpringAuthorityRule; import org.eclipse.hawkbit.WithUser; @@ -40,7 +39,7 @@ import ru.yandex.qatools.allure.annotations.Stories; * * */ -@Features("Component Tests - Management API") +@Features("Component Tests - System API") @Stories("System Management Resource") public class SystemManagementResourceTest extends AbstractIntegrationTestWithMongoDB { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/ConfigurationResourceTest.java b/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/SystemResourceTest.java similarity index 87% rename from hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/ConfigurationResourceTest.java rename to hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/SystemResourceTest.java index 39e571a2c..13ccf0999 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/ConfigurationResourceTest.java +++ b/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/SystemResourceTest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.rest.resource; +package org.eclipse.hawkbit.system.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; @@ -19,10 +19,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import org.eclipse.hawkbit.AbstractIntegrationTest; -import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; -import org.eclipse.hawkbit.rest.resource.model.ExceptionInfo; +import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; +import org.eclipse.hawkbit.system.rest.api.SystemRestConstant; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; import org.junit.Test; import org.springframework.http.MediaType; @@ -33,9 +33,9 @@ import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -@Features("Component Tests - Management RESTful API") +@Features("Component Tests - System RESTful API") @Stories("ConfigurationResource") -public class ConfigurationResourceTest extends AbstractIntegrationTest { +public class SystemResourceTest extends AbstractIntegrationTest { private static String BASE_JSON_REQUEST_STRING = "{\"value\":\"%s\"}"; @@ -43,7 +43,7 @@ public class ConfigurationResourceTest extends AbstractIntegrationTest { @Description("perform a GET request on all existing configurations.") public void getConfigurationValues() throws Exception { - final ResultActions resultActions = mvc.perform(get(RestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/")) + final ResultActions resultActions = mvc.perform(get(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING + "/configs/")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("$.*", hasSize(TenantConfigurationKey.values().length))); @@ -64,7 +64,7 @@ public class ConfigurationResourceTest extends AbstractIntegrationTest { tenantConfigurationManagement.addOrUpdateConfiguration(key, notGlobalValue); - mvc.perform(get(RestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{configId}/", key.getKeyName())) + mvc.perform(get(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING + "/configs/{configId}/", key.getKeyName())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("value", equalTo(notGlobalValue))).andExpect(jsonPath("global", equalTo(false))) .andExpect(jsonPath("createdAt", notNullValue())).andExpect(jsonPath("createdBy", notNullValue())); @@ -77,7 +77,7 @@ public class ConfigurationResourceTest extends AbstractIntegrationTest { final TenantConfigurationKey key = TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME; final String testValue = "12:12:12"; - mvc.perform(put(RestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{configId}/", key.getKeyName()) + mvc.perform(put(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING + "/configs/{configId}/", key.getKeyName()) .content(String.format(BASE_JSON_REQUEST_STRING, testValue)).contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); @@ -98,7 +98,7 @@ public class ConfigurationResourceTest extends AbstractIntegrationTest { assertThat(tenantConfigurationManagement.getConfigurationValue(key, String.class).getValue()) .isEqualTo(notGlobalValue); - mvc.perform(delete(RestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{configId}/", key.getKeyName())) + mvc.perform(delete(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING + "/configs/{configId}/", key.getKeyName())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isNoContent()); assertThat(tenantConfigurationManagement.getConfigurationValue(key, String.class).isGlobal()).isEqualTo(true); @@ -114,7 +114,7 @@ public class ConfigurationResourceTest extends AbstractIntegrationTest { final String testValue = "12:12:12"; final MvcResult mvcResult = mvc - .perform(put(RestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{configId}", notExistingKey) + .perform(put(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING + "/configs/{configId}", notExistingKey) .content(String.format(BASE_JSON_REQUEST_STRING, testValue)) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn(); @@ -133,7 +133,7 @@ public class ConfigurationResourceTest extends AbstractIntegrationTest { final String testValue = "invalidFormattedDuration"; final MvcResult mvcResult = mvc - .perform(put(RestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{configId}", key.getKeyName()) + .perform(put(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING + "/configs/{configId}", key.getKeyName()) .content(String.format(BASE_JSON_REQUEST_STRING, testValue)) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn(); diff --git a/hawkbit-system-resource/src/test/resources/application-test.properties b/hawkbit-system-resource/src/test/resources/application-test.properties new file mode 100644 index 000000000..92506caa4 --- /dev/null +++ b/hawkbit-system-resource/src/test/resources/application-test.properties @@ -0,0 +1,63 @@ +# +# 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 +# + +# used if IM profile is disabled +security.ignored=true + +# IM required for integration tests +spring.profiles.active=im,suiteembedded,artifactrepository,redis + +server.port=12222 + +spring.data.mongodb.uri=mongodb://localhost/spArtifactRepository${random.value} +spring.data.mongodb.port=28017 + + +# supported: H2, MYSQL +hawkbit.server.database=H2 +hawkbit.server.database.env=TEST +spring.main.show_banner=false + +hawkbit.server.ddi.security.authentication.header=true + +hawkbit.server.artifact.repo.upload.maxFileSize=5MB + +hawkbit.server.security.dos.maxStatusEntriesPerAction=100 + +hawkbit.server.security.dos.maxAttributeEntriesPerTarget=10 + +spring.jpa.database=${hawkbit.server.database} +#spring.jpa.show-sql=true + + +flyway.sqlMigrationSuffix=${spring.jpa.database}.sql + +# effective DB setting +spring.datasource.url=${${hawkbit.server.database}.spring.datasource.url} +spring.datasource.driverClassName=${${hawkbit.server.database}.spring.datasource.driverClassName} +spring.datasource.username=${${hawkbit.server.database}.spring.datasource.username} +spring.datasource.password=${${hawkbit.server.database}.spring.datasource.password} + +# H2 +##;AUTOCOMMIT=ON +H2.spring.datasource.url=jdbc:h2:mem:sp-db;DB_CLOSE_ON_EXIT=FALSE +#H2.spring.datasource.url=jdbc:h2:./db/sp-db;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE;MVCC=TRUE +H2.spring.datasource.driverClassName=org.h2.Driver +H2.spring.datasource.username=sa +H2.spring.datasource.password=sa + +# MYSQL +MYSQL.spring.datasource.url=jdbc:mysql://localhost:3306/sp_test +MYSQL.spring.datasource.driverClassName=org.mariadb.jdbc.Driver +MYSQL.spring.datasource.username=root +MYSQL.spring.datasource.password= + +# SP Controller configuration +hawkbit.controller.pollingTime=00:01:00 +hawkbit.controller.pollingOverdueTime=00:01:00 diff --git a/pom.xml b/pom.xml index 11374a16d..0260683ba 100644 --- a/pom.xml +++ b/pom.xml @@ -24,24 +24,27 @@ hawkBit :: Parent - hawkbit-dmf-api - hawkbit-rest-api - hawkbit-ddi-api hawkbit-core hawkbit-security-core - hawkbit-repository + hawkbit-rest-core + hawkbit-system-api + hawkbit-system-resource + hawkbit-mgmt-api + hawkbit-mgmt-resource + hawkbit-ddi-api + hawkbit-ddi-resource + hawkbit-dmf-api hawkbit-dmf-amqp + hawkbit-repository hawkbit-security-integration hawkbit-http-security - hawkbit-rest-resource - hawkbit-ddi-resource hawkbit-ui hawkbit-artifact-repository-mongo hawkbit-autoconfigure hawkbit-cache-redis hawkbit-test-report - examples - + examples +