Merge branch 'Extend_end-2-end_tests_for_full_DDI_roundtrip_with_Java_client' of https://github.com/bsinno/hawkbit.git into Extend_end-2-end_tests_for_full_DDI_roundtrip_with_Java_client
Conflicts: hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/api/RootControllerDdiApi.java Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
@@ -10,7 +10,7 @@ package org.eclipse.hawkbit.app;
|
||||
|
||||
import org.eclipse.hawkbit.RepositoryApplicationConfiguration;
|
||||
import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration;
|
||||
import org.eclipse.hawkbit.ddi.resource.EnableDirectDeviceApi;
|
||||
import org.eclipse.hawkbit.ddi.annotation.EnableDdiApi;
|
||||
import org.eclipse.hawkbit.rest.resource.EnableRestResources;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -25,7 +25,7 @@ import org.springframework.context.annotation.Import;
|
||||
@Import({ RepositoryApplicationConfiguration.class })
|
||||
@EnableHawkbitManagedSecurityConfiguration
|
||||
@EnableRestResources
|
||||
@EnableDirectDeviceApi
|
||||
@EnableDdiApi
|
||||
public class Start {
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,9 +6,9 @@ package org.eclipse.hawkbit.ddi.client;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.hawkbit.ddi.ControllerConstants;
|
||||
import org.eclipse.hawkbit.ddi.client.resource.RootControllerResourceClient;
|
||||
import org.eclipse.hawkbit.ddi.model.ControllerBase;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiControllerBase;
|
||||
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.netflix.feign.support.ResponseEntityDecoder;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -39,7 +39,7 @@ public class DdiClient {
|
||||
this.controllerId = controllerId;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
rootControllerResourcePath = rolloutsUrl + ControllerConstants.BASE_V1_REQUEST_MAPPING;
|
||||
rootControllerResourcePath = rolloutsUrl + DdiRestConstants.BASE_V1_REQUEST_MAPPING;
|
||||
rootControllerResourcePath = rootControllerResourcePath.replace("{tenant}", tenant);
|
||||
|
||||
createFeignClient();
|
||||
@@ -71,8 +71,9 @@ public class DdiClient {
|
||||
|
||||
// final HttpServletRequest request = new;
|
||||
|
||||
final ResponseEntity<ControllerBase> response = rootControllerResourceClient.getControllerBase("test", request);
|
||||
final ControllerBase controllerBase = response.getBody();
|
||||
final ResponseEntity<DdiControllerBase> response = rootControllerResourceClient.getControllerBase("test",
|
||||
request);
|
||||
final DdiControllerBase controllerBase = response.getBody();
|
||||
|
||||
// TODO notify every 10 seconds on the rollout server
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.ddi.api.RootControllerDdiApi;
|
||||
import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
* Client binding for the Rootcontroller resource of the DDI API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/{tenant}/controller/v1")
|
||||
public interface RootControllerResourceClient extends RootControllerDdiApi {
|
||||
public interface RootControllerResourceClient extends DdiRootControllerRestApi {
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.autoconfigure.web;
|
||||
|
||||
import org.eclipse.hawkbit.ddi.resource.EnableDirectDeviceApi;
|
||||
import org.eclipse.hawkbit.ddi.annotation.EnableDdiApi;
|
||||
import org.eclipse.hawkbit.rest.resource.EnableRestResources;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -21,8 +21,8 @@ import org.springframework.context.annotation.Import;
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({ EnableDirectDeviceApi.class, EnableRestResources.class })
|
||||
@Import({ EnableDirectDeviceApi.class, EnableRestResources.class })
|
||||
@ConditionalOnClass({ EnableDdiApi.class, EnableRestResources.class })
|
||||
@Import({ EnableDdiApi.class, EnableRestResources.class })
|
||||
public class ResourceControllerAutoConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -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.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -25,6 +25,6 @@ import org.springframework.stereotype.Controller;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
public @interface EnableDirectDeviceApi {
|
||||
public @interface EnableDdiApi {
|
||||
|
||||
}
|
||||
@@ -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.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@@ -35,12 +35,12 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
*
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ActionFeedback {
|
||||
public class DdiActionFeedback {
|
||||
private final Long id;
|
||||
private final String time;
|
||||
|
||||
@NotNull
|
||||
private final Status status;
|
||||
private final DdiStatus status;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -53,8 +53,8 @@ public class ActionFeedback {
|
||||
* is the feedback itself
|
||||
*/
|
||||
@JsonCreator
|
||||
public ActionFeedback(@JsonProperty("id") final Long id, @JsonProperty("time") final String time,
|
||||
@JsonProperty("status") final Status status) {
|
||||
public DdiActionFeedback(@JsonProperty("id") final Long id, @JsonProperty("time") final String time,
|
||||
@JsonProperty("status") final DdiStatus status) {
|
||||
this.id = id;
|
||||
this.time = time;
|
||||
this.status = status;
|
||||
@@ -68,7 +68,7 @@ public class ActionFeedback {
|
||||
return time;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
public DdiStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -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.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@@ -16,9 +16,9 @@ import org.springframework.hateoas.ResourceSupport;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Download information for all artifacts related to a specific {@link Chunk}.
|
||||
* Download information for all artifacts related to a specific {@link DdiChunk}.
|
||||
*/
|
||||
public class Artifact extends ResourceSupport {
|
||||
public class DdiArtifact extends ResourceSupport {
|
||||
|
||||
@NotNull
|
||||
@JsonProperty
|
||||
@@ -6,19 +6,19 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Cancel action to be provided to the target.
|
||||
*/
|
||||
public class Cancel {
|
||||
public class DdiCancel {
|
||||
|
||||
private final String id;
|
||||
|
||||
@NotNull
|
||||
private final CancelActionToStop cancelAction;
|
||||
private final DdiCancelActionToStop cancelAction;
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
@@ -28,7 +28,7 @@ public class Cancel {
|
||||
* @param cancelAction
|
||||
* the action
|
||||
*/
|
||||
public Cancel(final String id, final CancelActionToStop cancelAction) {
|
||||
public DdiCancel(final String id, final DdiCancelActionToStop cancelAction) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.cancelAction = cancelAction;
|
||||
@@ -38,7 +38,7 @@ public class Cancel {
|
||||
return id;
|
||||
}
|
||||
|
||||
public CancelActionToStop getCancelAction() {
|
||||
public DdiCancelActionToStop getCancelAction() {
|
||||
return cancelAction;
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* The {@link Action} that has to be stopped by the target.
|
||||
*/
|
||||
public class CancelActionToStop {
|
||||
public class DdiCancelActionToStop {
|
||||
|
||||
@NotNull
|
||||
private final String stopId;
|
||||
@@ -24,7 +24,7 @@ public class CancelActionToStop {
|
||||
* @param stopId
|
||||
* ID of the {@link Action} to be stoppedW
|
||||
*/
|
||||
public CancelActionToStop(final String stopId) {
|
||||
public DdiCancelActionToStop(final String stopId) {
|
||||
super();
|
||||
this.stopId = stopId;
|
||||
}
|
||||
@@ -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.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -15,7 +15,7 @@ import javax.validation.constraints.NotNull;
|
||||
/**
|
||||
* Deployment chunks.
|
||||
*/
|
||||
public class Chunk {
|
||||
public class DdiChunk {
|
||||
|
||||
@NotNull
|
||||
private final String part;
|
||||
@@ -26,7 +26,7 @@ public class Chunk {
|
||||
@NotNull
|
||||
private final String name;
|
||||
|
||||
private final List<Artifact> artifacts;
|
||||
private final List<DdiArtifact> artifacts;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -40,7 +40,7 @@ public class Chunk {
|
||||
* @param artifacts
|
||||
* download information
|
||||
*/
|
||||
public Chunk(final String part, final String version, final String name, final List<Artifact> artifacts) {
|
||||
public DdiChunk(final String part, final String version, final String name, final List<DdiArtifact> artifacts) {
|
||||
super();
|
||||
this.part = part;
|
||||
this.version = version;
|
||||
@@ -60,7 +60,7 @@ public class Chunk {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<Artifact> getArtifacts() {
|
||||
public List<DdiArtifact> getArtifacts() {
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
/**
|
||||
* Standard configuration for the target.
|
||||
*/
|
||||
public class Config {
|
||||
public class DdiConfig {
|
||||
|
||||
private final Polling polling;
|
||||
private final DdiPolling polling;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -21,12 +21,12 @@ public class Config {
|
||||
* @param polling
|
||||
* configuration of the SP target
|
||||
*/
|
||||
public Config(final Polling polling) {
|
||||
public DdiConfig(final DdiPolling polling) {
|
||||
super();
|
||||
this.polling = polling;
|
||||
}
|
||||
|
||||
public Polling getPolling() {
|
||||
public DdiPolling getPolling() {
|
||||
return polling;
|
||||
}
|
||||
|
||||
@@ -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.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
/**
|
||||
* Feedback channel for ConfigData action.
|
||||
*/
|
||||
public class ConfigData extends ActionFeedback {
|
||||
public class DdiConfigData extends DdiActionFeedback {
|
||||
|
||||
@NotEmpty
|
||||
private final Map<String, String> data;
|
||||
@@ -36,8 +36,8 @@ public class ConfigData extends ActionFeedback {
|
||||
* contains the attributes.
|
||||
*/
|
||||
@JsonCreator
|
||||
public ConfigData(@JsonProperty(value = "id") final Long id, @JsonProperty(value = "time") final String time,
|
||||
@JsonProperty(value = "status") final Status status,
|
||||
public DdiConfigData(@JsonProperty(value = "id") final Long id, @JsonProperty(value = "time") final String time,
|
||||
@JsonProperty(value = "status") final DdiStatus status,
|
||||
@JsonProperty(value = "data") final Map<String, String> data) {
|
||||
super(id, time, status);
|
||||
this.data = data;
|
||||
@@ -6,16 +6,16 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
|
||||
/**
|
||||
* {@link ControllerBase} resource content.
|
||||
* {@link DdiControllerBase} resource content.
|
||||
*/
|
||||
public class ControllerBase extends ResourceSupport {
|
||||
public class DdiControllerBase extends ResourceSupport {
|
||||
|
||||
private final Config config;
|
||||
private final DdiConfig config;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -23,12 +23,12 @@ public class ControllerBase extends ResourceSupport {
|
||||
* @param config
|
||||
* configuration of the SP target
|
||||
*/
|
||||
public ControllerBase(final Config config) {
|
||||
public DdiControllerBase(final DdiConfig config) {
|
||||
super();
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public Config getConfig() {
|
||||
public DdiConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -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.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -15,13 +15,13 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
/**
|
||||
* Detailed {@link UpdateAction} information.
|
||||
*/
|
||||
public class Deployment {
|
||||
public class DdiDeployment {
|
||||
|
||||
private final HandlingType download;
|
||||
|
||||
private final HandlingType update;
|
||||
|
||||
private final List<Chunk> chunks;
|
||||
private final List<DdiChunk> chunks;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -33,7 +33,7 @@ public class Deployment {
|
||||
* @param chunks
|
||||
* to handle.
|
||||
*/
|
||||
public Deployment(final HandlingType download, final HandlingType update, final List<Chunk> chunks) {
|
||||
public DdiDeployment(final HandlingType download, final HandlingType update, final List<DdiChunk> chunks) {
|
||||
super();
|
||||
this.download = download;
|
||||
this.update = update;
|
||||
@@ -48,7 +48,7 @@ public class Deployment {
|
||||
return update;
|
||||
}
|
||||
|
||||
public List<Chunk> getChunks() {
|
||||
public List<DdiChunk> getChunks() {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
@@ -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.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@@ -17,14 +17,14 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
/**
|
||||
* {@link UpdateAction} resource.
|
||||
*/
|
||||
public class DeploymentBase extends ResourceSupport {
|
||||
public class DdiDeploymentBase extends ResourceSupport {
|
||||
|
||||
@JsonProperty("id")
|
||||
@NotNull
|
||||
private final String deplyomentId;
|
||||
|
||||
@NotNull
|
||||
private final Deployment deployment;
|
||||
private final DdiDeployment deployment;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -34,12 +34,12 @@ public class DeploymentBase extends ResourceSupport {
|
||||
* @param deployment
|
||||
* details.
|
||||
*/
|
||||
public DeploymentBase(final String id, final Deployment deployment) {
|
||||
public DdiDeploymentBase(final String id, final DdiDeployment deployment) {
|
||||
deplyomentId = id;
|
||||
this.deployment = deployment;
|
||||
}
|
||||
|
||||
public Deployment getDeployment() {
|
||||
public DdiDeployment getDeployment() {
|
||||
return deployment;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
/**
|
||||
* Polling interval for the SP target.
|
||||
*/
|
||||
public class Polling {
|
||||
public class DdiPolling {
|
||||
|
||||
private final String sleep;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Polling {
|
||||
* @param sleep
|
||||
* between polls
|
||||
*/
|
||||
public Polling(final String sleep) {
|
||||
public DdiPolling(final String sleep) {
|
||||
super();
|
||||
this.sleep = sleep;
|
||||
}
|
||||
@@ -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.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
* Action fulfillment progress by means of gives the achieved amount of maximal
|
||||
* of possible levels.
|
||||
*/
|
||||
public class Progress {
|
||||
public class DdiProgress {
|
||||
|
||||
@NotNull
|
||||
private final Integer cnt;
|
||||
@@ -33,7 +33,7 @@ public class Progress {
|
||||
* maximum levels
|
||||
*/
|
||||
@JsonCreator
|
||||
public Progress(@JsonProperty("cnt") final Integer cnt, @JsonProperty("of") final Integer of) {
|
||||
public DdiProgress(@JsonProperty("cnt") final Integer cnt, @JsonProperty("of") final Integer of) {
|
||||
super();
|
||||
this.cnt = cnt;
|
||||
this.of = of;
|
||||
@@ -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.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
@@ -18,12 +18,12 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
* Result information of the action progress which can by an intermediate or
|
||||
* final update.
|
||||
*/
|
||||
public class Result {
|
||||
public class DdiResult {
|
||||
|
||||
@NotEmpty
|
||||
private final FinalResult finished;
|
||||
|
||||
private final Progress progress;
|
||||
private final DdiProgress progress;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -34,8 +34,8 @@ public class Result {
|
||||
* if not yet finished
|
||||
*/
|
||||
@JsonCreator
|
||||
public Result(@JsonProperty("finished") final FinalResult finished,
|
||||
@JsonProperty("progress") final Progress progress) {
|
||||
public DdiResult(@JsonProperty("finished") final FinalResult finished,
|
||||
@JsonProperty("progress") final DdiProgress progress) {
|
||||
super();
|
||||
this.finished = finished;
|
||||
this.progress = progress;
|
||||
@@ -45,7 +45,7 @@ public class Result {
|
||||
return finished;
|
||||
}
|
||||
|
||||
public Progress getProgress() {
|
||||
public DdiProgress getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
@@ -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.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,13 +19,13 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
/**
|
||||
* Details status information concerning the action processing.
|
||||
*/
|
||||
public class Status {
|
||||
public class DdiStatus {
|
||||
|
||||
@NotNull
|
||||
private final ExecutionStatus execution;
|
||||
|
||||
@NotNull
|
||||
private final Result result;
|
||||
private final DdiResult result;
|
||||
|
||||
private final List<String> details;
|
||||
|
||||
@@ -40,8 +40,8 @@ public class Status {
|
||||
* as optional addition
|
||||
*/
|
||||
@JsonCreator
|
||||
public Status(@JsonProperty("execution") final ExecutionStatus execution,
|
||||
@JsonProperty("result") final Result result, @JsonProperty("details") final List<String> details) {
|
||||
public DdiStatus(@JsonProperty("execution") final ExecutionStatus execution,
|
||||
@JsonProperty("result") final DdiResult result, @JsonProperty("details") final List<String> details) {
|
||||
super();
|
||||
this.execution = execution;
|
||||
this.result = result;
|
||||
@@ -52,7 +52,7 @@ public class Status {
|
||||
return execution;
|
||||
}
|
||||
|
||||
public Result getResult() {
|
||||
public DdiResult getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -6,13 +6,12 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.api;
|
||||
package org.eclipse.hawkbit.ddi.rest.api;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.hawkbit.ddi.ControllerConstants;
|
||||
import org.eclipse.hawkbit.ddi.model.Artifact;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiArtifact;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.web.bind.annotation.AuthenticationPrincipal;
|
||||
@@ -24,11 +23,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
/**
|
||||
* REST resource handling for artifact download operations.
|
||||
*/
|
||||
@RequestMapping(ControllerConstants.ARTIFACTS_V1_REQUEST_MAPPING)
|
||||
public interface ArtifactStoreControllerDdiApi {
|
||||
@RequestMapping(DdiRestConstants.ARTIFACTS_V1_REQUEST_MAPPING)
|
||||
public interface DdiArtifactStoreControllerRestApi {
|
||||
|
||||
/**
|
||||
* Handles GET {@link Artifact} download request. This could be full or
|
||||
* Handles GET {@link DdiArtifact} download request. This could be full or
|
||||
* partial download request.
|
||||
*
|
||||
* @param fileName
|
||||
@@ -44,7 +43,7 @@ public interface ArtifactStoreControllerDdiApi {
|
||||
* {@link HttpStatus#OK} or in case of partial download
|
||||
* {@link HttpStatus#PARTIAL_CONTENT}.
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = ControllerConstants.ARTIFACT_DOWNLOAD_BY_FILENAME
|
||||
@RequestMapping(method = RequestMethod.GET, value = DdiRestConstants.ARTIFACT_DOWNLOAD_BY_FILENAME
|
||||
+ "/{fileName}")
|
||||
@ResponseBody
|
||||
public ResponseEntity<Void> downloadArtifactByFilename(@PathVariable("fileName") final String fileName,
|
||||
@@ -52,7 +51,7 @@ public interface ArtifactStoreControllerDdiApi {
|
||||
@AuthenticationPrincipal final String targetid);
|
||||
|
||||
/**
|
||||
* Handles GET {@link Artifact} MD5 checksum file download request.
|
||||
* Handles GET {@link DdiArtifact} MD5 checksum file download request.
|
||||
*
|
||||
* @param fileName
|
||||
* to search for
|
||||
@@ -61,8 +60,8 @@ public interface ArtifactStoreControllerDdiApi {
|
||||
*
|
||||
* @return response of the servlet
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = ControllerConstants.ARTIFACT_DOWNLOAD_BY_FILENAME
|
||||
+ "/{fileName}" + ControllerConstants.ARTIFACT_MD5_DWNL_SUFFIX)
|
||||
@RequestMapping(method = RequestMethod.GET, value = DdiRestConstants.ARTIFACT_DOWNLOAD_BY_FILENAME
|
||||
+ "/{fileName}" + DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX)
|
||||
@ResponseBody
|
||||
public ResponseEntity<Void> downloadArtifactMD5ByFilename(@PathVariable("fileName") final String fileName,
|
||||
final HttpServletResponse response);
|
||||
@@ -6,12 +6,12 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi;
|
||||
package org.eclipse.hawkbit.ddi.rest.api;
|
||||
|
||||
/**
|
||||
* Constants for the direct device integration rest resources.
|
||||
*/
|
||||
public final class ControllerConstants {
|
||||
public final class DdiRestConstants {
|
||||
|
||||
/**
|
||||
* The base URL mapping of the direct device integration rest resources.
|
||||
@@ -59,7 +59,7 @@ public final class ControllerConstants {
|
||||
public static final String ARTIFACT_MD5_DWNL_SUFFIX = ".MD5SUM";
|
||||
|
||||
// constant class, private constructor.
|
||||
private ControllerConstants() {
|
||||
private DdiRestConstants() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2011-2016 Bosch Software Innovations GmbH, Germany. All rights reserved.
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.api;
|
||||
package org.eclipse.hawkbit.ddi.rest.api;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.eclipse.hawkbit.ddi.ControllerConstants;
|
||||
import org.eclipse.hawkbit.ddi.model.Cancel;
|
||||
import org.eclipse.hawkbit.ddi.model.ControllerBase;
|
||||
import org.eclipse.hawkbit.ddi.model.DeploymentBase;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiActionFeedback;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiArtifact;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiCancel;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiConfigData;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiControllerBase;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiDeploymentBase;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
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.RequestParam;
|
||||
@@ -23,23 +29,8 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
/**
|
||||
* REST resource handling for root controller CRUD operations.
|
||||
*/
|
||||
@RequestMapping(ControllerConstants.BASE_V1_REQUEST_MAPPING)
|
||||
public interface RootControllerDdiApi {
|
||||
|
||||
/**
|
||||
* Root resource for an individual {@link Target}.
|
||||
*
|
||||
* @param targetid
|
||||
* of the {@link Target} that matches to
|
||||
* {@link Target#getControllerId()}
|
||||
* @param request
|
||||
* the HTTP request injected by spring
|
||||
* @return the response
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}", produces = { "application/hal+json",
|
||||
MediaType.APPLICATION_JSON_VALUE })
|
||||
public ResponseEntity<ControllerBase> getControllerBase(@PathVariable("targetid") final String targetid,
|
||||
final HttpServletRequest request);
|
||||
@RequestMapping(DdiRestConstants.BASE_V1_REQUEST_MAPPING)
|
||||
public interface DdiRootControllerRestApi {
|
||||
|
||||
/**
|
||||
* Returns all artifacts of a given software module and target.
|
||||
@@ -53,12 +44,27 @@ public interface RootControllerDdiApi {
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts", produces = {
|
||||
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
||||
public ResponseEntity<List<org.eclipse.hawkbit.ddi.model.Artifact>> getSoftwareModulesArtifacts(
|
||||
ResponseEntity<List<org.eclipse.hawkbit.ddi.json.model.DdiArtifact>> getSoftwareModulesArtifacts(
|
||||
@PathVariable("targetid") final String targetid,
|
||||
@PathVariable("softwareModuleId") final Long softwareModuleId);
|
||||
|
||||
/**
|
||||
* Handles GET {@link Artifact} download request. This could be full or
|
||||
* Root resource for an individual {@link Target}.
|
||||
*
|
||||
* @param targetid
|
||||
* of the {@link Target} that matches to
|
||||
* {@link Target#getControllerId()}
|
||||
* @param request
|
||||
* the HTTP request injected by spring
|
||||
* @return the response
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}", produces = { "application/hal+json",
|
||||
MediaType.APPLICATION_JSON_VALUE })
|
||||
ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("targetid") final String targetid,
|
||||
final HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* Handles GET {@link DdiArtifact} download request. This could be full or
|
||||
* partial (as specified by RFC7233 (Range Requests)) download request.
|
||||
*
|
||||
* @param targetid
|
||||
@@ -76,17 +82,14 @@ public interface RootControllerDdiApi {
|
||||
* {@link HttpStatus#OK} or in case of partial download
|
||||
* {@link HttpStatus#PARTIAL_CONTENT}.
|
||||
*/
|
||||
// @RequestMapping(method = RequestMethod.GET, value =
|
||||
// "/{targetid}/softwaremodules/{softwareModuleId}/artifacts/{fileName}")
|
||||
// public ResponseEntity<Void> downloadArtifact(@PathVariable("targetid")
|
||||
// final String targetid,
|
||||
// @PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||
// @PathVariable("fileName") final String fileName, final
|
||||
// HttpServletResponse response,
|
||||
// final HttpServletRequest request);
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts/{fileName}")
|
||||
ResponseEntity<Void> downloadArtifact(@PathVariable("targetid") final String targetid,
|
||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||
@PathVariable("fileName") final String fileName, final HttpServletResponse response,
|
||||
final HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* Handles GET {@link Artifact} MD5 checksum file download request.
|
||||
* Handles GET {@link DdiArtifact} MD5 checksum file download request.
|
||||
*
|
||||
* @param targetid
|
||||
* of the related
|
||||
@@ -102,16 +105,12 @@ public interface RootControllerDdiApi {
|
||||
* @return {@link ResponseEntity} with status {@link HttpStatus#OK} if
|
||||
* successful
|
||||
*/
|
||||
// @RequestMapping(method = RequestMethod.GET, value =
|
||||
// "/{targetid}/softwaremodules/{softwareModuleId}/artifacts/{fileName}"
|
||||
// + ControllerConstants.ARTIFACT_MD5_DWNL_SUFFIX, produces =
|
||||
// MediaType.TEXT_PLAIN_VALUE)
|
||||
// public ResponseEntity<Void> downloadArtifactMd5(@PathVariable("targetid")
|
||||
// final String targetid,
|
||||
// @PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||
// @PathVariable("fileName") final String fileName, final
|
||||
// HttpServletResponse response,
|
||||
// final HttpServletRequest request);
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts/{fileName}"
|
||||
+ DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX, produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
ResponseEntity<Void> downloadArtifactMd5(@PathVariable("targetid") final String targetid,
|
||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||
@PathVariable("fileName") final String fileName, final HttpServletResponse response,
|
||||
final HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* Resource for {@link SoftwareModule} {@link UpdateAction}s.
|
||||
@@ -120,7 +119,7 @@ public interface RootControllerDdiApi {
|
||||
* of the {@link Target} that matches to
|
||||
* {@link Target#getControllerId()}
|
||||
* @param actionId
|
||||
* of the {@link DeploymentBase} that matches to
|
||||
* of the {@link DdiDeploymentBase} that matches to
|
||||
* {@link Target#getActiveActions()}
|
||||
* @param resource
|
||||
* an hashcode of the resource which indicates if the action has
|
||||
@@ -130,16 +129,16 @@ public interface RootControllerDdiApi {
|
||||
* the HTTP request injected by spring
|
||||
* @return the response
|
||||
*/
|
||||
@RequestMapping(value = "/{targetid}/" + ControllerConstants.DEPLOYMENT_BASE_ACTION
|
||||
@RequestMapping(value = "/{targetid}/" + DdiRestConstants.DEPLOYMENT_BASE_ACTION
|
||||
+ "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<DeploymentBase> getControllerBasedeploymentAction(
|
||||
ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(
|
||||
@PathVariable("targetid") @NotEmpty final String targetid,
|
||||
@PathVariable("actionId") @NotEmpty final Long actionId,
|
||||
@RequestParam(value = "c", required = false, defaultValue = "-1") final int resource,
|
||||
final HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* This is the feedback channel for the {@link DeploymentBase} action.
|
||||
* This is the feedback channel for the {@link DdiDeploymentBase} action.
|
||||
*
|
||||
* @param feedback
|
||||
* to provide
|
||||
@@ -153,15 +152,11 @@ public interface RootControllerDdiApi {
|
||||
*
|
||||
* @return the response
|
||||
*/
|
||||
// @RequestMapping(value = "/{targetid}/" +
|
||||
// ControllerConstants.DEPLOYMENT_BASE_ACTION + "/{actionId}/"
|
||||
// + ControllerConstants.FEEDBACK, method = RequestMethod.POST, consumes =
|
||||
// MediaType.APPLICATION_JSON_VALUE)
|
||||
// public ResponseEntity<Void> postBasedeploymentActionFeedback(@Valid
|
||||
// @RequestBody final ActionFeedback feedback,
|
||||
// @PathVariable("targetid") final String targetid,
|
||||
// @PathVariable("actionId") @NotEmpty final Long actionId,
|
||||
// final HttpServletRequest request);
|
||||
@RequestMapping(value = "/{targetid}/" + DdiRestConstants.DEPLOYMENT_BASE_ACTION + "/{actionId}/"
|
||||
+ DdiRestConstants.FEEDBACK, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Void> postBasedeploymentActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback,
|
||||
@PathVariable("targetid") final String targetid, @PathVariable("actionId") @NotEmpty final Long actionId,
|
||||
final HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* This is the feedback channel for the config data action.
|
||||
@@ -175,16 +170,13 @@ public interface RootControllerDdiApi {
|
||||
*
|
||||
* @return status of the request
|
||||
*/
|
||||
// @RequestMapping(value = "/{targetid}/"
|
||||
// + ControllerConstants.CONFIG_DATA_ACTION, method = RequestMethod.PUT,
|
||||
// consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public ResponseEntity<Void> putConfigData(@Valid @RequestBody final
|
||||
// ConfigData configData,
|
||||
// @PathVariable("targetid") final String targetid, final HttpServletRequest
|
||||
// request);
|
||||
@RequestMapping(value = "/{targetid}/"
|
||||
+ DdiRestConstants.CONFIG_DATA_ACTION, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Void> putConfigData(@Valid @RequestBody final DdiConfigData configData,
|
||||
@PathVariable("targetid") final String targetid, final HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* {@link RequestMethod.GET} method for the {@link Cancel} action.
|
||||
* {@link RequestMethod.GET} method for the {@link DdiCancel} action.
|
||||
*
|
||||
* @param targetid
|
||||
* ID of the calling target
|
||||
@@ -193,19 +185,19 @@ public interface RootControllerDdiApi {
|
||||
* @param request
|
||||
* the HTTP request injected by spring
|
||||
*
|
||||
* @return the {@link Cancel} response
|
||||
* @return the {@link DdiCancel} response
|
||||
*/
|
||||
@RequestMapping(value = "/{targetid}/" + ControllerConstants.CANCEL_ACTION
|
||||
@RequestMapping(value = "/{targetid}/" + DdiRestConstants.CANCEL_ACTION
|
||||
+ "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Cancel> getControllerCancelAction(@PathVariable("targetid") @NotEmpty final String targetid,
|
||||
ResponseEntity<DdiCancel> getControllerCancelAction(@PathVariable("targetid") @NotEmpty final String targetid,
|
||||
@PathVariable("actionId") @NotEmpty final Long actionId, final HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* {@link RequestMethod.POST} method receiving the {@link ActionFeedback}
|
||||
* {@link RequestMethod.POST} method receiving the {@link DdiActionFeedback}
|
||||
* from the target.
|
||||
*
|
||||
* @param feedback
|
||||
* the {@link ActionFeedback} from the target.
|
||||
* the {@link DdiActionFeedback} from the target.
|
||||
* @param targetid
|
||||
* the ID of the calling target
|
||||
* @param actionId
|
||||
@@ -213,17 +205,13 @@ public interface RootControllerDdiApi {
|
||||
* @param request
|
||||
* the HTTP request injected by spring
|
||||
*
|
||||
* @return the {@link ActionFeedback} response
|
||||
* @return the {@link DdiActionFeedback} response
|
||||
*/
|
||||
|
||||
// @RequestMapping(value = "/{targetid}/" +
|
||||
// ControllerConstants.CANCEL_ACTION + "/{actionId}/"
|
||||
// + ControllerConstants.FEEDBACK, method = RequestMethod.POST, consumes =
|
||||
// MediaType.APPLICATION_JSON_VALUE)
|
||||
// public ResponseEntity<Void> postCancelActionFeedback(@Valid @RequestBody
|
||||
// final ActionFeedback feedback,
|
||||
// @PathVariable("targetid") @NotEmpty final String targetid,
|
||||
// @PathVariable("actionId") @NotEmpty final Long actionId, final
|
||||
// HttpServletRequest request);
|
||||
@RequestMapping(value = "/{targetid}/" + DdiRestConstants.CANCEL_ACTION + "/{actionId}/"
|
||||
+ DdiRestConstants.FEEDBACK, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Void> postCancelActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback,
|
||||
@PathVariable("targetid") @NotEmpty final String targetid,
|
||||
@PathVariable("actionId") @NotEmpty final Long actionId, final HttpServletRequest request);
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
|
||||
import org.eclipse.hawkbit.cache.CacheWriteNotify;
|
||||
import org.eclipse.hawkbit.ddi.api.ArtifactStoreControllerDdiApi;
|
||||
import org.eclipse.hawkbit.ddi.rest.api.DdiArtifactStoreControllerRestApi;
|
||||
import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.repository.ControllerManagement;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
@@ -44,7 +44,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* for legacy controllers that can not be fed with a download URI at runtime.
|
||||
*/
|
||||
@RestController
|
||||
public class ArtifactStoreController implements ArtifactStoreControllerDdiApi {
|
||||
public class ArtifactStoreController implements DdiArtifactStoreControllerRestApi {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ArtifactStoreController.class);
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.hawkbit.api.ArtifactUrlHandler;
|
||||
import org.eclipse.hawkbit.api.UrlProtocol;
|
||||
import org.eclipse.hawkbit.ddi.ControllerConstants;
|
||||
import org.eclipse.hawkbit.ddi.model.Artifact;
|
||||
import org.eclipse.hawkbit.ddi.model.Chunk;
|
||||
import org.eclipse.hawkbit.ddi.model.Config;
|
||||
import org.eclipse.hawkbit.ddi.model.ControllerBase;
|
||||
import org.eclipse.hawkbit.ddi.model.Polling;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiArtifact;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiChunk;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiConfig;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiControllerBase;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiPolling;
|
||||
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||
@@ -50,10 +50,10 @@ public final class DataConversionHelper {
|
||||
|
||||
}
|
||||
|
||||
static List<Chunk> createChunks(final String targetid, final Action uAction,
|
||||
static List<DdiChunk> createChunks(final String targetid, final Action uAction,
|
||||
final ArtifactUrlHandler artifactUrlHandler) {
|
||||
return uAction.getDistributionSet().getModules().stream()
|
||||
.map(module -> new Chunk(mapChunkLegacyKeys(module.getType().getKey()), module.getVersion(),
|
||||
.map(module -> new DdiChunk(mapChunkLegacyKeys(module.getType().getKey()), module.getVersion(),
|
||||
module.getName(), createArtifacts(targetid, module, artifactUrlHandler)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -79,12 +79,12 @@ public final class DataConversionHelper {
|
||||
* the software module
|
||||
* @return a list of artifacts or a empty list. Cannot be <null>.
|
||||
*/
|
||||
public static List<Artifact> createArtifacts(final String targetid,
|
||||
public static List<DdiArtifact> createArtifacts(final String targetid,
|
||||
final org.eclipse.hawkbit.repository.model.SoftwareModule module,
|
||||
final ArtifactUrlHandler artifactUrlHandler) {
|
||||
final List<Artifact> files = new ArrayList<>();
|
||||
final List<DdiArtifact> files = new ArrayList<>();
|
||||
module.getLocalArtifacts().forEach(artifact -> {
|
||||
final Artifact file = new Artifact();
|
||||
final DdiArtifact file = new DdiArtifact();
|
||||
file.setHashes(new ArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash()));
|
||||
file.setFilename(artifact.getFilename());
|
||||
file.setSize(artifact.getSize());
|
||||
@@ -93,18 +93,18 @@ public final class DataConversionHelper {
|
||||
final String linkHttps = artifactUrlHandler.getUrl(targetid, artifact.getSoftwareModule().getId(),
|
||||
artifact.getFilename(), artifact.getSha1Hash(), UrlProtocol.HTTPS);
|
||||
file.add(new Link(linkHttps).withRel("download"));
|
||||
file.add(new Link(linkHttps + ControllerConstants.ARTIFACT_MD5_DWNL_SUFFIX).withRel("md5sum"));
|
||||
file.add(new Link(linkHttps + DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX).withRel("md5sum"));
|
||||
file.add(new Link(linkHttp).withRel("download-http"));
|
||||
file.add(new Link(linkHttp + ControllerConstants.ARTIFACT_MD5_DWNL_SUFFIX).withRel("md5sum-http"));
|
||||
file.add(new Link(linkHttp + DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX).withRel("md5sum-http"));
|
||||
|
||||
files.add(file);
|
||||
});
|
||||
return files;
|
||||
}
|
||||
|
||||
static ControllerBase fromTarget(final Target target, final List<Action> actions,
|
||||
static DdiControllerBase fromTarget(final Target target, final List<Action> actions,
|
||||
final String defaultControllerPollTime, final TenantAware tenantAware) {
|
||||
final ControllerBase result = new ControllerBase(new Config(new Polling(defaultControllerPollTime)));
|
||||
final DdiControllerBase result = new DdiControllerBase(new DdiConfig(new DdiPolling(defaultControllerPollTime)));
|
||||
|
||||
boolean addedUpdate = false;
|
||||
boolean addedCancel = false;
|
||||
@@ -118,19 +118,19 @@ public final class DataConversionHelper {
|
||||
// response because of eTags.
|
||||
result.add(linkTo(methodOn(RootController.class, tenantAware.getCurrentTenant())
|
||||
.getControllerBasedeploymentAction(target.getControllerId(), action.getId(), actions.hashCode(),
|
||||
null)).withRel(ControllerConstants.DEPLOYMENT_BASE_ACTION));
|
||||
null)).withRel(DdiRestConstants.DEPLOYMENT_BASE_ACTION));
|
||||
addedUpdate = true;
|
||||
} else if (action.isCancelingOrCanceled() && !addedCancel) {
|
||||
result.add(linkTo(methodOn(RootController.class, tenantAware.getCurrentTenant())
|
||||
.getControllerCancelAction(target.getControllerId(), action.getId(), null))
|
||||
.withRel(ControllerConstants.CANCEL_ACTION));
|
||||
.withRel(DdiRestConstants.CANCEL_ACTION));
|
||||
addedCancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (target.getTargetInfo().isRequestControllerAttributes()) {
|
||||
result.add(linkTo(methodOn(RootController.class, tenantAware.getCurrentTenant()).putConfigData(null,
|
||||
target.getControllerId(), null)).withRel(ControllerConstants.CONFIG_DATA_ACTION));
|
||||
target.getControllerId(), null)).withRel(DdiRestConstants.CONFIG_DATA_ACTION));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public final class DataConversionHelper {
|
||||
final StringBuilder header = new StringBuilder();
|
||||
header.append("attachment;filename=");
|
||||
header.append(fileName);
|
||||
header.append(ControllerConstants.ARTIFACT_MD5_DWNL_SUFFIX);
|
||||
header.append(DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX);
|
||||
|
||||
response.setContentLength(content.length);
|
||||
response.setHeader("Content-Disposition", header.toString());
|
||||
|
||||
@@ -18,17 +18,17 @@ import javax.validation.Valid;
|
||||
import org.eclipse.hawkbit.api.ArtifactUrlHandler;
|
||||
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
|
||||
import org.eclipse.hawkbit.cache.CacheWriteNotify;
|
||||
import org.eclipse.hawkbit.ddi.api.RootControllerDdiApi;
|
||||
import org.eclipse.hawkbit.ddi.model.ActionFeedback;
|
||||
import org.eclipse.hawkbit.ddi.model.Cancel;
|
||||
import org.eclipse.hawkbit.ddi.model.CancelActionToStop;
|
||||
import org.eclipse.hawkbit.ddi.model.Chunk;
|
||||
import org.eclipse.hawkbit.ddi.model.ConfigData;
|
||||
import org.eclipse.hawkbit.ddi.model.ControllerBase;
|
||||
import org.eclipse.hawkbit.ddi.model.Deployment;
|
||||
import org.eclipse.hawkbit.ddi.model.Deployment.HandlingType;
|
||||
import org.eclipse.hawkbit.ddi.model.DeploymentBase;
|
||||
import org.eclipse.hawkbit.ddi.model.Result.FinalResult;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiActionFeedback;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiCancel;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiCancelActionToStop;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiChunk;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiConfigData;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiControllerBase;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiDeployment;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiDeployment.HandlingType;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiDeploymentBase;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiResult.FinalResult;
|
||||
import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi;
|
||||
import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.repository.ControllerManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
@@ -63,7 +63,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* Transactional (read-write) as all queries at least update the last poll time.
|
||||
*/
|
||||
@RestController
|
||||
public class RootController implements RootControllerDdiApi {
|
||||
public class RootController implements DdiRootControllerRestApi {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RootController.class);
|
||||
private static final String GIVEN_ACTION_IS_NOT_ASSIGNED_TO_GIVEN_TARGET = "given action ({}) is not assigned to given target ({}).";
|
||||
@@ -90,7 +90,7 @@ public class RootController implements RootControllerDdiApi {
|
||||
private ArtifactUrlHandler artifactUrlHandler;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<org.eclipse.hawkbit.ddi.model.Artifact>> getSoftwareModulesArtifacts(
|
||||
public ResponseEntity<List<org.eclipse.hawkbit.ddi.json.model.DdiArtifact>> getSoftwareModulesArtifacts(
|
||||
@PathVariable final String targetid, @PathVariable final Long softwareModuleId) {
|
||||
LOG.debug("getSoftwareModulesArtifacts({})", targetid);
|
||||
|
||||
@@ -107,7 +107,7 @@ public class RootController implements RootControllerDdiApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<ControllerBase> getControllerBase(@PathVariable final String targetid,
|
||||
public ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable final String targetid,
|
||||
final HttpServletRequest request) {
|
||||
LOG.debug("getControllerBase({})", targetid);
|
||||
|
||||
@@ -206,7 +206,7 @@ public class RootController implements RootControllerDdiApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<DeploymentBase> getControllerBasedeploymentAction(
|
||||
public ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(
|
||||
@PathVariable @NotEmpty final String targetid, @PathVariable @NotEmpty final Long actionId,
|
||||
@RequestParam(value = "c", required = false, defaultValue = "-1") final int resource,
|
||||
final HttpServletRequest request) {
|
||||
@@ -223,12 +223,12 @@ public class RootController implements RootControllerDdiApi {
|
||||
|
||||
if (!action.isCancelingOrCanceled()) {
|
||||
|
||||
final List<Chunk> chunks = DataConversionHelper.createChunks(targetid, action, artifactUrlHandler);
|
||||
final List<DdiChunk> chunks = DataConversionHelper.createChunks(targetid, action, artifactUrlHandler);
|
||||
|
||||
final HandlingType handlingType = action.isForce() ? HandlingType.FORCED : HandlingType.ATTEMPT;
|
||||
|
||||
final DeploymentBase base = new DeploymentBase(Long.toString(action.getId()),
|
||||
new Deployment(handlingType, handlingType, chunks));
|
||||
final DdiDeploymentBase base = new DdiDeploymentBase(Long.toString(action.getId()),
|
||||
new DdiDeployment(handlingType, handlingType, chunks));
|
||||
|
||||
LOG.debug("Found an active UpdateAction for target {}. returning deyploment: {}", targetid, base);
|
||||
|
||||
@@ -242,7 +242,7 @@ public class RootController implements RootControllerDdiApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> postBasedeploymentActionFeedback(@Valid @RequestBody final ActionFeedback feedback,
|
||||
public ResponseEntity<Void> postBasedeploymentActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback,
|
||||
@PathVariable final String targetid, @PathVariable @NotEmpty final Long actionId,
|
||||
final HttpServletRequest request) {
|
||||
LOG.debug("provideBasedeploymentActionFeedback for target [{},{}]: {}", targetid, actionId, feedback);
|
||||
@@ -277,7 +277,7 @@ public class RootController implements RootControllerDdiApi {
|
||||
|
||||
}
|
||||
|
||||
private ActionStatus generateUpdateStatus(final ActionFeedback feedback, final String targetid, final Long actionid,
|
||||
private ActionStatus generateUpdateStatus(final DdiActionFeedback feedback, final String targetid, final Long actionid,
|
||||
final Action action) {
|
||||
|
||||
final ActionStatus actionStatus = new ActionStatus();
|
||||
@@ -317,7 +317,7 @@ public class RootController implements RootControllerDdiApi {
|
||||
return actionStatus;
|
||||
}
|
||||
|
||||
private static void handleDefaultUpdateStatus(final ActionFeedback feedback, final String targetid,
|
||||
private static void handleDefaultUpdateStatus(final DdiActionFeedback feedback, final String targetid,
|
||||
final Long actionid, final ActionStatus actionStatus) {
|
||||
LOG.debug("Controller reported intermediate status (actionid: {}, targetid: {}) as we got {} report.", actionid,
|
||||
targetid, feedback.getStatus().getExecution());
|
||||
@@ -325,7 +325,7 @@ public class RootController implements RootControllerDdiApi {
|
||||
actionStatus.addMessage("Controller reported: " + feedback.getStatus().getExecution());
|
||||
}
|
||||
|
||||
private static void handleClosedUpdateStatus(final ActionFeedback feedback, final String targetid,
|
||||
private static void handleClosedUpdateStatus(final DdiActionFeedback feedback, final String targetid,
|
||||
final Long actionid, final ActionStatus actionStatus) {
|
||||
LOG.debug("Controller reported closed (actionid: {}, targetid: {}) as we got {} report.", actionid, targetid,
|
||||
feedback.getStatus().getExecution());
|
||||
@@ -339,7 +339,7 @@ public class RootController implements RootControllerDdiApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> putConfigData(@Valid @RequestBody final ConfigData configData,
|
||||
public ResponseEntity<Void> putConfigData(@Valid @RequestBody final DdiConfigData configData,
|
||||
@PathVariable final String targetid, final HttpServletRequest request) {
|
||||
controllerManagement.updateLastTargetQuery(targetid,
|
||||
IpUtil.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
|
||||
@@ -350,7 +350,7 @@ public class RootController implements RootControllerDdiApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Cancel> getControllerCancelAction(@PathVariable @NotEmpty final String targetid,
|
||||
public ResponseEntity<DdiCancel> getControllerCancelAction(@PathVariable @NotEmpty final String targetid,
|
||||
@PathVariable @NotEmpty final Long actionId, final HttpServletRequest request) {
|
||||
LOG.debug("getControllerCancelAction({})", targetid);
|
||||
|
||||
@@ -364,8 +364,8 @@ public class RootController implements RootControllerDdiApi {
|
||||
}
|
||||
|
||||
if (action.isCancelingOrCanceled()) {
|
||||
final Cancel cancel = new Cancel(String.valueOf(action.getId()),
|
||||
new CancelActionToStop(String.valueOf(action.getId())));
|
||||
final DdiCancel cancel = new DdiCancel(String.valueOf(action.getId()),
|
||||
new DdiCancelActionToStop(String.valueOf(action.getId())));
|
||||
|
||||
LOG.debug("Found an active CancelAction for target {}. returning cancel: {}", targetid, cancel);
|
||||
|
||||
@@ -379,7 +379,7 @@ public class RootController implements RootControllerDdiApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> postCancelActionFeedback(@Valid @RequestBody final ActionFeedback feedback,
|
||||
public ResponseEntity<Void> postCancelActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback,
|
||||
@PathVariable @NotEmpty final String targetid, @PathVariable @NotEmpty final Long actionId,
|
||||
final HttpServletRequest request) {
|
||||
LOG.debug("provideCancelActionFeedback for target [{}]: {}", targetid, feedback);
|
||||
@@ -405,7 +405,7 @@ public class RootController implements RootControllerDdiApi {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
private static ActionStatus generateActionCancelStatus(final ActionFeedback feedback, final Target target,
|
||||
private static ActionStatus generateActionCancelStatus(final DdiActionFeedback feedback, final Target target,
|
||||
final Long actionid, final Action action) {
|
||||
|
||||
final ActionStatus actionStatus = new ActionStatus();
|
||||
@@ -445,7 +445,7 @@ public class RootController implements RootControllerDdiApi {
|
||||
|
||||
}
|
||||
|
||||
private static void handleClosedCancelStatus(final ActionFeedback feedback, final ActionStatus actionStatus) {
|
||||
private static void handleClosedCancelStatus(final DdiActionFeedback feedback, final ActionStatus actionStatus) {
|
||||
if (feedback.getStatus().getResult().getFinished() == FinalResult.FAILURE) {
|
||||
actionStatus.setStatus(Status.ERROR);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user