Fix Sonar findings - DdiRootController unused (#2524)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -53,7 +53,7 @@ public final class DdiRestConstants {
|
|||||||
/**
|
/**
|
||||||
* File suffix for MDH hash download (see Linux md5sum).
|
* File suffix for MDH hash download (see Linux md5sum).
|
||||||
*/
|
*/
|
||||||
public static final String ARTIFACT_MD5_DWNL_SUFFIX = ".MD5SUM";
|
public static final String ARTIFACT_MD5_DOWNLOAD_SUFFIX = ".MD5SUM";
|
||||||
/**
|
/**
|
||||||
* Config data action resources.
|
* Config data action resources.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ public interface DdiRootControllerRestApi {
|
|||||||
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true)))
|
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true)))
|
||||||
})
|
})
|
||||||
@GetMapping(value = DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{fileName}" +
|
@GetMapping(value = DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{fileName}" +
|
||||||
DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX, produces = MediaType.TEXT_PLAIN_VALUE)
|
DdiRestConstants.ARTIFACT_MD5_DOWNLOAD_SUFFIX, produces = MediaType.TEXT_PLAIN_VALUE)
|
||||||
ResponseEntity<Void> downloadArtifactMd5(
|
ResponseEntity<Void> downloadArtifactMd5(
|
||||||
@PathVariable("tenant") String tenant,
|
@PathVariable("tenant") String tenant,
|
||||||
@PathVariable("controllerId") String controllerId,
|
@PathVariable("controllerId") String controllerId,
|
||||||
|
|||||||
@@ -72,9 +72,6 @@ import org.eclipse.hawkbit.rest.util.RequestResponseContextHolder;
|
|||||||
import org.eclipse.hawkbit.security.HawkbitSecurityProperties;
|
import org.eclipse.hawkbit.security.HawkbitSecurityProperties;
|
||||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||||
import org.eclipse.hawkbit.util.IpUtil;
|
import org.eclipse.hawkbit.util.IpUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.cloud.bus.BusProperties;
|
|
||||||
import org.springframework.cloud.bus.ServiceMatcher;
|
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
@@ -89,7 +86,7 @@ import org.springframework.web.context.WebApplicationContext;
|
|||||||
* The {@link DdiRootController} of the hawkBit server DDI API that is queried by the hawkBit
|
* The {@link DdiRootController} of the hawkBit server DDI API that is queried by the hawkBit
|
||||||
* controller in order to pull {@link Action}s that have to be fulfilled and report status updates concerning
|
* controller in order to pull {@link Action}s that have to be fulfilled and report status updates concerning
|
||||||
* the {@link Action} processing.
|
* the {@link Action} processing.
|
||||||
*
|
* <p/>
|
||||||
* Transactional (read-write) as all queries at least update the last poll time.
|
* Transactional (read-write) as all queries at least update the last poll time.
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -99,10 +96,6 @@ 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 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.";
|
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";
|
|
||||||
|
|
||||||
private final ControllerManagement controllerManagement;
|
private final ControllerManagement controllerManagement;
|
||||||
private final ConfirmationManagement confirmationManagement;
|
private final ConfirmationManagement confirmationManagement;
|
||||||
@@ -110,18 +103,16 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
private final ArtifactUrlHandler artifactUrlHandler;
|
private final ArtifactUrlHandler artifactUrlHandler;
|
||||||
private final SystemManagement systemManagement;
|
private final SystemManagement systemManagement;
|
||||||
private final ApplicationEventPublisher eventPublisher;
|
private final ApplicationEventPublisher eventPublisher;
|
||||||
private final BusProperties bus;
|
|
||||||
private final HawkbitSecurityProperties securityProperties;
|
private final HawkbitSecurityProperties securityProperties;
|
||||||
private final TenantAware tenantAware;
|
private final TenantAware tenantAware;
|
||||||
private final EntityFactory entityFactory;
|
private final EntityFactory entityFactory;
|
||||||
private ServiceMatcher serviceMatcher;
|
|
||||||
|
|
||||||
@SuppressWarnings("java:S107")
|
@SuppressWarnings("java:S107")
|
||||||
public DdiRootController(
|
public DdiRootController(
|
||||||
final ControllerManagement controllerManagement, final ConfirmationManagement confirmationManagement,
|
final ControllerManagement controllerManagement, final ConfirmationManagement confirmationManagement,
|
||||||
final ArtifactManagement artifactManagement, final ArtifactUrlHandler artifactUrlHandler,
|
final ArtifactManagement artifactManagement, final ArtifactUrlHandler artifactUrlHandler,
|
||||||
final SystemManagement systemManagement,
|
final SystemManagement systemManagement,
|
||||||
final ApplicationEventPublisher eventPublisher, final BusProperties bus,
|
final ApplicationEventPublisher eventPublisher,
|
||||||
final HawkbitSecurityProperties securityProperties, final TenantAware tenantAware, final EntityFactory entityFactory) {
|
final HawkbitSecurityProperties securityProperties, final TenantAware tenantAware, final EntityFactory entityFactory) {
|
||||||
this.controllerManagement = controllerManagement;
|
this.controllerManagement = controllerManagement;
|
||||||
this.confirmationManagement = confirmationManagement;
|
this.confirmationManagement = confirmationManagement;
|
||||||
@@ -129,17 +120,11 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
this.artifactUrlHandler = artifactUrlHandler;
|
this.artifactUrlHandler = artifactUrlHandler;
|
||||||
this.systemManagement = systemManagement;
|
this.systemManagement = systemManagement;
|
||||||
this.eventPublisher = eventPublisher;
|
this.eventPublisher = eventPublisher;
|
||||||
this.bus = bus;
|
|
||||||
this.securityProperties = securityProperties;
|
this.securityProperties = securityProperties;
|
||||||
this.tenantAware = tenantAware;
|
this.tenantAware = tenantAware;
|
||||||
this.entityFactory = entityFactory;
|
this.entityFactory = entityFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired(required = false)
|
|
||||||
public void setServiceMatcher(final ServiceMatcher serviceMatcher) {
|
|
||||||
this.serviceMatcher = serviceMatcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<List<DdiArtifact>> getSoftwareModulesArtifacts(
|
public ResponseEntity<List<DdiArtifact>> getSoftwareModulesArtifacts(
|
||||||
final String tenant,
|
final String tenant,
|
||||||
@@ -609,7 +594,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
final byte[] content = (md5Hash + " " + filename).getBytes(StandardCharsets.US_ASCII);
|
final byte[] content = (md5Hash + " " + filename).getBytes(StandardCharsets.US_ASCII);
|
||||||
response.setContentType("text/plain");
|
response.setContentType("text/plain");
|
||||||
response.setContentLength(content.length);
|
response.setContentLength(content.length);
|
||||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + filename + ARTIFACT_MD5_DWNL_SUFFIX);
|
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + filename + DdiRestConstants.ARTIFACT_MD5_DOWNLOAD_SUFFIX);
|
||||||
response.getOutputStream().write(content);
|
response.getOutputStream().write(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -766,10 +751,9 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Optional<DdiActionHistory> generateDdiActionHistory(final Action action, final Integer actionHistoryMessageCount) {
|
private Optional<DdiActionHistory> generateDdiActionHistory(final Action action, final Integer actionHistoryMessageCount) {
|
||||||
final List<String> actionHistoryMsgs = controllerManagement.getActionHistoryMessages(action.getId(),
|
final List<String> actionHistoryMsgs = controllerManagement.getActionHistoryMessages(
|
||||||
actionHistoryMessageCount == null
|
action.getId(),
|
||||||
? Integer.parseInt(DdiRestConstants.NO_ACTION_HISTORY)
|
actionHistoryMessageCount == null ? Integer.parseInt(DdiRestConstants.NO_ACTION_HISTORY) : actionHistoryMessageCount);
|
||||||
: actionHistoryMessageCount);
|
|
||||||
return actionHistoryMsgs.isEmpty()
|
return actionHistoryMsgs.isEmpty()
|
||||||
? Optional.empty()
|
? Optional.empty()
|
||||||
: Optional.of(new DdiActionHistory(action.getStatus().name(), actionHistoryMsgs));
|
: Optional.of(new DdiActionHistory(action.getStatus().name(), actionHistoryMsgs));
|
||||||
|
|||||||
Reference in New Issue
Block a user