Created hawkbit-ddi-api maven module and resource interfaces for the module
Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Constants for the direct device integration rest resources.
|
||||
*/
|
||||
public final class ControllerConstants {
|
||||
|
||||
/**
|
||||
* The base URL mapping of the direct device integration rest resources.
|
||||
*/
|
||||
public static final String BASE_V1_REQUEST_MAPPING = "/{tenant}/controller/v1";
|
||||
|
||||
/**
|
||||
* The base URL mapping of the artifact repository rest resources.
|
||||
*/
|
||||
public static final String ARTIFACTS_V1_REQUEST_MAPPING = "/{tenant}/controller/artifacts/v1";
|
||||
|
||||
/**
|
||||
* Deployment action resources.
|
||||
*/
|
||||
public static final String DEPLOYMENT_BASE_ACTION = "deploymentBase";
|
||||
|
||||
/**
|
||||
* Cancel action resources.
|
||||
*/
|
||||
public static final String CANCEL_ACTION = "cancelAction";
|
||||
|
||||
/**
|
||||
* Feedback channel.
|
||||
*/
|
||||
public static final String FEEDBACK = "feedback";
|
||||
|
||||
/**
|
||||
* Config data action resources.
|
||||
*/
|
||||
public static final String CONFIG_DATA_ACTION = "configData";
|
||||
|
||||
/**
|
||||
* The artifact URL mapping rest resource.
|
||||
*/
|
||||
public static final String ARTIFACT_DOWNLOAD = "artifact";
|
||||
|
||||
/**
|
||||
* The artifact by filename URL mapping rest resource.
|
||||
*/
|
||||
public static final String ARTIFACT_DOWNLOAD_BY_FILENAME = "/filename";
|
||||
|
||||
/**
|
||||
* File suffix for MDH hash download (see Linux md5sum).
|
||||
*/
|
||||
public static final String ARTIFACT_MD5_DWNL_SUFFIX = ".MD5SUM";
|
||||
|
||||
// constant class, private constructor.
|
||||
private ControllerConstants() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Copyright (c) 2011-2016 Bosch Software Innovations GmbH, Germany. All rights reserved.
|
||||
*
|
||||
* 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.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.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.web.bind.annotation.AuthenticationPrincipal;
|
||||
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;
|
||||
|
||||
/**
|
||||
* REST resource handling for artifact download operations.
|
||||
*/
|
||||
@RequestMapping(ControllerConstants.ARTIFACTS_V1_REQUEST_MAPPING)
|
||||
public interface ArtifactStoreControllerDdiApi {
|
||||
|
||||
/**
|
||||
* Handles GET {@link Artifact} download request. This could be full or
|
||||
* partial download request.
|
||||
*
|
||||
* @param fileName
|
||||
* to search for
|
||||
* @param response
|
||||
* to write to
|
||||
* @param request
|
||||
* from the client
|
||||
* @param targetid
|
||||
* of authenticated target
|
||||
*
|
||||
* @return response of the servlet which in case of success is status code
|
||||
* {@link HttpStatus#OK} or in case of partial download
|
||||
* {@link HttpStatus#PARTIAL_CONTENT}.
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = ControllerConstants.ARTIFACT_DOWNLOAD_BY_FILENAME
|
||||
+ "/{fileName}")
|
||||
@ResponseBody
|
||||
public ResponseEntity<Void> downloadArtifactByFilename(@PathVariable("fileName") final String fileName,
|
||||
final HttpServletResponse response, final HttpServletRequest request,
|
||||
@AuthenticationPrincipal final String targetid);
|
||||
|
||||
/**
|
||||
* Handles GET {@link Artifact} MD5 checksum file download request.
|
||||
*
|
||||
* @param fileName
|
||||
* to search for
|
||||
* @param response
|
||||
* to write to
|
||||
*
|
||||
* @return response of the servlet
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = ControllerConstants.ARTIFACT_DOWNLOAD_BY_FILENAME
|
||||
+ "/{fileName}" + ControllerConstants.ARTIFACT_MD5_DWNL_SUFFIX)
|
||||
@ResponseBody
|
||||
public ResponseEntity<Void> downloadArtifactMD5ByFilename(@PathVariable("fileName") final String fileName,
|
||||
final HttpServletResponse response);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
/**
|
||||
* Copyright (c) 2011-2016 Bosch Software Innovations GmbH, Germany. All rights reserved.
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.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.ActionFeedback;
|
||||
import org.eclipse.hawkbit.ddi.model.Artifact;
|
||||
import org.eclipse.hawkbit.ddi.model.Cancel;
|
||||
import org.eclipse.hawkbit.ddi.model.ConfigData;
|
||||
import org.eclipse.hawkbit.ddi.model.ControllerBase;
|
||||
import org.eclipse.hawkbit.ddi.model.DeploymentBase;
|
||||
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;
|
||||
|
||||
/**
|
||||
* REST resource handling for root controller CRUD operations.
|
||||
*/
|
||||
@RequestMapping(ControllerConstants.BASE_V1_REQUEST_MAPPING)
|
||||
public interface RootControllerDdiApi {
|
||||
|
||||
/**
|
||||
* Returns all artifacts of a given software module and target.
|
||||
*
|
||||
* @param targetid
|
||||
* of the {@link Target} that matches to
|
||||
* {@link Target#getControllerId()}
|
||||
* @param softwareModuleId
|
||||
* of the {@link SoftwareModule}
|
||||
* @return the response
|
||||
*/
|
||||
@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(
|
||||
@PathVariable("targetid") final String targetid,
|
||||
@PathVariable("softwareModuleId") final Long softwareModuleId);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Handles GET {@link Artifact} download request. This could be full or
|
||||
* partial (as specified by RFC7233 (Range Requests)) download request.
|
||||
*
|
||||
* @param targetid
|
||||
* of the related
|
||||
* @param softwareModuleId
|
||||
* of the parent {@link SoftwareModule}
|
||||
* @param fileName
|
||||
* of the related {@link LocalArtifact}
|
||||
* @param response
|
||||
* of the servlet
|
||||
* @param request
|
||||
* from the client
|
||||
*
|
||||
* @return response of the servlet which in case of success is status code
|
||||
* {@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);
|
||||
|
||||
/**
|
||||
* Handles GET {@link Artifact} MD5 checksum file download request.
|
||||
*
|
||||
* @param targetid
|
||||
* of the related
|
||||
* @param softwareModuleId
|
||||
* of the parent {@link SoftwareModule}
|
||||
* @param fileName
|
||||
* of the related {@link LocalArtifact}
|
||||
* @param response
|
||||
* of the servlet
|
||||
* @param request
|
||||
* the HTTP request injected by spring
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Resource for {@link SoftwareModule} {@link UpdateAction}s.
|
||||
*
|
||||
* @param targetid
|
||||
* of the {@link Target} that matches to
|
||||
* {@link Target#getControllerId()}
|
||||
* @param actionId
|
||||
* of the {@link DeploymentBase} that matches to
|
||||
* {@link Target#getActiveActions()}
|
||||
* @param resource
|
||||
* an hashcode of the resource which indicates if the action has
|
||||
* been changed, e.g. from 'soft' to 'force' and the eTag needs
|
||||
* to be re-generated
|
||||
* @param request
|
||||
* the HTTP request injected by spring
|
||||
* @return the response
|
||||
*/
|
||||
@RequestMapping(value = "/{targetid}/" + ControllerConstants.DEPLOYMENT_BASE_ACTION
|
||||
+ "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<DeploymentBase> 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.
|
||||
*
|
||||
* @param feedback
|
||||
* to provide
|
||||
* @param targetid
|
||||
* of the {@link Target} that matches to
|
||||
* {@link Target#getControllerId()}
|
||||
* @param actionId
|
||||
* of the action we have feedback for
|
||||
* @param request
|
||||
* the HTTP request injected by spring
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* This is the feedback channel for the config data action.
|
||||
*
|
||||
* @param configData
|
||||
* as body
|
||||
* @param targetid
|
||||
* to provide data for
|
||||
* @param request
|
||||
* the HTTP request injected by spring
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* {@link RequestMethod.GET} method for the {@link Cancel} action.
|
||||
*
|
||||
* @param targetid
|
||||
* ID of the calling target
|
||||
* @param actionId
|
||||
* of the action
|
||||
* @param request
|
||||
* the HTTP request injected by spring
|
||||
*
|
||||
* @return the {@link Cancel} response
|
||||
*/
|
||||
@RequestMapping(value = "/{targetid}/" + ControllerConstants.CANCEL_ACTION
|
||||
+ "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Cancel> getControllerCancelAction(@PathVariable("targetid") @NotEmpty final String targetid,
|
||||
@PathVariable("actionId") @NotEmpty final Long actionId, final HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* {@link RequestMethod.POST} method receiving the {@link ActionFeedback}
|
||||
* from the target.
|
||||
*
|
||||
* @param feedback
|
||||
* the {@link ActionFeedback} from the target.
|
||||
* @param targetid
|
||||
* the ID of the calling target
|
||||
* @param actionId
|
||||
* of the action we have feedback for
|
||||
* @param request
|
||||
* the HTTP request injected by spring
|
||||
*
|
||||
* @return the {@link ActionFeedback} 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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* 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.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* After the HawkBit Target has executed an action, received by a GET(URL)
|
||||
* request it reports the completion of it to the HawkBit Server with a action
|
||||
* status message, i.e. with a PUT message to the feedback channel, i.e. PUT
|
||||
* URL/feedback. This message could be used not only at the end of execution but
|
||||
* also as status updates during a longer lasting execution period. The format
|
||||
* of each action answer message is defined below at each action. But it is
|
||||
* expected, that the contents of the message answers have all a similar
|
||||
* structure: The content starts with a generic header and additional elements.
|
||||
* *
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* The answer header would look like: { "id": "51659181", "time":
|
||||
* "20140511T121314", "status": { "execution": "closed", "result": { "final":
|
||||
* "success", "progress": {} } "details": [], } }
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ActionFeedback {
|
||||
private final Long id;
|
||||
private final String time;
|
||||
|
||||
@NotNull
|
||||
private final Status status;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param id
|
||||
* of the actions the feedback is for
|
||||
* @param time
|
||||
* of the feedback
|
||||
* @param status
|
||||
* is the feedback itself
|
||||
*/
|
||||
@JsonCreator
|
||||
public ActionFeedback(@JsonProperty("id") final Long id, @JsonProperty("time") final String time,
|
||||
@JsonProperty("status") final Status status) {
|
||||
this.id = id;
|
||||
this.time = time;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ActionFeedback [id=" + id + ", time=" + time + ", status=" + status + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.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 Chunk}.
|
||||
*/
|
||||
public class Artifact extends ResourceSupport {
|
||||
|
||||
@NotNull
|
||||
@JsonProperty
|
||||
private String filename;
|
||||
|
||||
@JsonProperty
|
||||
private ArtifactHash hashes;
|
||||
|
||||
@JsonProperty
|
||||
private Long size;
|
||||
|
||||
public ArtifactHash getHashes() {
|
||||
return hashes;
|
||||
}
|
||||
|
||||
public void setHashes(final ArtifactHash hashes) {
|
||||
this.hashes = hashes;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename(final String fileName) {
|
||||
filename = fileName;
|
||||
}
|
||||
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(final Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 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.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Cancel action to be provided to the target.
|
||||
*/
|
||||
public class Cancel {
|
||||
|
||||
private final String id;
|
||||
|
||||
@NotNull
|
||||
private final CancelActionToStop cancelAction;
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param id
|
||||
* of the {@link CancelAction}
|
||||
* @param cancelAction
|
||||
* the action
|
||||
*/
|
||||
public Cancel(final String id, final CancelActionToStop cancelAction) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.cancelAction = cancelAction;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public CancelActionToStop getCancelAction() {
|
||||
return cancelAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Cancel [id=" + id + ", cancelAction=" + cancelAction + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.ddi.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* The {@link Action} that has to be stopped by the target.
|
||||
*/
|
||||
public class CancelActionToStop {
|
||||
|
||||
@NotNull
|
||||
private final String stopId;
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param stopId
|
||||
* ID of the {@link Action} to be stoppedW
|
||||
*/
|
||||
public CancelActionToStop(final String stopId) {
|
||||
super();
|
||||
this.stopId = stopId;
|
||||
}
|
||||
|
||||
public String getStopId() {
|
||||
return stopId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CancelAction [stopId=" + stopId + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* 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.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Deployment chunks.
|
||||
*/
|
||||
public class Chunk {
|
||||
|
||||
@NotNull
|
||||
private final String part;
|
||||
|
||||
@NotNull
|
||||
private final String version;
|
||||
|
||||
@NotNull
|
||||
private final String name;
|
||||
|
||||
private final List<Artifact> artifacts;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param part
|
||||
* of the deployment chunk
|
||||
* @param version
|
||||
* of the artifact
|
||||
* @param name
|
||||
* of the artifact
|
||||
* @param artifacts
|
||||
* download information
|
||||
*/
|
||||
public Chunk(final String part, final String version, final String name, final List<Artifact> artifacts) {
|
||||
super();
|
||||
this.part = part;
|
||||
this.version = version;
|
||||
this.name = name;
|
||||
this.artifacts = artifacts;
|
||||
}
|
||||
|
||||
public String getPart() {
|
||||
return part;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<Artifact> getArtifacts() {
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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.model;
|
||||
|
||||
/**
|
||||
* Standard configuration for the target.
|
||||
*/
|
||||
public class Config {
|
||||
|
||||
private final Polling polling;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param polling
|
||||
* configuration of the SP target
|
||||
*/
|
||||
public Config(final Polling polling) {
|
||||
super();
|
||||
this.polling = polling;
|
||||
}
|
||||
|
||||
public Polling getPolling() {
|
||||
return polling;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.ddi.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Feedback channel for ConfigData action.
|
||||
*/
|
||||
public class ConfigData extends ActionFeedback {
|
||||
|
||||
@NotEmpty
|
||||
private final Map<String, String> data;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param id
|
||||
* of the actions the feedback is for
|
||||
* @param time
|
||||
* of the feedback
|
||||
* @param status
|
||||
* is the feedback itself
|
||||
* @param data
|
||||
* contains the attributes.
|
||||
*/
|
||||
@JsonCreator
|
||||
public ConfigData(@JsonProperty(value = "id") final Long id, @JsonProperty(value = "time") final String time,
|
||||
@JsonProperty(value = "status") final Status status,
|
||||
@JsonProperty(value = "data") final Map<String, String> data) {
|
||||
super(id, time, status);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Map<String, String> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConfigData [data=" + data + ", toString()=" + super.toString() + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 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.model;
|
||||
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
|
||||
/**
|
||||
* {@link ControllerBase} resource content.
|
||||
*/
|
||||
public class ControllerBase extends ResourceSupport {
|
||||
|
||||
private final Config config;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param config
|
||||
* configuration of the SP target
|
||||
*/
|
||||
public ControllerBase(final Config config) {
|
||||
super();
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public Config getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* 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.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Detailed {@link UpdateAction} information.
|
||||
*/
|
||||
public class Deployment {
|
||||
|
||||
private final HandlingType download;
|
||||
|
||||
private final HandlingType update;
|
||||
|
||||
private final List<Chunk> chunks;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param download
|
||||
* handling type
|
||||
* @param update
|
||||
* handling type
|
||||
* @param chunks
|
||||
* to handle.
|
||||
*/
|
||||
public Deployment(final HandlingType download, final HandlingType update, final List<Chunk> chunks) {
|
||||
super();
|
||||
this.download = download;
|
||||
this.update = update;
|
||||
this.chunks = chunks;
|
||||
}
|
||||
|
||||
public HandlingType getDownload() {
|
||||
return download;
|
||||
}
|
||||
|
||||
public HandlingType getUpdate() {
|
||||
return update;
|
||||
}
|
||||
|
||||
public List<Chunk> getChunks() {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
/**
|
||||
* The handling type for the update {@link Action}.
|
||||
*/
|
||||
public enum HandlingType {
|
||||
|
||||
/**
|
||||
* Not necessary for the command.
|
||||
*/
|
||||
SKIP("skip"),
|
||||
|
||||
/**
|
||||
* Try to execute (local applications may intervene by SP control API).
|
||||
*/
|
||||
ATTEMPT("attempt"),
|
||||
|
||||
/**
|
||||
* Execution independent of local intervention attempts.
|
||||
*/
|
||||
FORCED("forced");
|
||||
|
||||
private String name;
|
||||
|
||||
private HandlingType(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Deployment [download=" + download + ", update=" + update + ", chunks=" + chunks + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* {@link UpdateAction} resource.
|
||||
*/
|
||||
public class DeploymentBase extends ResourceSupport {
|
||||
|
||||
@JsonProperty("id")
|
||||
@NotNull
|
||||
private final String deplyomentId;
|
||||
|
||||
@NotNull
|
||||
private final Deployment deployment;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param id
|
||||
* of the {@link UpdateAction}
|
||||
* @param deployment
|
||||
* details.
|
||||
*/
|
||||
public DeploymentBase(final String id, final Deployment deployment) {
|
||||
deplyomentId = id;
|
||||
this.deployment = deployment;
|
||||
}
|
||||
|
||||
public Deployment getDeployment() {
|
||||
return deployment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeploymentBase [id=" + deplyomentId + ", deployment=" + deployment + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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.model;
|
||||
|
||||
/**
|
||||
* Polling interval for the SP target.
|
||||
*/
|
||||
public class Polling {
|
||||
|
||||
private final String sleep;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param sleep
|
||||
* between polls
|
||||
*/
|
||||
public Polling(final String sleep) {
|
||||
super();
|
||||
this.sleep = sleep;
|
||||
}
|
||||
|
||||
public String getSleep() {
|
||||
return sleep;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.ddi.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Action fulfillment progress by means of gives the achieved amount of maximal
|
||||
* of possible levels.
|
||||
*/
|
||||
public class Progress {
|
||||
|
||||
@NotNull
|
||||
private final Integer cnt;
|
||||
|
||||
private final Integer of;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param cnt
|
||||
* achieved amount
|
||||
* @param of
|
||||
* maximum levels
|
||||
*/
|
||||
@JsonCreator
|
||||
public Progress(@JsonProperty("cnt") final Integer cnt, @JsonProperty("of") final Integer of) {
|
||||
super();
|
||||
this.cnt = cnt;
|
||||
this.of = of;
|
||||
}
|
||||
|
||||
public Integer getCnt() {
|
||||
return cnt;
|
||||
}
|
||||
|
||||
public Integer getOf() {
|
||||
return of;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Progress [cnt=" + cnt + ", of=" + of + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* 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.model;
|
||||
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Result information of the action progress which can by an intermediate or
|
||||
* final update.
|
||||
*/
|
||||
public class Result {
|
||||
|
||||
@NotEmpty
|
||||
private final FinalResult finished;
|
||||
|
||||
private final Progress progress;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param finished
|
||||
* as final result
|
||||
* @param progress
|
||||
* if not yet finished
|
||||
*/
|
||||
@JsonCreator
|
||||
public Result(@JsonProperty("finished") final FinalResult finished,
|
||||
@JsonProperty("progress") final Progress progress) {
|
||||
super();
|
||||
this.finished = finished;
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
public FinalResult getFinished() {
|
||||
return finished;
|
||||
}
|
||||
|
||||
public Progress getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined status of the final result.
|
||||
*
|
||||
*/
|
||||
public enum FinalResult {
|
||||
/**
|
||||
* Execution was successful.
|
||||
*/
|
||||
SUCESS("success"),
|
||||
|
||||
/**
|
||||
* Execution terminated with errors or without the expected result.
|
||||
*/
|
||||
FAILURE("failure"),
|
||||
|
||||
/**
|
||||
* No final result could be determined (yet).
|
||||
*/
|
||||
NONE("none");
|
||||
|
||||
private String name;
|
||||
|
||||
private FinalResult(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Result [finished=" + finished + ", progress=" + progress + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* 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.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Details status information concerning the action processing.
|
||||
*/
|
||||
public class Status {
|
||||
|
||||
@NotNull
|
||||
private final ExecutionStatus execution;
|
||||
|
||||
@NotNull
|
||||
private final Result result;
|
||||
|
||||
private final List<String> details;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param execution
|
||||
* status
|
||||
* @param result
|
||||
* information
|
||||
* @param details
|
||||
* as optional addition
|
||||
*/
|
||||
@JsonCreator
|
||||
public Status(@JsonProperty("execution") final ExecutionStatus execution,
|
||||
@JsonProperty("result") final Result result, @JsonProperty("details") final List<String> details) {
|
||||
super();
|
||||
this.execution = execution;
|
||||
this.result = result;
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public ExecutionStatus getExecution() {
|
||||
return execution;
|
||||
}
|
||||
|
||||
public Result getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<String> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
/**
|
||||
* The element status contains information about the execution of the
|
||||
* operation.
|
||||
*
|
||||
*/
|
||||
public enum ExecutionStatus {
|
||||
/**
|
||||
* Execution of the action has finished.
|
||||
*/
|
||||
CLOSED("closed"),
|
||||
|
||||
/**
|
||||
* Execution has started but has not yet finished.
|
||||
*/
|
||||
PROCEEDING("proceeding"),
|
||||
|
||||
/**
|
||||
* Execution was suspended from outside.
|
||||
*/
|
||||
CANCELED("canceled"),
|
||||
|
||||
/**
|
||||
* Action has been noticed and is intended to run.
|
||||
*/
|
||||
SCHEDULED("scheduled"),
|
||||
|
||||
/**
|
||||
* Action was not accepted.
|
||||
*/
|
||||
REJECTED("rejected"),
|
||||
|
||||
/**
|
||||
* Action is started after a reset, power loss, etc.
|
||||
*/
|
||||
RESUMED("resumed");
|
||||
|
||||
private String name;
|
||||
|
||||
private ExecutionStatus(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Status [execution=" + execution + ", result=" + result + ", details=" + details + "]";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user