Skip to content

Commit

Permalink
Lombok/apply to security repo3 (#1594)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
avgustinmm committed Feb 3, 2024
1 parent 1c5a7bb commit f69d386
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 307 deletions.
Expand Up @@ -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;
Expand All @@ -34,77 +37,4 @@ public ArtifactUrl(final String protocol, final String rel, final String ref) {
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 + "]";
}

}
}
Expand Up @@ -15,6 +15,7 @@
import java.util.List;
import java.util.Map;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
Expand All @@ -23,6 +24,7 @@
*
* @see PropertyBasedArtifactUrlHandler
*/
@Data
@ConfigurationProperties("hawkbit.artifact.url")
public class ArtifactUrlHandlerProperties {

Expand All @@ -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;
Expand Down Expand Up @@ -85,68 +84,8 @@ public static class UrlProtocol {
*/
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;
}
}
}
Expand Up @@ -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;
Expand Down Expand Up @@ -49,17 +52,18 @@ public URLPlaceholder(final String tenant, final Long tenantId, final String con
/**
* 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;
private String sha1Hash;

/**
* Constructor.
*
*
* @param softwareModuleId
* of the module the artifact belongs to
* @param filename
Expand All @@ -76,91 +80,5 @@ public SoftwareData(final Long softwareModuleId, final String filename, final Lo
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);
}
}
Expand Up @@ -162,4 +162,4 @@ private static DigestInputStream wrapInDigestInputStream(final InputStream input
protected static String sanitizeTenant(final String tenant) {
return tenant.trim().toUpperCase();
}
}
}
Expand Up @@ -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;
Expand All @@ -32,34 +33,4 @@ protected AbstractDbArtifact(final String artifactId, final DbArtifactHash hashe
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;
}
}
}

0 comments on commit f69d386

Please sign in to comment.