SDK DMF Support - Removed duplication (#1707)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.sdk.dmf;
|
||||
package org.eclipse.hawkbit.sdk.spi;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
@@ -1,73 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.sdk.device;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Artifact handler provide plug-in endpoint allowing for customization of the artifact processing.
|
||||
* For instance, it could save downloaded files in some location and on successful finish could
|
||||
* apply them.
|
||||
*/
|
||||
public interface ArtifactHandler {
|
||||
|
||||
ArtifactHandler SKIP = url -> DownloadHandler.SKIP;
|
||||
|
||||
DownloadHandler getDownloadHandler(final String url);
|
||||
|
||||
interface DownloadHandler {
|
||||
|
||||
enum Status {
|
||||
SUCCESS, ERROR
|
||||
}
|
||||
|
||||
DownloadHandler SKIP = new DownloadHandler() {
|
||||
@Override
|
||||
public void read(byte[] buff, int off, int len) {
|
||||
// skip
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finished(Status status) {
|
||||
// skip
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Path> download() {
|
||||
return Optional.empty();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Called on every read chunk of data
|
||||
*
|
||||
* @param buff buffer
|
||||
* @param off offset
|
||||
* @param len read bytes
|
||||
*/
|
||||
void read(byte[] buff, int off, int len);
|
||||
|
||||
/**
|
||||
* Called when the download has finished. It could have finished with error in case of network problems,
|
||||
* invalid hashes or size. In case of success the hashes and size are already checked and valid.
|
||||
*
|
||||
* @param status finish status. On error the download shall be discarded and related resources shall be released
|
||||
*/
|
||||
void finished(Status status);
|
||||
|
||||
/**
|
||||
* Return download path if existing
|
||||
*
|
||||
* @return the path to the download
|
||||
*/
|
||||
Optional<Path> download();
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import org.eclipse.hawkbit.ddi.json.model.DdiArtifact;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiArtifactHash;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiChunk;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiDeployment;
|
||||
import org.eclipse.hawkbit.sdk.spi.ArtifactHandler;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.eclipse.hawkbit.dmf.json.model.DmfArtifact;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfArtifactHash;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfDownloadAndUpdateRequest;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfSoftwareModule;
|
||||
import org.eclipse.hawkbit.sdk.spi.ArtifactHandler;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class DmfReceiverService extends MessageService {
|
||||
|
||||
private final Set<Long> openActions = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
DmfReceiverService(final RabbitTemplate rabbitTemplate, final DmfSenderService dmfSenderService,
|
||||
public DmfReceiverService(final RabbitTemplate rabbitTemplate, final DmfSenderService dmfSenderService,
|
||||
final DeviceManagement deviceManagement, final DmfProperties dmfProperties) {
|
||||
super(rabbitTemplate, dmfProperties);
|
||||
this.dmfSenderService = dmfSenderService;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class DmfSenderService extends MessageService {
|
||||
private final String spExchange;
|
||||
private final ConcurrentHashMap<String, BiConsumer<String, Message>> pingListeners = new ConcurrentHashMap<>();
|
||||
|
||||
DmfSenderService(final RabbitTemplate rabbitTemplate, final DmfProperties dmfProperties) {
|
||||
public DmfSenderService(final RabbitTemplate rabbitTemplate, final DmfProperties dmfProperties) {
|
||||
super(rabbitTemplate, dmfProperties);
|
||||
spExchange = AmqpSettings.DMF_EXCHANGE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user