Renamed new DMF parent folder to be consistent with other parents. (#499)
* Fix DMF folder name. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Alligned name. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Delete old gitgnore Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
8
hawkbit-dmf/hawkbit-dmf-api/README.md
Normal file
8
hawkbit-dmf/hawkbit-dmf-api/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# hawkBit device management federation API - model definition
|
||||
|
||||
This API is used for communicating with the hawkBit Update Server through AMQP.
|
||||
It is used to integrate other device management system through a high throughput protocol optimized for service to service communication.
|
||||
|
||||
# Version 1
|
||||
|
||||
The model follows [semantic versioning](http://semver.org) with MAJOR version, i.e. breaking changes will result in a new MAJOR version.
|
||||
29
hawkbit-dmf/hawkbit-dmf-api/pom.xml
Normal file
29
hawkbit-dmf/hawkbit-dmf-api/pom.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<!--
|
||||
|
||||
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
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-dmf-parent</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>hawkbit-dmf-api</artifactId>
|
||||
<name>hawkBit :: DMF :: API</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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.amqp.api;
|
||||
|
||||
/**
|
||||
* Global constants for RabbitMQ settings.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class AmqpSettings {
|
||||
|
||||
public static final String DMF_EXCHANGE = "dmf.exchange";
|
||||
|
||||
public static final String AUTHENTICATION_EXCHANGE = "authentication.exchange";
|
||||
|
||||
private AmqpSettings() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.amqp.api;
|
||||
|
||||
/**
|
||||
* The event topics for the message headers.
|
||||
*/
|
||||
public enum EventTopic {
|
||||
|
||||
/**
|
||||
* Topic when sending and receiving a update status.
|
||||
*/
|
||||
UPDATE_ACTION_STATUS,
|
||||
/**
|
||||
* Topic when sending and receiving a download and install task.
|
||||
*/
|
||||
DOWNLOAD_AND_INSTALL,
|
||||
/**
|
||||
* Topic when sending and receiving a cancel download task.
|
||||
*/
|
||||
CANCEL_DOWNLOAD,
|
||||
/**
|
||||
* Topic when updating device attributes.
|
||||
*/
|
||||
UPDATE_ATTRIBUTES;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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.amqp.api;
|
||||
|
||||
/**
|
||||
* The constant of all amqp message header.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class MessageHeaderKey {
|
||||
|
||||
/**
|
||||
* The message type.
|
||||
*/
|
||||
public static final String TYPE = "type";
|
||||
|
||||
/**
|
||||
* The used tenant.
|
||||
*/
|
||||
public static final String TENANT = "tenant";
|
||||
|
||||
/**
|
||||
* The name of the thing/target.
|
||||
*/
|
||||
public static final String THING_ID = "thingId";
|
||||
|
||||
/**
|
||||
* The name of the sender who has send the message.
|
||||
*/
|
||||
public static final String SENDER = "sender";
|
||||
|
||||
/**
|
||||
* The topic to handle events different.
|
||||
*/
|
||||
public static final String TOPIC = "topic";
|
||||
|
||||
/**
|
||||
* The content type.
|
||||
*/
|
||||
public static final String CONTENT_TYPE = "content-type";
|
||||
|
||||
private MessageHeaderKey() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 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.amqp.api;
|
||||
|
||||
/**
|
||||
* The amqp message types which can be handled.
|
||||
*
|
||||
*/
|
||||
public enum MessageType {
|
||||
|
||||
/**
|
||||
* The event type.
|
||||
*/
|
||||
EVENT,
|
||||
|
||||
/**
|
||||
* The thing created type.
|
||||
*/
|
||||
THING_CREATED,
|
||||
|
||||
/**
|
||||
* The thing deleted type.
|
||||
*/
|
||||
THING_DELETED,
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* The json message action status.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public enum ActionStatus {
|
||||
/**
|
||||
* Action requests download by this target which has now started.
|
||||
*/
|
||||
DOWNLOAD,
|
||||
|
||||
/**
|
||||
* Action has been send to the target.
|
||||
*/
|
||||
RETRIEVED,
|
||||
|
||||
/**
|
||||
* Action is still running for this target.
|
||||
*/
|
||||
RUNNING,
|
||||
|
||||
/**
|
||||
* Action is finished successfully for this target.
|
||||
*/
|
||||
FINISHED,
|
||||
|
||||
/**
|
||||
* Action has failed for this target.
|
||||
*/
|
||||
ERROR,
|
||||
|
||||
/**
|
||||
* Action is still running but with warnings.
|
||||
*/
|
||||
WARNING,
|
||||
|
||||
/**
|
||||
* Action has been canceled for this target.
|
||||
*/
|
||||
CANCELED,
|
||||
|
||||
/**
|
||||
* Cancellation has been rejected by the target..
|
||||
*/
|
||||
CANCEL_REJECTED;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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 action update status.
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ActionUpdateStatus {
|
||||
|
||||
private final Long actionId;
|
||||
private final ActionStatus actionStatus;
|
||||
|
||||
@JsonProperty
|
||||
private Long softwareModuleId;
|
||||
|
||||
@JsonProperty
|
||||
private List<String> message;
|
||||
|
||||
public ActionUpdateStatus(@JsonProperty(value = "actionId", required = true) Long actionId,
|
||||
@JsonProperty(value = "actionStatus", required = true) ActionStatus actionStatus) {
|
||||
this.actionId = actionId;
|
||||
this.actionStatus = actionStatus;
|
||||
}
|
||||
|
||||
public Long getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
public Long getSoftwareModuleId() {
|
||||
return softwareModuleId;
|
||||
}
|
||||
|
||||
public void setSoftwareModuleId(final Long softwareModuleId) {
|
||||
this.softwareModuleId = softwareModuleId;
|
||||
}
|
||||
|
||||
public ActionStatus getActionStatus() {
|
||||
return actionStatus;
|
||||
}
|
||||
|
||||
public List<String> getMessage() {
|
||||
if (message == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public boolean addMessage(final String message) {
|
||||
if (this.message == null) {
|
||||
this.message = new ArrayList<>();
|
||||
}
|
||||
|
||||
return this.message.add(message);
|
||||
}
|
||||
|
||||
public boolean addMessage(final Collection<String> messages) {
|
||||
if (messages == null || messages.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (message == null) {
|
||||
message = new ArrayList<>(messages);
|
||||
return true;
|
||||
}
|
||||
|
||||
return message.addAll(messages);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* 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 java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
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 artifact.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Artifact {
|
||||
@JsonProperty
|
||||
private String filename;
|
||||
|
||||
@JsonProperty
|
||||
private ArtifactHash hashes;
|
||||
|
||||
@JsonProperty
|
||||
private Long size;
|
||||
|
||||
@JsonProperty
|
||||
private Map<String, String> urls;
|
||||
|
||||
public Map<String, String> getUrls() {
|
||||
if (urls == null) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
return Collections.unmodifiableMap(urls);
|
||||
}
|
||||
|
||||
public void setUrls(final Map<String, String> urls) {
|
||||
this.urls = urls;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename(final String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public ArtifactHash getHashes() {
|
||||
return hashes;
|
||||
}
|
||||
|
||||
public void setHashes(final ArtifactHash hashes) {
|
||||
this.hashes = hashes;
|
||||
}
|
||||
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(final Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* 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.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* JSON representation of artifact hash.
|
||||
*/
|
||||
public class ArtifactHash {
|
||||
|
||||
@JsonProperty
|
||||
private String sha1;
|
||||
|
||||
@JsonProperty
|
||||
private String md5;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param sha1
|
||||
* the sha1 hash
|
||||
* @param md5
|
||||
* the md5 hash
|
||||
*/
|
||||
@JsonCreator
|
||||
public ArtifactHash(@JsonProperty("sha1") final String sha1, @JsonProperty("md5") final String md5) {
|
||||
super();
|
||||
this.sha1 = sha1;
|
||||
this.md5 = md5;
|
||||
}
|
||||
|
||||
public void setSha1(final String sha1) {
|
||||
this.sha1 = sha1;
|
||||
}
|
||||
|
||||
public void setMd5(final String md5) {
|
||||
this.md5 = md5;
|
||||
}
|
||||
|
||||
public String getSha1() {
|
||||
return sha1;
|
||||
}
|
||||
|
||||
public String getMd5() {
|
||||
return md5;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 java.lang.annotation.Target;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Map of {@link Target} attributes.
|
||||
*
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class AttributeUpdate {
|
||||
@JsonProperty
|
||||
private final Map<String, String> attributes = new HashMap<>();
|
||||
|
||||
public Map<String, String> getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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 download and update request.
|
||||
*
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DownloadAndUpdateRequest {
|
||||
@JsonProperty
|
||||
private Long actionId;
|
||||
|
||||
@JsonProperty
|
||||
private String targetSecurityToken;
|
||||
|
||||
@JsonProperty
|
||||
private List<SoftwareModule> softwareModules;
|
||||
|
||||
public Long getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
public void setActionId(final Long correlator) {
|
||||
this.actionId = correlator;
|
||||
}
|
||||
|
||||
public String getTargetSecurityToken() {
|
||||
return targetSecurityToken;
|
||||
}
|
||||
|
||||
public void setTargetSecurityToken(final String targetSecurityToken) {
|
||||
this.targetSecurityToken = targetSecurityToken;
|
||||
}
|
||||
|
||||
public List<SoftwareModule> getSoftwareModules() {
|
||||
if (softwareModules == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return Collections.unmodifiableList(softwareModules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Software module.
|
||||
*
|
||||
* @param createSoftwareModule
|
||||
* the module
|
||||
*/
|
||||
public void addSoftwareModule(final SoftwareModule createSoftwareModule) {
|
||||
if (softwareModules == null) {
|
||||
softwareModules = new ArrayList<>();
|
||||
}
|
||||
|
||||
softwareModules.add(createSoftwareModule);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* The authentification response JSON representation.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DownloadResponse {
|
||||
|
||||
@JsonProperty
|
||||
private String downloadUrl;
|
||||
|
||||
@JsonProperty
|
||||
private Artifact artifact;
|
||||
|
||||
@JsonProperty
|
||||
private int responseCode;
|
||||
|
||||
@JsonProperty
|
||||
private String message;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(final String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getResponseCode() {
|
||||
return responseCode;
|
||||
}
|
||||
|
||||
public void setResponseCode(final int responseCode) {
|
||||
this.responseCode = responseCode;
|
||||
}
|
||||
|
||||
public String getDownloadUrl() {
|
||||
return downloadUrl;
|
||||
}
|
||||
|
||||
public void setDownloadUrl(final String downloadUrl) {
|
||||
this.downloadUrl = downloadUrl;
|
||||
}
|
||||
|
||||
public Artifact getArtifact() {
|
||||
return artifact;
|
||||
}
|
||||
|
||||
public void setArtifact(final Artifact artifact) {
|
||||
this.artifact = artifact;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* 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 java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
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 a software module.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class SoftwareModule {
|
||||
|
||||
@JsonProperty
|
||||
private Long moduleId;
|
||||
@JsonProperty
|
||||
private String moduleType;
|
||||
@JsonProperty
|
||||
private String moduleVersion;
|
||||
@JsonProperty
|
||||
private List<Artifact> artifacts;
|
||||
|
||||
public String getModuleType() {
|
||||
return moduleType;
|
||||
}
|
||||
|
||||
public void setModuleType(final String moduleType) {
|
||||
this.moduleType = moduleType;
|
||||
}
|
||||
|
||||
public String getModuleVersion() {
|
||||
return moduleVersion;
|
||||
}
|
||||
|
||||
public void setModuleVersion(final String moduleVersion) {
|
||||
this.moduleVersion = moduleVersion;
|
||||
}
|
||||
|
||||
public List<Artifact> getArtifacts() {
|
||||
if (artifacts == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return Collections.unmodifiableList(artifacts);
|
||||
}
|
||||
|
||||
public Long getModuleId() {
|
||||
return moduleId;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setModuleId(final Long moduleId) {
|
||||
this.moduleId = moduleId;
|
||||
}
|
||||
|
||||
public void setArtifacts(final List<Artifact> artifacts) {
|
||||
this.artifacts = artifacts;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
/**
|
||||
* 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 java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
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 to authenticate a tenant.
|
||||
*/
|
||||
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class TenantSecurityToken {
|
||||
|
||||
public static final String AUTHORIZATION_HEADER = "Authorization";
|
||||
|
||||
@JsonProperty(required = false)
|
||||
private String tenant;
|
||||
@JsonProperty(required = false)
|
||||
private final Long tenantId;
|
||||
@JsonProperty(required = false)
|
||||
private final String controllerId;
|
||||
@JsonProperty(required = false)
|
||||
private final Long targetId;
|
||||
|
||||
@JsonProperty(required = false)
|
||||
private Map<String, String> headers;
|
||||
|
||||
@JsonProperty(required = false)
|
||||
private final FileResource fileResource;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant for the security token
|
||||
* @param tenantId
|
||||
* alternative tenant identification by technical ID
|
||||
* @param controllerId
|
||||
* the ID of the controller for the security token
|
||||
* @param targetId
|
||||
* alternative target identification by technical ID
|
||||
* @param fileResource
|
||||
* the file to obtain
|
||||
*/
|
||||
@JsonCreator
|
||||
public TenantSecurityToken(@JsonProperty("tenant") final String tenant,
|
||||
@JsonProperty("tenantId") final Long tenantId, @JsonProperty("controllerId") final String controllerId,
|
||||
@JsonProperty("targetId") final Long targetId,
|
||||
@JsonProperty("fileResource") final FileResource fileResource) {
|
||||
this.tenant = tenant;
|
||||
this.tenantId = tenantId;
|
||||
this.controllerId = controllerId;
|
||||
this.targetId = targetId;
|
||||
this.fileResource = fileResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant for the security token
|
||||
* @param controllerId
|
||||
* the ID of the controller for the security token
|
||||
* @param fileResource
|
||||
* the file to obtain
|
||||
*/
|
||||
public TenantSecurityToken(final String tenant, final String controllerId, final FileResource fileResource) {
|
||||
this(tenant, null, controllerId, null, fileResource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenantId
|
||||
* the tenant for the security token
|
||||
* @param targetId
|
||||
* target identification by technical ID
|
||||
* @param fileResource
|
||||
* the file to obtain
|
||||
*/
|
||||
public TenantSecurityToken(final Long tenantId, final Long targetId, final FileResource fileResource) {
|
||||
this(null, tenantId, null, targetId, fileResource);
|
||||
}
|
||||
|
||||
public void setTenant(final String tenant) {
|
||||
this.tenant = tenant;
|
||||
}
|
||||
|
||||
public String getTenant() {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
public String getControllerId() {
|
||||
return controllerId;
|
||||
}
|
||||
|
||||
public Map<String, String> getHeaders() {
|
||||
if (headers == null) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
return Collections.unmodifiableMap(headers);
|
||||
}
|
||||
|
||||
public FileResource getFileResource() {
|
||||
return fileResource;
|
||||
}
|
||||
|
||||
public Long getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public Long getTargetId() {
|
||||
return targetId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header value.
|
||||
*
|
||||
* @param name
|
||||
* of header
|
||||
* @return the value
|
||||
*/
|
||||
public String getHeader(final String name) {
|
||||
if (headers == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return headers.get(name);
|
||||
}
|
||||
|
||||
public void setHeaders(final Map<String, String> headers) {
|
||||
this.headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
this.headers.putAll(headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Associates the specified header value with the specified name.
|
||||
*
|
||||
* @param name
|
||||
* of the header
|
||||
* @param value
|
||||
* of the header
|
||||
*
|
||||
* @return the previous value associated with the <tt>name</tt>, or
|
||||
* <tt>null</tt> if there was no mapping for <tt>name</tt>.
|
||||
*/
|
||||
public String putHeader(final String name, final String value) {
|
||||
if (headers == null) {
|
||||
headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
}
|
||||
return headers.put(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* File resource descriptor which is used to ask for the resource to
|
||||
* download e.g. The lookup of the file can be different e.g. by SHA1 hash
|
||||
* or by filename.
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class FileResource {
|
||||
@JsonProperty(required = false)
|
||||
private String sha1;
|
||||
@JsonProperty(required = false)
|
||||
private Long artifactId;
|
||||
@JsonProperty(required = false)
|
||||
private String filename;
|
||||
@JsonProperty(required = false)
|
||||
private SoftwareModuleFilenameResource softwareModuleFilenameResource;
|
||||
|
||||
public String getSha1() {
|
||||
return sha1;
|
||||
}
|
||||
|
||||
public void setSha1(final String sha1) {
|
||||
this.sha1 = sha1;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename(final String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public SoftwareModuleFilenameResource getSoftwareModuleFilenameResource() {
|
||||
return softwareModuleFilenameResource;
|
||||
}
|
||||
|
||||
public void setSoftwareModuleFilenameResource(
|
||||
final SoftwareModuleFilenameResource softwareModuleFilenameResource) {
|
||||
this.softwareModuleFilenameResource = softwareModuleFilenameResource;
|
||||
}
|
||||
|
||||
public Long getArtifactId() {
|
||||
return artifactId;
|
||||
}
|
||||
|
||||
public void setArtifactId(final Long artifactId) {
|
||||
this.artifactId = artifactId;
|
||||
}
|
||||
|
||||
/**
|
||||
* factory method to create a file resource for an SHA1 lookup.
|
||||
*
|
||||
* @param sha1
|
||||
* the SHA1 key of the file to obtain
|
||||
* @return the {@link FileResource} with SHA1 key set
|
||||
*/
|
||||
public static FileResource createFileResourceBySha1(final String sha1) {
|
||||
final FileResource resource = new FileResource();
|
||||
resource.sha1 = sha1;
|
||||
return resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* factory method to create a file resource for an artifact ID lookup.
|
||||
*
|
||||
* @param artifactId
|
||||
* the artifact IF key of the file to obtain
|
||||
* @return the {@link FileResource} with SHA1 key set
|
||||
*/
|
||||
public static FileResource createFileResourceByArtifactId(final Long artifactId) {
|
||||
final FileResource resource = new FileResource();
|
||||
resource.artifactId = artifactId;
|
||||
return resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* factory method to create a file resource for an filename lookup.
|
||||
*
|
||||
* @param filename
|
||||
* the filename of the file to obtain
|
||||
* @return the {@link FileResource} with filename set
|
||||
*/
|
||||
public static FileResource createFileResourceByFilename(final String filename) {
|
||||
final FileResource resource = new FileResource();
|
||||
resource.filename = filename;
|
||||
return resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* factory method to create a file resource for an softwaremodule +
|
||||
* filename lookup, because an filename is not globally unique but
|
||||
* within a softwaremodule.
|
||||
*
|
||||
* @param softwareModuleId
|
||||
* the ID of the software module which contains the artifact
|
||||
* @param filename
|
||||
* the name of file to obtain within the software module
|
||||
* @return the {@link FileResource} with artifactId set
|
||||
*/
|
||||
public static FileResource softwareModuleFilename(final Long softwareModuleId, final String filename) {
|
||||
final FileResource resource = new FileResource();
|
||||
resource.softwareModuleFilenameResource = new SoftwareModuleFilenameResource(softwareModuleId, filename);
|
||||
return resource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FileResource [sha1=" + sha1 + ", artifactId=" + artifactId + ", filename=" + filename + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Inner class which holds the pointer to an artifact based on the
|
||||
* softwaremoduleId and the filename.
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class SoftwareModuleFilenameResource {
|
||||
@JsonProperty(required = false)
|
||||
private Long softwareModuleId;
|
||||
@JsonProperty(required = false)
|
||||
private String filename;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param softwareModuleId
|
||||
* the ID of the softwaremodule
|
||||
* @param filename
|
||||
* the name of the file of the artifact within the
|
||||
* softwaremodule
|
||||
*/
|
||||
@JsonCreator
|
||||
public SoftwareModuleFilenameResource(@JsonProperty("softwareModuleId") final Long softwareModuleId,
|
||||
@JsonProperty("filename") final String filename) {
|
||||
this.softwareModuleId = softwareModuleId;
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public Long getSoftwareModuleId() {
|
||||
return softwareModuleId;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setSoftwareModuleId(final Long softwareModuleId) {
|
||||
this.softwareModuleId = softwareModuleId;
|
||||
}
|
||||
|
||||
public void setFilename(final String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user