Complete API for action cancelation. (#643)
* Complete API for action cancelation. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix content bug
This commit is contained in:
@@ -113,6 +113,7 @@ Payload Template
|
||||
"message":["String"]
|
||||
}
|
||||
```
|
||||
|
||||
Possible actionStatus
|
||||
|
||||
| Header | Description |
|
||||
@@ -155,12 +156,25 @@ Possible actionStatus
|
||||
|-----------------------------|----------------------------------|-------------------------------------|----------------
|
||||
| content_type | The content type of the payload | String | true
|
||||
|
||||
**Example Header**
|
||||
Payload Template
|
||||
|
||||
```json
|
||||
{
|
||||
"actionId": long
|
||||
}
|
||||
```
|
||||
|
||||
**Example Header and payload**
|
||||
|
||||
| Headers | MessageProperties |
|
||||
|---------------------------------------|---------------------------------|
|
||||
| type=EVENT <br /> tenant=tenant123 <br /> thingId=abc <br /> topic=CANCEL\_DOWNLOAD | content_type=application/json
|
||||
|
||||
```json
|
||||
{
|
||||
"actionId":137
|
||||
}
|
||||
```
|
||||
|
||||
After this message has been sent, an action status event with either actionStatus=CANCELED or actionStatus=CANCEL_REJECTED has to be returned.
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.eclipse.hawkbit.api.URLPlaceholder.SoftwareData;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.MessageType;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfActionRequest;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfArtifact;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfArtifactHash;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfDownloadAndUpdateRequest;
|
||||
@@ -241,7 +242,11 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
||||
if (!IpUtil.isAmqpUri(address)) {
|
||||
return;
|
||||
}
|
||||
final Message message = getMessageConverter().toMessage(actionId,
|
||||
|
||||
final DmfActionRequest actionRequest = new DmfActionRequest();
|
||||
actionRequest.setActionId(actionId);
|
||||
|
||||
final Message message = getMessageConverter().toMessage(actionRequest,
|
||||
createConnectorMessagePropertiesEvent(tenant, controllerId, EventTopic.CANCEL_DOWNLOAD));
|
||||
|
||||
amqpSenderService.sendMessage(message, address);
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.MessageType;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfActionRequest;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfDownloadAndUpdateRequest;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfMetadata;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
@@ -277,8 +278,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
||||
|
||||
private void assertCancelMessage(final Message sendMessage) {
|
||||
assertEventMessage(sendMessage);
|
||||
final Long actionId = convertMessage(sendMessage, Long.class);
|
||||
assertEquals("Action ID should be 1", actionId, Long.valueOf(1));
|
||||
final DmfActionRequest actionId = convertMessage(sendMessage, DmfActionRequest.class);
|
||||
assertEquals("Action ID should be 1", actionId.getActionId(), Long.valueOf(1));
|
||||
assertEquals("The topc in the message should be a CANCEL_DOWNLOAD value", EventTopic.CANCEL_DOWNLOAD,
|
||||
sendMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.TOPIC));
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.MessageType;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfActionRequest;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfAttributeUpdate;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfDownloadAndUpdateRequest;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfMetadata;
|
||||
@@ -128,8 +129,9 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
|
||||
protected void assertCancelActionMessage(final Long actionId, final String controllerId) {
|
||||
final Message replyMessage = assertReplyMessageHeader(EventTopic.CANCEL_DOWNLOAD, controllerId);
|
||||
|
||||
final Long actionUpdateStatus = (Long) getDmfClient().getMessageConverter().fromMessage(replyMessage);
|
||||
assertThat(actionUpdateStatus).isEqualTo(actionId);
|
||||
final DmfActionRequest actionUpdateStatus = (DmfActionRequest) getDmfClient().getMessageConverter()
|
||||
.fromMessage(replyMessage);
|
||||
assertThat(actionUpdateStatus.getActionId()).isEqualTo(actionId);
|
||||
}
|
||||
|
||||
protected void assertDeleteMessage(final String target) {
|
||||
|
||||
@@ -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.dmf.json.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* JSON representation of an action related request.
|
||||
*
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DmfActionRequest {
|
||||
@JsonProperty
|
||||
private Long actionId;
|
||||
|
||||
public Long getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
public void setActionId(final Long correlator) {
|
||||
this.actionId = correlator;
|
||||
}
|
||||
}
|
||||
@@ -23,9 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DmfDownloadAndUpdateRequest {
|
||||
@JsonProperty
|
||||
private Long actionId;
|
||||
public class DmfDownloadAndUpdateRequest extends DmfActionRequest {
|
||||
|
||||
@JsonProperty
|
||||
private String targetSecurityToken;
|
||||
@@ -33,14 +31,6 @@ public class DmfDownloadAndUpdateRequest {
|
||||
@JsonProperty
|
||||
private List<DmfSoftwareModule> softwareModules;
|
||||
|
||||
public Long getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
public void setActionId(final Long correlator) {
|
||||
this.actionId = correlator;
|
||||
}
|
||||
|
||||
public String getTargetSecurityToken() {
|
||||
return targetSecurityToken;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user