Skip to content

Commit

Permalink
Improve Security Core with lombok (#1592)
Browse files Browse the repository at this point in the history
Add lombok to repository modules

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
  • Loading branch information
avgustinmm committed Feb 3, 2024
1 parent ea885d6 commit d2a7408
Show file tree
Hide file tree
Showing 27 changed files with 168 additions and 874 deletions.
Expand Up @@ -15,9 +15,7 @@
/**
* Generic assignment result bean.
*
* @param <T>
* type of the assigned and unassigned {@link BaseEntity}s.
*
* @param <T> type of the assigned and unassigned {@link BaseEntity}s.
*/
public abstract class AbstractAssignmentResult<T extends BaseEntity> {

Expand Down Expand Up @@ -90,5 +88,4 @@ public List<T> getUnassignedEntity() {

return Collections.unmodifiableList(unassignedEntity);
}

}
}
Expand Up @@ -10,12 +10,14 @@
package org.eclipse.hawkbit.repository.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import java.io.Serializable;

/**
* Holds properties for {@link Action}
*/
@Data
public class ActionProperties implements Serializable {

private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -43,42 +45,6 @@ public ActionProperties(final Action action) {
this.status = action.getStatus();
}

public void setId(final Long id) {
this.id = id;
}

public Long getId() {
return id;
}

public void setTenant(final String tenant) {
this.tenant = tenant;
}

public String getTenant() {
return tenant;
}

public void setMaintenanceWindowAvailable(final boolean maintenanceWindowAvailable) {
this.maintenanceWindowAvailable = maintenanceWindowAvailable;
}

public boolean isMaintenanceWindowAvailable() {
return maintenanceWindowAvailable;
}

public Action.ActionType getActionType() {
return actionType;
}

public void setActionType(final Action.ActionType actionType) {
this.actionType = actionType;
}

public Action.Status getStatus() {
return status;
}

@JsonIgnore
public boolean isWaitingConfirmation() {
return status == Action.Status.WAIT_FOR_CONFIRMATION;
Expand Down
Expand Up @@ -14,12 +14,14 @@
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;

import lombok.Data;
import org.eclipse.hawkbit.repository.ValidString;

/**
* Use to create a new artifact.
*
*/
@Data
public class ArtifactUpload {

@NotNull
Expand Down Expand Up @@ -97,40 +99,4 @@ public ArtifactUpload(final InputStream inputStream, final long moduleId, final
this.contentType = contentType;
this.filesize = filesize;
}

public InputStream getInputStream() {
return inputStream;
}

public long getModuleId() {
return moduleId;
}

public String getFilename() {
return filename;
}

public String getProvidedMd5Sum() {
return providedMd5Sum;
}

public String getProvidedSha1Sum() {
return providedSha1Sum;
}

public String getProvidedSha256Sum() {
return providedSha256Sum;
}

public boolean overrideExisting() {
return overrideExisting;
}

public String getContentType() {
return contentType;
}

public long getFilesize() {
return filesize;
}
}
Expand Up @@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.repository.model;

import lombok.Data;
import org.eclipse.hawkbit.repository.Identifiable;

import java.io.Serializable;
Expand All @@ -18,6 +19,7 @@
* Use to display software modules for the selected distribution.
*
*/
@Data
public class AssignedSoftwareModule implements Serializable, Identifiable<Long> {

private static final long serialVersionUID = 1L;
Expand All @@ -40,62 +42,8 @@ public AssignedSoftwareModule(final SoftwareModule softwareModule, final boolean
this.assigned = assigned;
}

/**
* @return {@link SoftwareModule}
*/
public SoftwareModule getSoftwareModule() {
return softwareModule;
}

/**
* @return <code>true</code> if assigned
*/
public boolean isAssigned() {
return assigned;
}

@Override
public String toString() {
return "AssignedSoftwareModule [softwareModule=" + softwareModule + ", assigned=" + assigned + "]";
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (assigned ? 1231 : 1237);
result = prime * result + ((softwareModule == null) ? 0 : softwareModule.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 AssignedSoftwareModule other = (AssignedSoftwareModule) obj;
if (assigned != other.assigned) {
return false;
}
if (softwareModule == null) {
if (other.softwareModule != null) {
return false;
}
} else if (!softwareModule.equals(other.softwareModule)) {
return false;
}
return true;
}

@Override
public Long getId() {
return softwareModule.getId();
}

}
Expand Up @@ -13,14 +13,16 @@

import jakarta.validation.Valid;

import lombok.Data;
import org.eclipse.hawkbit.repository.exception.InvalidMaintenanceScheduleException;
import org.eclipse.hawkbit.repository.model.Action.ActionType;

/**
* A custom view on assigning a {@link DistributionSet} to a {@link Target}.
*
*/
@Data
public class DeploymentRequest {

private final Long distributionSetId;
@Valid
private final TargetWithActionType targetWithActionType;
Expand Down Expand Up @@ -76,46 +78,7 @@ public DeploymentRequest(final String controllerId, final Long distributionSetId
this.distributionSetId = distributionSetId;
}

public Long getDistributionSetId() {
return distributionSetId;
}

public String getControllerId() {
return targetWithActionType.getControllerId();
}

public TargetWithActionType getTargetWithActionType() {
return targetWithActionType;
}

@Override
public String toString() {
return String.format(
"DeploymentRequest [controllerId=%s, distributionSetId=%d, actionType=%s, forceTime=%d, weight=%d, maintenanceSchedule=%s, maintenanceWindowDuration=%s, maintenanceWindowTimeZone=%s, confirmationRequired=%s]",
targetWithActionType.getControllerId(), getDistributionSetId(), targetWithActionType.getActionType(),
targetWithActionType.getForceTime(), targetWithActionType.getWeight(),
targetWithActionType.getMaintenanceSchedule(), targetWithActionType.getMaintenanceWindowDuration(),
targetWithActionType.getMaintenanceWindowTimeZone(), targetWithActionType.isConfirmationRequired());
}

@Override
public int hashCode() {
return Objects.hash(distributionSetId, targetWithActionType);
}

@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final DeploymentRequest other = (DeploymentRequest) obj;
return Objects.equals(distributionSetId, other.distributionSetId)
&& Objects.equals(targetWithActionType, other.targetWithActionType);
}
}
Expand Up @@ -123,5 +123,4 @@ public DeploymentRequest build() {
return new DeploymentRequest(controllerId, distributionSetId, actionType, forceTime, weight,
maintenanceSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone, confirmationRequired);
}

}
}
Expand Up @@ -9,6 +9,8 @@
*/
package org.eclipse.hawkbit.repository.model;

import lombok.Data;

import java.util.Collections;
import java.util.List;

Expand All @@ -18,6 +20,7 @@
* how much of the assignments had already been existed.
*
*/
@Data
public class DistributionSetAssignmentResult extends AbstractAssignmentResult<Action> {

private final DistributionSet distributionSet;
Expand All @@ -37,12 +40,4 @@ public DistributionSetAssignmentResult(final DistributionSet distributionSet, fi
super(alreadyAssigned, assigned, Collections.emptyList());
this.distributionSet = distributionSet;
}

/**
* @return The distribution set that has been assigned
*/
public DistributionSet getDistributionSet() {
return distributionSet;
}

}
}

0 comments on commit d2a7408

Please sign in to comment.