Lombok/apply to security repo3 (#1594)

* Improve Security Core with lombok (#1592)

Add lombok to repository modules

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

* Improve Security Core with lombok 3

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

---------

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-02-03 04:46:24 +02:00
committed by GitHub
parent 1c5a7bbeb3
commit f69d386613
10 changed files with 42 additions and 307 deletions

View File

@@ -9,10 +9,13 @@
*/
package org.eclipse.hawkbit.api;
import lombok.Data;
/**
* Container for a generated Artifact URL.
*
*/
@Data
public class ArtifactUrl {
private final String protocol;
@@ -34,77 +37,4 @@ public class ArtifactUrl {
this.rel = rel;
this.ref = ref;
}
/**
* @return protocol name used in DMF API messages.
*/
public String getProtocol() {
return protocol;
}
/**
* @return rel links value useful in hypermedia.
*/
public String getRel() {
return rel;
}
/**
* @return generated artifact download URL
*/
public String getRef() {
return ref;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
result = prime * result + ((ref == null) ? 0 : ref.hashCode());
result = prime * result + ((rel == null) ? 0 : rel.hashCode());
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final ArtifactUrl other = (ArtifactUrl) obj;
if (protocol == null) {
if (other.protocol != null) {
return false;
}
} else if (!protocol.equals(other.protocol)) {
return false;
}
if (ref == null) {
if (other.ref != null) {
return false;
}
} else if (!ref.equals(other.ref)) {
return false;
}
if (rel == null) {
if (other.rel != null) {
return false;
}
} else if (!rel.equals(other.rel)) {
return false;
}
return true;
}
@Override
public String toString() {
return "ArtifactUrl [protocol=" + protocol + ", rel=" + rel + ", ref=" + ref + "]";
}
}
}

View File

@@ -15,6 +15,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@@ -23,6 +24,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*
* @see PropertyBasedArtifactUrlHandler
*/
@Data
@ConfigurationProperties("hawkbit.artifact.url")
public class ArtifactUrlHandlerProperties {
@@ -31,13 +33,10 @@ public class ArtifactUrlHandlerProperties {
*/
private final Map<String, UrlProtocol> protocols = new HashMap<>();
public Map<String, UrlProtocol> getProtocols() {
return protocols;
}
/**
* Protocol specific properties to generate URLs accordingly.
*/
@Data
public static class UrlProtocol {
private static final int DEFAULT_HTTP_PORT = 8080;
@@ -85,68 +84,8 @@ public class ArtifactUrlHandlerProperties {
*/
private List<ApiType> supports = Arrays.asList(ApiType.DDI, ApiType.DMF, ApiType.MGMT);
public boolean isEnabled() {
return enabled;
}
public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
public String getRel() {
return rel;
}
public void setRel(final String rel) {
this.rel = rel;
}
public String getRef() {
return ref;
}
public void setRef(final String ref) {
this.ref = ref;
}
public String getHostname() {
return hostname;
}
public void setHostname(final String hostname) {
this.hostname = hostname;
}
public String getIp() {
return ip;
}
public void setIp(final String ip) {
this.ip = ip;
}
public Integer getPort() {
return port;
}
public void setPort(final Integer port) {
this.port = port;
}
public List<ApiType> getSupports() {
return Collections.unmodifiableList(supports);
}
public void setSupports(final List<ApiType> supports) {
this.supports = Collections.unmodifiableList(supports);
}
public String getProtocol() {
return protocol;
}
public void setProtocol(final String protocol) {
this.protocol = protocol;
}
}
}

View File

@@ -9,13 +9,16 @@
*/
package org.eclipse.hawkbit.api;
import lombok.Data;
import java.util.Objects;
/**
* Container for variables available to the {@link ArtifactUrlHandler}.
*
*/
@Data
public class URLPlaceholder {
private final String tenant;
private final Long tenantId;
private final String controllerId;
@@ -49,9 +52,10 @@ public class URLPlaceholder {
/**
* Information about the artifact and software module that can be accessed
* by the URL.
*
*/
@Data
public static class SoftwareData {
private Long softwareModuleId;
private String filename;
private Long artifactId;
@@ -59,7 +63,7 @@ public class URLPlaceholder {
/**
* Constructor.
*
*
* @param softwareModuleId
* of the module the artifact belongs to
* @param filename
@@ -76,91 +80,5 @@ public class URLPlaceholder {
this.artifactId = artifactId;
this.sha1Hash = sha1Hash;
}
public Long getSoftwareModuleId() {
return softwareModuleId;
}
public void setSoftwareModuleId(final Long softwareModuleId) {
this.softwareModuleId = softwareModuleId;
}
public String getFilename() {
return filename;
}
public void setFilename(final String filename) {
this.filename = filename;
}
public Long getArtifactId() {
return artifactId;
}
public void setArtifactId(final Long artifactId) {
this.artifactId = artifactId;
}
public String getSha1Hash() {
return sha1Hash;
}
public void setSha1Hash(final String sha1Hash) {
this.sha1Hash = sha1Hash;
}
@Override
public boolean equals(final Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
final SoftwareData that = (SoftwareData) o;
return Objects.equals(softwareModuleId, that.softwareModuleId)
&& Objects.equals(filename, that.filename)
&& Objects.equals(artifactId, that.artifactId)
&& Objects.equals(sha1Hash, that.sha1Hash);
}
@Override
public int hashCode() {
return Objects.hash(softwareModuleId, filename, artifactId, sha1Hash);
}
}
public String getTenant() {
return tenant;
}
public Long getTenantId() {
return tenantId;
}
public String getControllerId() {
return controllerId;
}
public Long getTargetId() {
return targetId;
}
public SoftwareData getSoftwareData() {
return softwareData;
}
@Override
public boolean equals(final Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
final URLPlaceholder that = (URLPlaceholder) o;
return tenantId.equals(that.tenantId) && Objects.equals(controllerId, that.controllerId) && Objects.equals(
targetId, that.targetId) && Objects.equals(softwareData, that.softwareData);
}
@Override
public int hashCode() {
return Objects.hash(tenantId, controllerId, targetId, softwareData);
}
}

View File

@@ -162,4 +162,4 @@ public abstract class AbstractArtifactRepository implements ArtifactRepository {
protected static String sanitizeTenant(final String tenant) {
return tenant.trim().toUpperCase();
}
}
}

View File

@@ -9,12 +9,13 @@
*/
package org.eclipse.hawkbit.artifact.repository.model;
import lombok.Data;
import org.springframework.util.Assert;
/**
* Database representation of artifact.
*
*/
@Data
public abstract class AbstractDbArtifact implements DbArtifact {
private final String artifactId;
@@ -32,34 +33,4 @@ public abstract class AbstractDbArtifact implements DbArtifact {
this.size = size;
this.contentType = contentType;
}
@Override
public String getArtifactId() {
return artifactId;
}
@Override
public DbArtifactHash getHashes() {
return hashes;
}
/**
* Set hashes of the artifact
*
* @param hashes
* artifact hashes
*/
public void setHashes(final DbArtifactHash hashes) {
this.hashes = hashes;
}
@Override
public long getSize() {
return size;
}
@Override
public String getContentType() {
return contentType;
}
}
}

View File

@@ -9,43 +9,28 @@
*/
package org.eclipse.hawkbit.artifact.repository.model;
import lombok.Data;
/**
* Database representation of artifact hash.
*
*/
@Data
public class DbArtifactHash {
private final String sha1;
private final String md5;
private final String sha256;
/**
* Constructor.
*
* @param sha1
* the sha1 hash
* @param md5
* the md5 hash
* @param sha256
* the sha256 hash
* @param sha1 the sha1 hash
* @param md5 the md5 hash
* @param sha256 the sha256 hash
*/
public DbArtifactHash(final String sha1, final String md5, final String sha256) {
this.sha1 = sha1;
this.md5 = md5;
this.sha256 = sha256;
}
public String getSha1() {
return sha1;
}
public String getMd5() {
return md5;
}
public String getSha256() {
return sha256;
}
}

View File

@@ -26,8 +26,7 @@ public class DefaultDownloadIdCache implements DownloadIdCache {
private final CacheManager cacheManager;
/**
* @param cacheManager
* the underlying cache-manager to store the download-ids
* @param cacheManager the underlying cache-manager to store the download-ids
*/
public DefaultDownloadIdCache(final CacheManager cacheManager) {
this.cacheManager = cacheManager;