diff options
14 files changed, 80 insertions, 240 deletions
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java index 240b1f40..300d49c7 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java @@ -1,45 +1,43 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.policy.common.parameters; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + /** * This static class holds the values of constants for parameter handling. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public final class ParameterConstants { // Indentation is 0 on the left and 2 for each level of hierarchy public static final String DEFAULT_INITIAL_RESULT_INDENTATION = ""; public static final String DEFAULT_RESULT_INDENTATION = " "; - + // By default we do not show validation results for parameters that are validated as clean public static final boolean DO_NOT_SHOW_CLEAN_RESULTS = false; - + // Messages for clean validations public static final String PARAMETER_GROUP_HAS_STATUS_MESSAGE = "parameter group has status "; public static final String PARAMETER_GROUP_MAP_HAS_STATUS_MESSAGE = "parameter group map has status "; public static final String PARAMETER_HAS_STATUS_MESSAGE = "parameter has status "; - - /** - * Private constructor to prevent subclassing. - */ - private ParameterConstants() { - // Private constructor to prevent subclassing - } -}
\ No newline at end of file +} diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java index 84faa9c8..aa3105ef 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java @@ -21,6 +21,8 @@ package org.onap.policy.common.parameters; +import lombok.Getter; + /** * Exception thrown oon parameter reading, validation, and check errors. * @@ -30,6 +32,7 @@ public class ParameterException extends Exception { private static final long serialVersionUID = -8507246953751956974L; // The object on which the exception was thrown + @Getter private final transient Object object; /** @@ -100,13 +103,4 @@ public class ParameterException extends Exception { return builder.toString(); } - - /** - * Get the object on which the exception was thrown. - * - * @return The object on which the exception was thrown - */ - public Object getObject() { - return object; - } } diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterRuntimeException.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterRuntimeException.java index 071593a9..4eb79447 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterRuntimeException.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterRuntimeException.java @@ -1,25 +1,28 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.policy.common.parameters; +import lombok.Getter; + /** * A run time exception thrown on parameter validations. * @@ -29,6 +32,7 @@ public class ParameterRuntimeException extends RuntimeException { private static final long serialVersionUID = -8507246953751956974L; // The object on which the exception was thrown + @Getter private final transient Object object; /** @@ -81,13 +85,4 @@ public class ParameterRuntimeException extends RuntimeException { public String getCascadedMessage() { return ParameterException.buildCascadedMessage(this); } - - /** - * Get the object on which the exception was thrown. - * - * @return The object - */ - public Object getObject() { - return object; - } } diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java index 7bf0ac5f..a368d25f 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java @@ -25,6 +25,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; /** * The parameter service makes ONAP PF parameter groups available to all classes in a JVM. @@ -37,25 +39,18 @@ import java.util.concurrent.ConcurrentHashMap; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public abstract class ParameterService { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class ParameterService { // The map holding the parameters private static Map<String, ParameterGroup> parameterGroupMap = new ConcurrentHashMap<>(); /** - * This class is an abstract static class that cannot be extended. - */ - private ParameterService() { - } - - /** * Register a parameter group with the parameter service. * * @param parameterGroup the parameter group */ public static void register(final ParameterGroup parameterGroup) { - if (!parameterGroupMap.containsKey(parameterGroup.getName())) { - parameterGroupMap.put(parameterGroup.getName(), parameterGroup); - } else { + if (parameterGroupMap.putIfAbsent(parameterGroup.getName(), parameterGroup) != null) { throw new ParameterRuntimeException( "\"" + parameterGroup.getName() + "\" already registered in parameter service"); } @@ -81,9 +76,7 @@ public abstract class ParameterService { * @param parameterGroupName the name of the parameter group */ public static void deregister(final String parameterGroupName) { - if (parameterGroupMap.containsKey(parameterGroupName)) { - parameterGroupMap.remove(parameterGroupName); - } else { + if (parameterGroupMap.remove(parameterGroupName) == null) { throw new ParameterRuntimeException("\"" + parameterGroupName + "\" not registered in parameter service"); } } @@ -121,7 +114,7 @@ public abstract class ParameterService { * @return true if the parameter is defined */ public static boolean contains(final String parameterGroupName) { - return parameterGroupMap.containsKey(parameterGroupName) && parameterGroupMap.get(parameterGroupName) != null; + return parameterGroupMap.get(parameterGroupName) != null; } /** diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResultImpl.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResultImpl.java index 0fda51ad..45898818 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResultImpl.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResultImpl.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,12 +21,14 @@ package org.onap.policy.common.parameters; +import lombok.AllArgsConstructor; import lombok.Getter; /** * Basic implementation of a ValidationResult. */ @Getter +@AllArgsConstructor public abstract class ValidationResultImpl implements ValidationResult { public static final String ITEM_HAS_STATUS_MESSAGE = "item has status "; @@ -63,21 +65,6 @@ public abstract class ValidationResultImpl implements ValidationResult { } /** - * Constructs the object. - * - * @param name name of the object of this result - * @param object object being validated - * @param status the validation status - * @param message the validation message explaining the validation status - */ - protected ValidationResultImpl(String name, Object object, ValidationStatus status, String message) { - this.name = name; - this.object = object; - this.status = status; - this.message = message; - } - - /** * Validates that the value is not {@code null}. * * @return {@code true} if the value is not null, {@code false} otherwise diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValueValidator.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValueValidator.java index a8a0e614..faf41008 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValueValidator.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValueValidator.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.List; import lombok.AccessLevel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import org.onap.policy.common.parameters.annotations.NotNull; @@ -34,6 +35,7 @@ import org.onap.policy.common.parameters.annotations.NotNull; * Note: this currently does not support Min/Max validation of "short" or "byte"; these * annotations are simply ignored for these types. */ +@NoArgsConstructor public class ValueValidator { /** @@ -55,14 +57,6 @@ public class ValueValidator { */ protected List<Checker> checkers = new ArrayList<>(10); - - /** - * Constructs the object. - */ - public ValueValidator() { - // do nothing - } - /** * Determines if the validator has anything to check. * diff --git a/gson/src/main/java/org/onap/policy/common/gson/DoubleConverter.java b/gson/src/main/java/org/onap/policy/common/gson/DoubleConverter.java index cbf5d0e7..4d10bd13 100644 --- a/gson/src/main/java/org/onap/policy/common/gson/DoubleConverter.java +++ b/gson/src/main/java/org/onap/policy/common/gson/DoubleConverter.java @@ -25,18 +25,17 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; /** * Converter for Double values. By default, GSON treats all Objects that are numbers, as * Double. This converts Doubles to Integer or Long, if possible. It converts stand-alone * Doubles, as well as those found within Arrays and Maps. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class DoubleConverter { - private DoubleConverter() { - // do nothing - } - /** * Performs in-place conversion of all values in a list. * diff --git a/gson/src/main/java/org/onap/policy/common/gson/internal/Adapter.java b/gson/src/main/java/org/onap/policy/common/gson/internal/Adapter.java index c15ccb7d..af4a746c 100644 --- a/gson/src/main/java/org/onap/policy/common/gson/internal/Adapter.java +++ b/gson/src/main/java/org/onap/policy/common/gson/internal/Adapter.java @@ -29,6 +29,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.util.function.Supplier; +import lombok.Getter; import org.onap.policy.common.gson.annotation.GsonJsonProperty; /** @@ -49,6 +50,7 @@ public class Adapter { /** * Name of the property within the json structure containing the item. */ + @Getter private final String propName; /** @@ -69,6 +71,7 @@ public class Adapter { /** * Name of the item being lifted - used when throwing exceptions. */ + @Getter private final String fullName; /** @@ -143,14 +146,6 @@ public class Adapter { return reader.getConverter().fromJsonTree(tree); } - public final String getPropName() { - return propName; - } - - public final String getFullName() { - return fullName; - } - /** * Makes an error message, appending the item's full name to the message prefix. * diff --git a/gson/src/main/java/org/onap/policy/common/gson/internal/ClassWalker.java b/gson/src/main/java/org/onap/policy/common/gson/internal/ClassWalker.java index ef4eaae3..954d3f4c 100644 --- a/gson/src/main/java/org/onap/policy/common/gson/internal/ClassWalker.java +++ b/gson/src/main/java/org/onap/policy/common/gson/internal/ClassWalker.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import lombok.Getter; import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter; import org.onap.policy.common.gson.annotation.GsonJsonAnySetter; import org.onap.policy.common.gson.annotation.GsonJsonIgnore; @@ -79,23 +80,16 @@ public class ClassWalker { * Method having {@link GsonJsonAnyGetter} annotation. Overwritten as new "any-getters" * are identified. */ + @Getter private Method anyGetter = null; /** * Method having {@link GsonJsonAnySetter} annotation. Overwritten as new "any-setters" * are identified. */ + @Getter private Method anySetter = null; - - public Method getAnyGetter() { - return anyGetter; - } - - public Method getAnySetter() { - return anySetter; - } - /** * Gets the names of input properties that are not being ignored. * diff --git a/integrity-audit/pom.xml b/integrity-audit/pom.xml index cf46fc7a..4e857919 100644 --- a/integrity-audit/pom.xml +++ b/integrity-audit/pom.xml @@ -39,6 +39,10 @@ <dependencies> <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditorTime.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditorTime.java index 95eecbc3..5bfedaac 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditorTime.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditorTime.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * Integrity Audit * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,11 +21,14 @@ package org.onap.policy.common.ia; import java.util.function.Supplier; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.onap.policy.common.utils.time.CurrentTime; /** * "Current" time used by IntegrityMonitor classes. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class AuditorTime { /** @@ -41,15 +44,8 @@ public class AuditorTime { private static Supplier<CurrentTime> supplier = () -> currentTime; /** - * Constructor. - */ - private AuditorTime() { - super(); - } - - /** * Get instance. - * + * * @return the CurrentTime singleton */ public static CurrentTime getInstance() { diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java index 10900e3c..66ab307c 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java @@ -21,6 +21,8 @@ package org.onap.policy.common.ia; import java.util.Properties; +import lombok.Getter; +import lombok.Setter; import org.apache.commons.lang3.StringUtils; import org.onap.policy.common.ia.IntegrityAuditProperties.NodeTypeEnum; import org.onap.policy.common.logging.flexlogger.FlexLogger; @@ -34,8 +36,12 @@ public class IntegrityAudit { private static final Logger logger = FlexLogger.getLogger(IntegrityAudit.class); - private static boolean isUnitTesting; - private boolean isThreadInitialized = false; + @Getter + @Setter + private static boolean unitTesting; + + @Getter + private boolean threadInitialized = false; AuditThread auditThread = null; @@ -54,6 +60,7 @@ public class IntegrityAudit { * indicated period * */ + @Getter private int integrityAuditPeriodSeconds; /** @@ -94,13 +101,6 @@ public class IntegrityAudit { } /** - * Used during JUnit testing by AuditPeriodTest.java - */ - public int getIntegrityAuditPeriodSeconds() { - return integrityAuditPeriodSeconds; - } - - /** * Determine if the nodeType conforms to the required node types. */ public static boolean isNodeTypeEnum(String nt) { @@ -237,21 +237,9 @@ public class IntegrityAudit { logger.info("stopAuditThread: Exiting"); } - public boolean isThreadInitialized() { - return isThreadInitialized; - } - public void setThreadInitialized(boolean isThreadInitialized) { logger.info("setThreadInitialized: Setting isThreadInitialized=" + isThreadInitialized); - this.isThreadInitialized = isThreadInitialized; - } - - public static boolean isUnitTesting() { - return isUnitTesting; - } - - public static void setUnitTesting(boolean isUnitTesting) { - IntegrityAudit.isUnitTesting = isUnitTesting; + this.threadInitialized = isThreadInitialized; } /** diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java index 365afd25..9122b721 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Integrity Audit * ================================================================================ - * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,10 @@ package org.onap.policy.common.ia; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class IntegrityAuditProperties { public static final int DEFAULT_AUDIT_PERIOD_SECONDS = -1; // Audit does not run @@ -38,9 +42,4 @@ public class IntegrityAuditProperties { PDP_XACML, PDP_DROOLS, PAP, PAP_ADMIN, LOGPARSER, BRMS_GATEWAY, ASTRA_GATEWAY, ELK_SERVER, PYPDP } - - private IntegrityAuditProperties() { - - } - } diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java index 1c8277c0..37688859 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java @@ -35,6 +35,10 @@ import javax.persistence.PreUpdate; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; /* * The Entity class to for management of IntegrityAudits */ @@ -44,15 +48,20 @@ import org.onap.policy.common.ia.AuditorTime; @Table(name = "IntegrityAuditEntity") @NamedQuery(name = " IntegrityAuditEntity.findAll", query = "SELECT e FROM IntegrityAuditEntity e ") @NamedQuery(name = "IntegrityAuditEntity.deleteAll", query = "DELETE FROM IntegrityAuditEntity WHERE 1=1") - +@NoArgsConstructor +@Getter +@Setter public class IntegrityAuditEntity implements Serializable { private static final long serialVersionUID = 1L; - private static boolean isUnitTesting; + @Getter + @Setter + private static boolean unitTesting; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id") + @Setter(AccessLevel.PRIVATE) private long id; @Column(name = "persistenceUnit", nullable = false) @@ -90,11 +99,6 @@ public class IntegrityAuditEntity implements Serializable { @Column(name = "lastUpdated") private Date lastUpdated; - - public IntegrityAuditEntity() { - // Empty constructor - } - /** * Pre persist. */ @@ -110,106 +114,6 @@ public class IntegrityAuditEntity implements Serializable { this.lastUpdated = AuditorTime.getInstance().getDate(); } - public long getId() { - return id; - } - - public String getPersistenceUnit() { - return persistenceUnit; - } - - public void setPersistenceUnit(String persistenceUnit) { - this.persistenceUnit = persistenceUnit; - } - - public String getSite() { - return site; - } - - public void setSite(String site) { - this.site = site; - } - - public String getNodeType() { - return nodeType; - } - - public void setNodeType(String nodeType) { - this.nodeType = nodeType; - } - - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - public boolean isDesignated() { - return designated; - } - - public void setDesignated(boolean designated) { - this.designated = designated; - } - - public String getJdbcDriver() { - return jdbcDriver; - } - - public void setJdbcDriver(String jdbcDriver) { - this.jdbcDriver = jdbcDriver; - } - - public String getJdbcUrl() { - return jdbcUrl; - } - - public void setJdbcUrl(String jdbcUrl) { - this.jdbcUrl = jdbcUrl; - } - - public String getJdbcUser() { - return jdbcUser; - } - - public void setJdbcUser(String jdbcUser) { - this.jdbcUser = jdbcUser; - } - - public String getJdbcPassword() { - return jdbcPassword; - } - - public void setJdbcPassword(String jdbcPassword) { - this.jdbcPassword = jdbcPassword; - } - - public Date getLastUpdated() { - return lastUpdated; - } - - public void setLastUpdated(Date lastUpdated) { - this.lastUpdated = lastUpdated; - } - - public Date getCreatedDate() { - return createdDate; - } - - public void setCreatedDate(Date created) { - this.createdDate = created; - } - - public static boolean isUnitTesting() { - return isUnitTesting; - } - - public static void setUnitTesting(boolean isUnitTesting) { - IntegrityAuditEntity.isUnitTesting = isUnitTesting; - } - private void writeObject(ObjectOutputStream out) throws IOException { if (isUnitTesting()) { /* |