Code formating and removing unused imports (#2072)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -100,7 +100,7 @@ public interface DdiRootControllerRestApi {
|
||||
retrieve actions that need to be executed. Those are provided as a list of links to give more detailed
|
||||
information about the action. Links are only available for initial configuration, open actions, or the latest
|
||||
installed action, respectively. The resource supports Etag based modification checks in order to save traffic.
|
||||
|
||||
|
||||
Note: deployments have to be confirmed in order to move on to the next action. Cancellations have to be
|
||||
confirmed or rejected.""")
|
||||
@ApiResponses(value = {
|
||||
@@ -222,7 +222,7 @@ public interface DdiRootControllerRestApi {
|
||||
*/
|
||||
@Operation(summary = "Resource for software module (Deployment Base)", description = """
|
||||
Core resource for deployment operations. Contains all information necessary in order to execute the operation.
|
||||
|
||||
|
||||
Keep in mind that the provided download links for the artifacts are generated dynamically by the update server.
|
||||
Host, port and path and not guaranteed to be similar to the provided examples below but will be defined at
|
||||
runtime.
|
||||
@@ -230,15 +230,15 @@ public interface DdiRootControllerRestApi {
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = """
|
||||
Successfully retrieved
|
||||
|
||||
|
||||
In case a device provides state information on the feedback channel and won’t store it locally,
|
||||
a query for, e.q, the last 10 messages, could be used which will include the previously provided by the
|
||||
device,
|
||||
feedback.
|
||||
|
||||
|
||||
In addition to the straight forward approach to inform the device to download and install the software
|
||||
in one transaction hawkBit supports the separation of download and installation into separate steps.
|
||||
|
||||
|
||||
This feature is called Maintenance Window where the device is informed to download the software first
|
||||
and then when it enters a defined (maintenance) window the installation triggers follows as usual.
|
||||
"""),
|
||||
@@ -461,7 +461,7 @@ public interface DdiRootControllerRestApi {
|
||||
the already finished action, for example in case a re-installation is necessary. The response will be of
|
||||
the same format as the deploymentBase operation, providing the previous action that has been finished
|
||||
successfully. As the action is already finished, no further feedback is expected.
|
||||
|
||||
|
||||
Keep in mind that the provided download links for the artifacts are generated dynamically by the update server.
|
||||
Host, port and path are not guaranteed to be similar to the provided examples below but will be defined at
|
||||
runtime.
|
||||
@@ -470,7 +470,7 @@ public interface DdiRootControllerRestApi {
|
||||
@ApiResponse(responseCode = "200", description = """
|
||||
The response body includes the detailed operation for the already finished action in the same format as
|
||||
for the deploymentBase operation.
|
||||
|
||||
|
||||
In this case the (optional) query for the last 10 messages, previously provided by the device, are included.
|
||||
"""),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters",
|
||||
@@ -556,7 +556,7 @@ public interface DdiRootControllerRestApi {
|
||||
Resource to receive information about a pending confirmation. The response will be of the same format as the
|
||||
deploymentBase operation. The controller should provide feedback about the confirmation first, before
|
||||
processing the deployment.
|
||||
|
||||
|
||||
Keep in mind that the provided download links for the artifacts are generated dynamically by the update server.
|
||||
Host, port and path are not guaranteed to be similar to the provided examples below but will be defined at
|
||||
runtime.
|
||||
|
||||
@@ -43,7 +43,8 @@ class DdiConfirmationBaseTest {
|
||||
final String id = "1234";
|
||||
final DdiDeployment ddiDeployment = new DdiDeployment(FORCED, ATTEMPT, Collections.emptyList(), AVAILABLE);
|
||||
final String actionStatus = "TestAction";
|
||||
final DdiActionHistory ddiActionHistory = new DdiActionHistory(actionStatus, List.of("Action status message 1", "Action status message 2"));
|
||||
final DdiActionHistory ddiActionHistory = new DdiActionHistory(
|
||||
actionStatus, List.of("Action status message 1", "Action status message 2"));
|
||||
final DdiConfirmationBaseAction ddiConfirmationBaseAction = new DdiConfirmationBaseAction(id, ddiDeployment, ddiActionHistory);
|
||||
|
||||
// Test
|
||||
|
||||
@@ -17,7 +17,6 @@ import static org.eclipse.hawkbit.ddi.json.model.DdiDeployment.HandlingType.ATTE
|
||||
import static org.eclipse.hawkbit.ddi.json.model.DdiDeployment.HandlingType.FORCED;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -44,7 +43,8 @@ public class DdiDeploymentBaseTest {
|
||||
final String id = "1234";
|
||||
final DdiDeployment ddiDeployment = new DdiDeployment(FORCED, ATTEMPT, Collections.emptyList(), AVAILABLE);
|
||||
final String actionStatus = "TestAction";
|
||||
final DdiActionHistory ddiActionHistory = new DdiActionHistory(actionStatus, List.of("Action status message 1", "Action status message 2"));
|
||||
final DdiActionHistory ddiActionHistory = new DdiActionHistory(
|
||||
actionStatus, List.of("Action status message 1", "Action status message 2"));
|
||||
final DdiDeploymentBase ddiDeploymentBase = new DdiDeploymentBase(id, ddiDeployment, ddiActionHistory);
|
||||
|
||||
// Test
|
||||
|
||||
@@ -90,7 +90,7 @@ public class DdiStatusTest {
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
final String serializedDdiStatus = "{\"execution\":[\"proceeding\"],\"result\":{\"finished\":\"none\"," +
|
||||
final String serializedDdiStatus = "{\"execution\":[\"proceeding\"],\"result\":{\"finished\":\"none\"," +
|
||||
"\"progress\":{\"cnt\":30,\"of\":100}},\"details\":[]}";
|
||||
|
||||
// Test
|
||||
|
||||
@@ -98,7 +98,10 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
|
||||
private static final String GIVEN_ACTION_IS_NOT_ASSIGNED_TO_GIVEN_TARGET = "given action ({}) is not assigned to given target ({}).";
|
||||
private static final String FALLBACK_REMARK = "Initiated using the Device Direct Integration API without providing a remark.";
|
||||
|
||||
/**
|
||||
* File suffix for MDH hash download (see Linux md5sum).
|
||||
*/
|
||||
private static final String ARTIFACT_MD5_DWNL_SUFFIX = ".MD5SUM";
|
||||
@Autowired
|
||||
private ConfirmationManagement confirmationManagement;
|
||||
@Autowired
|
||||
@@ -121,6 +124,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
private ArtifactUrlHandler artifactUrlHandler;
|
||||
@Autowired
|
||||
private EntityFactory entityFactory;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<DdiArtifact>> getSoftwareModulesArtifacts(
|
||||
final String tenant,
|
||||
@@ -572,6 +576,27 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a md5 file response.
|
||||
*
|
||||
* @param response the response
|
||||
* @param md5Hash of the artifact
|
||||
* @param filename as provided by the client
|
||||
* @throws IOException cannot write output stream
|
||||
*/
|
||||
private static void writeMD5FileResponse(final HttpServletResponse response, final String md5Hash, final String filename)
|
||||
throws IOException {
|
||||
if (md5Hash == null) {
|
||||
throw new IllegalArgumentException("MD5 hash must not be null");
|
||||
}
|
||||
|
||||
final byte[] content = (md5Hash + " " + filename).getBytes(StandardCharsets.US_ASCII);
|
||||
response.setContentType("text/plain");
|
||||
response.setContentLength(content.length);
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + filename + ARTIFACT_MD5_DWNL_SUFFIX);
|
||||
response.getOutputStream().write(content);
|
||||
}
|
||||
|
||||
private ActionStatus checkAndLogDownload(final HttpServletRequest request, final Target target, final Long module) {
|
||||
final Action action = controllerManagement
|
||||
.getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(), module)
|
||||
@@ -713,7 +738,8 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
return new DdiDeploymentBase(Long.toString(action.getId()), ddiDeployment, actionHistory);
|
||||
}
|
||||
|
||||
private DdiConfirmationBaseAction generateDdiConfirmationBase(final Target target, final Action action, final Integer actionHistoryMessageCount) {
|
||||
private DdiConfirmationBaseAction generateDdiConfirmationBase(
|
||||
final Target target, final Action action, final Integer actionHistoryMessageCount) {
|
||||
final DdiActionHistory actionHistory = generateDdiActionHistory(action, actionHistoryMessageCount).orElse(null);
|
||||
final DdiDeployment ddiDeployment = generateDdiDeployment(target, action);
|
||||
return new DdiConfirmationBaseAction(Long.toString(action.getId()), ddiDeployment, actionHistory);
|
||||
@@ -753,29 +779,4 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
return DdiAutoConfirmationState.disabled();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* File suffix for MDH hash download (see Linux md5sum).
|
||||
*/
|
||||
private static final String ARTIFACT_MD5_DWNL_SUFFIX = ".MD5SUM";
|
||||
|
||||
/**
|
||||
* Write a md5 file response.
|
||||
*
|
||||
* @param response the response
|
||||
* @param md5Hash of the artifact
|
||||
* @param filename as provided by the client
|
||||
* @throws IOException cannot write output stream
|
||||
*/
|
||||
private static void writeMD5FileResponse(final HttpServletResponse response, final String md5Hash, final String filename) throws IOException {
|
||||
if (md5Hash == null) {
|
||||
throw new IllegalArgumentException("MD5 hash must not be null");
|
||||
}
|
||||
|
||||
final byte[] content = (md5Hash + " " + filename).getBytes(StandardCharsets.US_ASCII);
|
||||
response.setContentType("text/plain");
|
||||
response.setContentLength(content.length);
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + filename + ARTIFACT_MD5_DWNL_SUFFIX);
|
||||
response.getOutputStream().write(content);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,5 @@ import org.springframework.context.annotation.Import;
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(DdiApiConfiguration.class)
|
||||
@Import({ DdiApiConfiguration.class, DdiSecurityProperties.class} )
|
||||
public class DdiApiAutoConfiguration {
|
||||
|
||||
}
|
||||
@Import({ DdiApiConfiguration.class, DdiSecurityProperties.class })
|
||||
public class DdiApiAutoConfiguration {}
|
||||
Reference in New Issue
Block a user