diff options
Diffstat (limited to 'common-app-api/src/main/java/org')
10 files changed, 205 insertions, 309 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactGroupTypeEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactGroupTypeEnum.java index c990d43f64..b9b440dc49 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactGroupTypeEnum.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactGroupTypeEnum.java @@ -22,27 +22,19 @@ package org.openecomp.sdc.common.api; import java.util.ArrayList; import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Getter; +@AllArgsConstructor public enum ArtifactGroupTypeEnum { INFORMATIONAL("INFORMATIONAL"), DEPLOYMENT("DEPLOYMENT"), LIFE_CYCLE("LIFE_CYCLE"), SERVICE_API("SERVICE_API"), TOSCA("TOSCA"), OTHER("OTHER"); - private String type; - - ArtifactGroupTypeEnum(String type) { - this.type = type; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } + @Getter + private final String type; public static ArtifactGroupTypeEnum findType(final String type) { - for (ArtifactGroupTypeEnum ate : ArtifactGroupTypeEnum.values()) { + for (ArtifactGroupTypeEnum ate : values()) { if (ate.getType().equals(type)) { return ate; } @@ -52,7 +44,7 @@ public enum ArtifactGroupTypeEnum { public static List<String> getAllTypes() { List<String> types = new ArrayList<>(); - for (ArtifactGroupTypeEnum ate : ArtifactGroupTypeEnum.values()) { + for (ArtifactGroupTypeEnum ate : values()) { types.add(ate.getType()); } return types; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java index 1310ab170f..ae25ebe177 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java @@ -22,30 +22,19 @@ package org.openecomp.sdc.common.api; import java.util.ArrayList; import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Getter; +@AllArgsConstructor public enum YamlSuffixEnum { YAML("YAML"), - yaml("yaml"), - YML("YML"), - yml("yml"); - YamlSuffixEnum(String suffix) { - this.suffix = suffix; - } - - private String suffix; - - public String getSuffix() { - return suffix; - } - - public void setSuufix(String suffix) { - this.suffix = suffix; - } + @Getter + private final String suffix; public static List<String> getSuffixes() { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompClassification.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompClassification.java index 31499486de..5ea06cb3f7 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompClassification.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompClassification.java @@ -20,22 +20,15 @@ package org.openecomp.sdc.common.config; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor public enum EcompClassification { INFORMATION("I"), WARNING("W"), ERROR("E"), FATAL("F"); - String classification; - - EcompClassification(String classification) { - this.classification = classification; - } - - public String getClassification() { - return classification; - } - - public void setClassification(String classification) { - this.classification = classification; - } + @Getter + private final String classification; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorCode.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorCode.java index e605366fcb..845288a5db 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorCode.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorCode.java @@ -20,87 +20,94 @@ package org.openecomp.sdc.common.config; +import lombok.Getter; + +@Getter public enum EcompErrorCode { E_100("Authentication problem towards U-EB server. Reason: %s", - "An Authentication failure occured during access to UEB server. Please check that UEB keys are configured correctly in ASDC BE distribution configuration."), E_199( - "Internal authentication problem. Description: %s"), - - E_200("ASDC Backend probably lost connectivity to either one of the following components: JanusGraph DB, Cassandra, Onboarding, UEB Cluster. Please check the logs for more information."), E_201( - "ASDC Backend probably lost connectivity to JanusGraph DB. Please check the logs for more information."), E_202( - "ASDC Backend probably lost connectivity to ElasticSearch. Please check the logs for more information."), E_203( - "ASDC Backend probably lost connectivity to UEB Cluster. Please check the logs for more information.", - "Check connectivity to UEB cluster which is configured under parameter uebServers in distribution-configuration.yaml."), E_204( - "Unable to connect to a valid ASDC Backend Server", - "Please check connectivity from this FE instance towards BE or BE Load Balancer. Please check that parameters in FE configuration.yaml: beHost, beHttpPort and beSslPort point to a valid host and port values."), - - E_205("ASDC Backend Recovery to either one of the following components: JanusGraph DB, Cassandra, Onboarding, UEB Cluster."), E_206( - "ASDC Backend connection recovery to JanusGraph DB."), E_208( - "ASDC Backend connection recovery to UEB Cluster."), E_209( - "Connectivity to ASDC BE Server is recovered."), E_210( - "Connection problem towards U-EB server. Reason: %s", - "Please check that that parameter uebServers in distribution-configuration.yaml points to a valid UEB Cluster."), E_211( - "Connection problem towards U-EB server. Cannot reach host %s", - "Please check that that parameter uebServers in distribution-configuration.yaml points to a valid UEB Cluster."), E_212( - "Couldn't resolve hostIP. Desciption: %s"), E_213( - "Site switch over was done. Site is now in %s mode"), E_214( - "Dmaap Connection problem."), E_220( - "User HTTP session is expired"), E_299( - "Internal Connection problem. Description: %s"), + "An Authentication failure occured during access to UEB server. Please check that UEB keys are configured correctly in ASDC BE distribution configuration."), + E_199("Internal authentication problem. Description: %s"), + + E_200("ASDC Backend probably lost connectivity to either one of the following components: JanusGraph DB, Cassandra, Onboarding, UEB Cluster. Please check the logs for more information."), + E_201("ASDC Backend probably lost connectivity to JanusGraph DB. Please check the logs for more information."), + E_202("ASDC Backend probably lost connectivity to ElasticSearch. Please check the logs for more information."), + E_203("ASDC Backend probably lost connectivity to UEB Cluster. Please check the logs for more information.", + "Check connectivity to UEB cluster which is configured under parameter uebServers in distribution-configuration.yaml."), + E_204("Unable to connect to a valid ASDC Backend Server", + "Please check connectivity from this FE instance towards BE or BE Load Balancer. Please check that parameters in FE configuration.yaml: beHost, beHttpPort and beSslPort point to a valid host and port values."), + + E_205("ASDC Backend Recovery to either one of the following components: JanusGraph DB, Cassandra, Onboarding, UEB Cluster."), + E_206("ASDC Backend connection recovery to JanusGraph DB."), + E_208("ASDC Backend connection recovery to UEB Cluster."), + E_209("Connectivity to ASDC BE Server is recovered."), + E_210("Connection problem towards U-EB server. Reason: %s", + "Please check that that parameter uebServers in distribution-configuration.yaml points to a valid UEB Cluster."), + E_211("Connection problem towards U-EB server. Cannot reach host %s", + "Please check that that parameter uebServers in distribution-configuration.yaml points to a valid UEB Cluster."), + E_212("Couldn't resolve hostIP. Desciption: %s"), + E_213("Site switch over was done. Site is now in %s mode"), + E_214("Dmaap Connection problem."), + E_220("User HTTP session is expired"), + E_299("Internal Connection problem. Description: %s"), // [resource/service/product] E_300("Mandatory %s Component %s cannot be found in repository"), // [SERVICE/RESOURCE/PRODUCT] [id] is not valid. Cannot be found in graph. - E_301("%s Component %s is not valid. Cannot be found in graph."), E_302( - "Configuration parameter %s is invalid. Value configured is %s."), E_303( - "Error occured during access to U-EB Server. Data not found: %s", - "An error occured during access to UEB Server, ASDC failed to either register or unregister to/from UEB topic."), E_304( - "The artifact type %s does not appear in the list of valid artifacts %s"), E_305( - "Configuration parameter %s is missing"), E_306( - "Configuration parameter %s is invalid. At least %s values shall be configured"), E_307( - "Invalid configuration in YAML file. %s"), E_308( - "Artifact uploaded has missing information. Missing %s"), E_309( - "Artifact %s requested is not found"), E_310( - "User %s requested is not found"), E_311( - "Ecomp error description params mismatch between code and YAML or wrong format, name: %s"), E_312( - "Ecomp error element not found in YAML, name: %s"), + E_301("%s Component %s is not valid. Cannot be found in graph."), + E_302("Configuration parameter %s is invalid. Value configured is %s."), + E_303("Error occured during access to U-EB Server. Data not found: %s", + "An error occured during access to UEB Server, ASDC failed to either register or unregister to/from UEB topic."), + E_304("The artifact type %s does not appear in the list of valid artifacts %s"), + E_305("Configuration parameter %s is missing"), + E_306("Configuration parameter %s is invalid. At least %s values shall be configured"), + E_307("Invalid configuration in YAML file. %s"), + E_308("Artifact uploaded has missing information. Missing %s"), + E_309("Artifact %s requested is not found"), + E_310("User %s requested is not found"), + E_311("Ecomp error description params mismatch between code and YAML or wrong format, name: %s"), + E_312("Ecomp error element not found in YAML, name: %s"), E_399("Internal Invalid Object. Description: %s"), - E_400("The type %s of %s is invalid"), E_401("The value %s of %s from type %s is invalid"), E_402( - "Payload of artifact uploaded is invalid (invalid MD5 or encryption)"), E_403( - "Input for artifact metadata is invalid"), E_404("%s %s required is missing"), E_405( - "Failed to convert json input to object"), E_406("Distribution %s required is missing"), + E_400("The type %s of %s is invalid"), + E_401("The value %s of %s from type %s is invalid"), + E_402("Payload of artifact uploaded is invalid (invalid MD5 or encryption)"), + E_403("Input for artifact metadata is invalid"), + E_404("%s %s required is missing"), + E_405("Failed to convert json input to object"), + E_406("Distribution %s required is missing"), E_499("Invalid input. Description: %s"), - E_500("Catalog-BE was not initialized properly"), E_501( - "Failed to add resource instance of resource %s to service %s"), E_502( - "Error occured during access to U-EB Server. Operation: %s", - "An error occured in ASDC distribution mechanism. Please check the logs for more information."), E_503( - "Error occured in Distribution Engine. Failed operation: %s", - "System Error occured in ASDC Distribution Engine. Please check ASDC logs for more details."), E_504( - "Failed adding node of type %s to graph."), E_505( - "Operation towards database failed.", - "Please check JanusGraph DB health or look at the logs for more details."), E_506( - "Unexpected error during operation"), E_507( - "Going to execute rollback on graph."), E_508( - "Failed to lock object for update. Type = %s, Id = %s"), E_509( - "Failed to create node %s on graph. status is %s"), E_510( - "Failed to update node %s on graph. Status is %s"), E_511( - "Failed to delete node %s on graph. Status is %s"), E_512( - "Failed to retrieve node %s from graph. Status is %s"), E_513( - "Failed to find parent node of %s on graph. Status is %s"), E_514( - "Failed to fetch all nodes with type %s of parent node %s . Status is %s"), E_515( - "Cannot find node with type %s associated with node %s . Status is %s"), E_516( - "Error occured in Component Cleaner Task. Failed operation: %s"), E_517( - "Error when logging FE HTTP request/response"), E_518( - "Error when trying to access FE Portal page"), + E_500("Catalog-BE was not initialized properly"), + E_501("Failed to add resource instance of resource %s to service %s"), + E_502("Error occured during access to U-EB Server. Operation: %s", + "An error occured in ASDC distribution mechanism. Please check the logs for more information."), + E_503("Error occured in Distribution Engine. Failed operation: %s", + "System Error occured in ASDC Distribution Engine. Please check ASDC logs for more details."), + E_504("Failed adding node of type %s to graph."), + E_505("Operation towards database failed.", + "Please check JanusGraph DB health or look at the logs for more details."), + E_506("Unexpected error during operation"), + E_507("Going to execute rollback on graph."), + E_508("Failed to lock object for update. Type = %s, Id = %s"), + E_509("Failed to create node %s on graph. status is %s"), + E_510("Failed to update node %s on graph. Status is %s"), + E_511("Failed to delete node %s on graph. Status is %s"), + E_512("Failed to retrieve node %s from graph. Status is %s"), + E_513("Failed to find parent node of %s on graph. Status is %s"), + E_514("Failed to fetch all nodes with type %s of parent node %s . Status is %s"), + E_515("Cannot find node with type %s associated with node %s . Status is %s"), + E_516("Error occured in Component Cleaner Task. Failed operation: %s"), + E_517("Error when logging FE HTTP request/response"), + E_518("Error when trying to access FE Portal page"), E_599("Internal flow error. Operation: %s"), - E_900("Unexpected error during BE REST API execution"), E_901("General error during FE Health Check"), E_999( - "Unexpected error. Description: %s"); + E_900("Unexpected error during BE REST API execution"), + E_901("General error during FE Health Check"), + E_999("Unexpected error. Description: %s"); /* * 100-199 Security/Permission Related - Authentication problems (from @@ -125,8 +132,8 @@ public enum EcompErrorCode { * 900-999 Unknown Errors - unexpected exception */ - private String description; - private String resolution; + private final String description; + private final String resolution; EcompErrorCode(String description, String resolution) { this.description = description; @@ -135,22 +142,7 @@ public enum EcompErrorCode { EcompErrorCode(String description) { this.description = description; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getResolution() { - return resolution; - } - - public void setResolution(String resolution) { - this.resolution = resolution; + this.resolution = ""; } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorEnum.java index bed7255057..61e992bbd7 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorEnum.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorEnum.java @@ -20,6 +20,9 @@ package org.openecomp.sdc.common.config; +import lombok.Getter; + +@Getter public enum EcompErrorEnum { @@ -410,13 +413,11 @@ public enum EcompErrorEnum { * AlarmSeverity.CRITICAL, EcompClassification.FATAL), */; - ; - - EcompErrorCode ecompErrorCode; - ErrorType eType; - AlarmSeverity alarmSeverity; - EcompClassification classification; - EcompErrorEnum clearCode; + private final EcompErrorCode ecompErrorCode; + private final ErrorType eType; + private final AlarmSeverity alarmSeverity; + private final EcompClassification classification; + private final EcompErrorEnum clearCode; EcompErrorEnum(EcompErrorCode ecompErrorCode, ErrorType eType, AlarmSeverity alarmSeverity, EcompClassification classification, EcompErrorEnum clearCode) { @@ -435,46 +436,7 @@ public enum EcompErrorEnum { this.eType = eType; this.alarmSeverity = alarmSeverity; this.classification = classification; - } - - public ErrorType geteType() { - return eType; - } - - public void seteType(ErrorType eType) { - this.eType = eType; - } - - public AlarmSeverity getAlarmSeverity() { - return alarmSeverity; - } - - public void setAlarmSeverity(AlarmSeverity alarmSeverity) { - this.alarmSeverity = alarmSeverity; - } - - public EcompErrorCode getEcompErrorCode() { - return ecompErrorCode; - } - - public void setEcompErrorCode(EcompErrorCode ecompErrorCode) { - this.ecompErrorCode = ecompErrorCode; - } - - public EcompClassification getClassification() { - return classification; - } - - public void setClassification(EcompClassification classification) { - this.classification = classification; - } - - public EcompErrorEnum getClearCode() { - return clearCode; - } - - public void setClearCode(EcompErrorEnum clearCode) { - this.clearCode = clearCode; + this.clearCode = null; } public enum ErrorType { @@ -485,7 +447,4 @@ public enum EcompErrorEnum { CRITICAL, MAJOR, MINOR, INFORMATIONAL, NONE } - // public String toString() { - // return eType + "," + eCode + "," + desc; - // } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java index feb3ea6e68..7145a11005 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java @@ -111,9 +111,9 @@ public class EcompErrorLogUtil { String eCode = createEcode(ecompErrorEnum); - MDC.put("alarmSeverity", ecompErrorEnum.alarmSeverity.name()); + MDC.put("alarmSeverity", ecompErrorEnum.getAlarmSeverity().name()); // else it stays ERROR - formatter.format(ECOMP_ERROR_TMPL, ecompErrorEnum.geteType(), ecompErrorEnum.name(), eCode, + formatter.format(ECOMP_ERROR_TMPL, ecompErrorEnum.getEType(), ecompErrorEnum.name(), eCode, ecompErrorContext, description); log.error(severity, EcompLoggerErrorCode.getByValue(ecompErrorEnum.getEcompErrorCode().name()), diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java index a4852d10f1..b9c0d77be8 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java @@ -167,7 +167,7 @@ public class GenerateEcompErrorsCsv { ecompErrorRow.setDescription(ecompErrorEnum.getEcompErrorCode().getDescription()); ecompErrorRow.setErrorCode(errorCode); ecompErrorRow.setErrorName(ecompErrorEnum.name()); - ecompErrorRow.setErrorType(ecompErrorEnum.geteType()); + ecompErrorRow.setErrorType(ecompErrorEnum.getEType()); ecompErrorRow.setResolution(ecompErrorEnum.getEcompErrorCode().getResolution()); errors.add(ecompErrorRow); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKey.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKey.java index 06b2452d82..060e3ea79a 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKey.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKey.java @@ -21,7 +21,11 @@ package org.openecomp.sdc.common.datastructure; import java.util.Date; +import lombok.AllArgsConstructor; +import lombok.Getter; +@AllArgsConstructor +@Getter public enum AuditingFieldsKey { // General AUDIT_TIMESTAMP(Date.class, "TIMESTAMP"), @@ -92,23 +96,7 @@ public enum AuditingFieldsKey { AUDIT_AUTH_REALM(String.class, "REALM"), AUDIT_ECOMP_USER(String.class, "ECOMP_USER"); - private Class<?> clazz; - private String displayName; + private final Class<?> clazz; + private final String displayName; - AuditingFieldsKey(Class<?> clazz, String displayName) { - this.clazz = clazz; - this.displayName = displayName; - } - - public Class<?> getValueClass() { - return this.clazz; - } - - public String getDisplayName() { - return displayName; - } - - public void setDisplayName(String displayName) { - this.displayName = displayName; - } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/MonitoringFieldsKeysEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/MonitoringFieldsKeysEnum.java index f92b4ef687..d44470758a 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/MonitoringFieldsKeysEnum.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/MonitoringFieldsKeysEnum.java @@ -21,7 +21,11 @@ package org.openecomp.sdc.common.datastructure; import java.util.Date; +import lombok.AllArgsConstructor; +import lombok.Getter; +@AllArgsConstructor +@Getter public enum MonitoringFieldsKeysEnum { MONITORING_TIMESTAMP(Date.class, "TIMESTAMP"), MONITORING_HOST_IP(String.class, "HOST_IP"), @@ -35,23 +39,7 @@ public enum MonitoringFieldsKeysEnum { MONITORING_APP_ID(String.class, "APP_ID"), MONITORING_APP_STAT(String.class, "APP_STAT"); - private Class<?> clazz; - private String displayName; + private final Class<?> clazz; + private final String displayName; - MonitoringFieldsKeysEnum(Class<?> clazz, String displayName) { - this.clazz = clazz; - this.displayName = displayName; - } - - public Class<?> getValueClass() { - return this.clazz; - } - - public String getDisplayName() { - return displayName; - } - - public void setDisplayName(String displayName) { - this.displayName = displayName; - } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java index 6183d42417..57cf96e068 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java @@ -22,116 +22,116 @@ package org.openecomp.sdc.common.util; import com.google.common.base.CharMatcher; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.text.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; -import org.apache.commons.lang3.text.WordUtils; +import org.apache.commons.text.WordUtils; import org.apache.commons.validator.routines.UrlValidator; import org.jsoup.Jsoup; -import org.jsoup.helper.StringUtil; import org.jsoup.safety.Whitelist; import java.util.*; import java.util.regex.Pattern; public class ValidationUtils { - public final static Integer COMPONENT_NAME_MAX_LENGTH = 1024; - public final static Pattern COMPONENT_NAME_PATTERN = Pattern + + private ValidationUtils() { + } + + public static final Integer COMPONENT_NAME_MAX_LENGTH = 1024; + public static final Pattern COMPONENT_NAME_PATTERN = Pattern .compile("^[\\w][\\w \\.\\-\\_\\:\\+]{0," + (COMPONENT_NAME_MAX_LENGTH-1) + "}$"); - public final static Integer ADDITIONAL_INFORMATION_KEY_MAX_LENGTH = 50; - public final static Pattern ADDITIONAL_INFORMATION_KEY_PATTERN = Pattern + public static final Integer ADDITIONAL_INFORMATION_KEY_MAX_LENGTH = 50; + public static final Pattern ADDITIONAL_INFORMATION_KEY_PATTERN = Pattern .compile("^[\\w\\s\\.\\-\\_]{1," + COMPONENT_NAME_MAX_LENGTH + "}$"); - public final static Integer RSI_NAME_MAX_LENGTH = 1024; - public final static Pattern RSI_NAME_PATTERN = Pattern + public static final Integer RSI_NAME_MAX_LENGTH = 1024; + public static final Pattern RSI_NAME_PATTERN = Pattern .compile("^[\\w \\s\\.\\-\\_\\:\\+]{1," + RSI_NAME_MAX_LENGTH + "}$"); - public final static Integer COMMENT_MAX_LENGTH = 256; + public static final Integer COMMENT_MAX_LENGTH = 256; - public final static Integer ICON_MAX_LENGTH = 25; - public final static Pattern ICON_PATTERN = Pattern.compile("^[\\w\\-]{1," + ICON_MAX_LENGTH + "}$"); - public final static Integer PROJECT_CODE_MAX_LEGTH = 50; - public final static Pattern PROJECT_CODE_PATTERN = Pattern.compile("^[\\s\\w_.-]{5,50}$"); + public static final Integer ICON_MAX_LENGTH = 25; + public static final Pattern ICON_PATTERN = Pattern.compile("^[\\w\\-]{1," + ICON_MAX_LENGTH + "}$"); + public static final Integer PROJECT_CODE_MAX_LEGTH = 50; + public static final Pattern PROJECT_CODE_PATTERN = Pattern.compile("^[\\s\\w_.-]{5,50}$"); // USER_ID format : aannnX (where a=a-z or A-Z, n=0-9, and X=a-z,A-Z, or 0-9) - public final static Integer CONNTACT_ID_MAX_LENGTH = 50; - // public final static Pattern CONTACT_ID_PATTERN = Pattern -// .compile("[mM]{1}[0-9]{5}|[a-zA-Z]{2}[0-9]{4}|[a-zA-Z]{2}[0-9]{3}[a-zA-Z]{1}"); - public final static Pattern CONTACT_ID_PATTERN = Pattern.compile("^[\\s\\w_.-]{1,50}$"); - public final static Pattern OCTET_PATTERN = Pattern.compile("%[a-fA-F0-9]{2}"); - public final static Pattern NONE_UTF8_PATTERN = Pattern.compile("[^\\x00-\\x7F]+"); - public final static Pattern URL_INVALIDE_PATTERN = Pattern.compile("[,#?&@$<>~^`\\\\\\[\\]{}|\")(*!+=;%]+");// ,#?&@$<>~^`\\[]{}|")(*! - - public final static Pattern ENGLISH_PATTERN = Pattern.compile("^[\\p{Graph}\\x20]+$"); - public final static Pattern COMMENT_PATTERN = Pattern.compile("^[\\u0000-\\u00BF]{1,1024}$"); - public final static Pattern SERVICE_METADATA_PATTERN = Pattern.compile("^[\\x20-\\x21\\x23-\\x29\\x2B-\\x2E\\x30-\\x39\\x3B\\x3D\\x40-\\x5B\\x5D-\\x7B\\x7D-\\xFF]{1,256}"); - public final static Integer COMPONENT_DESCRIPTION_MAX_LENGTH = 1024; - public final static Integer SERVICE_TYPE_MAX_LENGTH = 256; - public final static Integer SERVICE_ROLE_MAX_LENGTH = 256; - public final static Integer SERVICE_FUNCTION_MAX_LENGTH = 256; - public final static Integer SERVICE_NAMING_POLICY_MAX_SIZE = 100; - - public final static Integer TAG_MAX_LENGTH = 1024; - public final static Integer TAG_LIST_MAX_LENGTH = 1024; - public final static Integer VENDOR_NAME_MAX_LENGTH = 60; - public final static Pattern VENDOR_NAME_PATTERN = Pattern + public static final Integer CONNTACT_ID_MAX_LENGTH = 50; + + public static final Pattern CONTACT_ID_PATTERN = Pattern.compile("^[\\s\\w_.-]{1,50}$"); + public static final Pattern OCTET_PATTERN = Pattern.compile("%[a-fA-F0-9]{2}"); + public static final Pattern NONE_UTF8_PATTERN = Pattern.compile("[^\\x00-\\x7F]+"); + public static final Pattern URL_INVALIDE_PATTERN = Pattern.compile("[,#?&@$<>~^`\\\\\\[\\]{}|\")(*!+=;%]+");// ,#?&@$<>~^`\\[]{}|")(*! + + public static final Pattern ENGLISH_PATTERN = Pattern.compile("^[\\p{Graph}\\x20]+$"); + public static final Pattern COMMENT_PATTERN = Pattern.compile("^[\\u0000-\\u00BF]{1,1024}$"); + public static final Pattern SERVICE_METADATA_PATTERN = Pattern.compile("^[\\x20-\\x21\\x23-\\x29\\x2B-\\x2E\\x30-\\x39\\x3B\\x3D\\x40-\\x5B\\x5D-\\x7B\\x7D-\\xFF]{1,256}"); + public static final Integer COMPONENT_DESCRIPTION_MAX_LENGTH = 1024; + public static final Integer SERVICE_TYPE_MAX_LENGTH = 256; + public static final Integer SERVICE_ROLE_MAX_LENGTH = 256; + public static final Integer SERVICE_FUNCTION_MAX_LENGTH = 256; + public static final Integer SERVICE_NAMING_POLICY_MAX_SIZE = 100; + + public static final Integer TAG_MAX_LENGTH = 1024; + public static final Integer TAG_LIST_MAX_LENGTH = 1024; + public static final Integer VENDOR_NAME_MAX_LENGTH = 60; + public static final Pattern VENDOR_NAME_PATTERN = Pattern .compile("^[\\x20-\\x21\\x23-\\x29\\x2B-\\x2E\\x30-\\x39\\x3B\\x3D\\x40-\\x5B\\x5D-\\x7B\\x7D-\\xFF]+$"); - public final static Integer VENDOR_RELEASE_MAX_LENGTH = 25; - public final static Pattern VENDOR_RELEASE_PATTERN = Pattern + public static final Integer VENDOR_RELEASE_MAX_LENGTH = 25; + public static final Pattern VENDOR_RELEASE_PATTERN = Pattern .compile("^[\\x20-\\x21\\x23-\\x29\\x2B-\\x2E\\x30-\\x39\\x3B\\x3D\\x40-\\x5B\\x5D-\\x7B\\x7D-\\xFF]+$"); - public final static Integer RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH = 65; - - public final static Pattern CLEAN_FILENAME_PATTERN = Pattern.compile("[\\x00-\\x1f\\x80-\\x9f\\x5c/<?>\\*:|\"/]+"); - - public final static Pattern DASH_PATTERN = Pattern.compile("[-]+"); - public final static Pattern UNDERSCORE_PATTERN = Pattern.compile("[_]+"); - public final static Pattern PLUS_PATTERN = Pattern.compile("[+]+"); - public final static Pattern SPACE_PATTERN = Pattern.compile("[ ]+"); - public final static Pattern AMP_PATTERN = Pattern.compile("[&]+"); - public final static Pattern DOT_PATTERN = Pattern.compile("[\\.]+"); - public final static Pattern APOST_PATTERN = Pattern.compile("[']+"); - public final static Pattern HASHTAG_PATTERN = Pattern.compile("[#]+"); - public final static Pattern EQUAL_PATTERN = Pattern.compile("[=]+"); - public final static Pattern COLON_PATTERN = Pattern.compile("[:]+"); - public final static Pattern AT_PATTERN = Pattern.compile("[@]+"); - public final static Pattern AND_PATTERN = Pattern.compile(" [aA][Nn][Dd] "); - public final static Set<String> CATEGORY_CONJUNCTIONS = new HashSet<>( + public static final Integer RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH = 65; + + public static final Pattern CLEAN_FILENAME_PATTERN = Pattern.compile("[\\x00-\\x1f\\x80-\\x9f\\x5c/<?>\\*:|\"/]+"); + + public static final Pattern DASH_PATTERN = Pattern.compile("[-]+"); + public static final Pattern UNDERSCORE_PATTERN = Pattern.compile("[_]+"); + public static final Pattern PLUS_PATTERN = Pattern.compile("[+]+"); + public static final Pattern SPACE_PATTERN = Pattern.compile("[ ]+"); + public static final Pattern AMP_PATTERN = Pattern.compile("[&]+"); + public static final Pattern DOT_PATTERN = Pattern.compile("[\\.]+"); + public static final Pattern APOST_PATTERN = Pattern.compile("[']+"); + public static final Pattern HASHTAG_PATTERN = Pattern.compile("[#]+"); + public static final Pattern EQUAL_PATTERN = Pattern.compile("[=]+"); + public static final Pattern COLON_PATTERN = Pattern.compile("[:]+"); + public static final Pattern AT_PATTERN = Pattern.compile("[@]+"); + public static final Pattern AND_PATTERN = Pattern.compile(" [aA][Nn][Dd] "); + private static final Set<String> CATEGORY_CONJUNCTIONS = new HashSet<>( Arrays.asList("of", "to", "for", "as", "a", "an", "the")); - public final static Pattern COST_PATTERN = Pattern.compile("^[0-9]{1,5}\\.[0-9]{1,3}$"); - public final static Pattern ARTIFACT_LABEL_PATTERN = Pattern.compile("^[a-zA-Z0-9 \\-+]+$"); - public final static Integer ARTIFACT_LABEL_LENGTH = 255; - public final static Pattern ARTIFACT_DISPLAY_NAME_PATTERN = Pattern.compile("^[a-zA-Z0-9][a-zA-Z0-9 &\\.'#=:@_\\-+]+$"); - public final static Pattern CATEGORY_LABEL_PATTERN = Pattern.compile("^[a-zA-Z0-9][a-zA-Z0-9 &\\.'#=:@_\\-+]+$"); - public final static Integer CATEGORY_LABEL_MIN_LENGTH = 3; - public final static Integer CATEGORY_LABEL_MAX_LENGTH = 25; - - public final static Pattern COMPONENT_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-\\_]+"); - public final static Pattern COMPONENT_INCTANCE_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-]+"); - public final static Pattern PRODUCT_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-\\_&=#@':\\[\\]\\+]+"); - public final static Integer CONSUMER_NAME_MAX_LENGTH = 255; - // public final static Pattern CONSUMER_NAME_PATTERN = - // Pattern.compile("^[\\w]{1}?[\\w\\.\\-]{0," + CONSUMER_NAME_MAX_LENGTH + - // "}?$"); - public final static Pattern CONSUMER_NAME_PATTERN = Pattern.compile("^[\\w]+[\\w\\.\\-]*$"); - public final static Integer CONSUMER_SALT_LENGTH = 32; - public final static Integer CONSUMER_PASSWORD_LENGTH = 64; - public final static Pattern CONSUMER_PASS_SALT_PATTERN = Pattern.compile("^[a-z0-9]+$"); - public final static Pattern FLOAT_PATTERN = Pattern.compile("^[\\d]+[\\.]{1}[\\d]+$"); - public final static Pattern CERTIFIED_VERSION_PATTERN = Pattern.compile("^[1-9][0-9]*\\.0$"); - public final static Pattern MINOR_VERSION_PATTERN = Pattern.compile("^0\\.[1-9][0-9]*$"); - public final static Pattern TAGS_PATTERN = Pattern.compile("<[^><]*>"); - public final static Pattern TAG_PATTERN = Pattern.compile("^[\\s\\w_.-]{1,1024}$"); - - public final static Integer ARTIFACT_NAME_LENGTH = 255; - public final static Integer API_URL_LENGTH = 100; - public final static Integer ARTIFACT_DESCRIPTION_MAX_LENGTH = 256; - - public final static Integer PRODUCT_FULL_NAME_MIN_LENGTH = 4; - public final static Integer PRODUCT_FULL_NAME_MAX_LENGTH = 100; + public static final Pattern COST_PATTERN = Pattern.compile("^[0-9]{1,5}\\.[0-9]{1,3}$"); + public static final Pattern ARTIFACT_LABEL_PATTERN = Pattern.compile("^[a-zA-Z0-9 \\-+]+$"); + public static final Integer ARTIFACT_LABEL_LENGTH = 255; + public static final Pattern ARTIFACT_DISPLAY_NAME_PATTERN = Pattern.compile("^[a-zA-Z0-9][a-zA-Z0-9 &\\.'#=:@_\\-+]+$"); + public static final Pattern CATEGORY_LABEL_PATTERN = Pattern.compile("^[a-zA-Z0-9][a-zA-Z0-9 &\\.'#=:@_\\-+]+$"); + public static final Integer CATEGORY_LABEL_MIN_LENGTH = 3; + public static final Integer CATEGORY_LABEL_MAX_LENGTH = 25; + + public static final Pattern COMPONENT_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-\\_]+"); + public static final Pattern COMPONENT_INCTANCE_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-]+"); + public static final Pattern PRODUCT_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-\\_&=#@':\\[\\]\\+]+"); + public static final Integer CONSUMER_NAME_MAX_LENGTH = 255; + + public static final Pattern CONSUMER_NAME_PATTERN = Pattern.compile("^[\\w]+[\\w\\.\\-]*$"); + public static final Integer CONSUMER_SALT_LENGTH = 32; + public static final Integer CONSUMER_PASSWORD_LENGTH = 64; + public static final Pattern CONSUMER_PASS_SALT_PATTERN = Pattern.compile("^[a-z0-9]+$"); + public static final Pattern FLOAT_PATTERN = Pattern.compile("^[\\d]+[\\.]{1}[\\d]+$"); + public static final Pattern CERTIFIED_VERSION_PATTERN = Pattern.compile("^[1-9][0-9]*\\.0$"); + public static final Pattern MINOR_VERSION_PATTERN = Pattern.compile("^0\\.[1-9][0-9]*$"); + public static final Pattern TAGS_PATTERN = Pattern.compile("<[^><]*>"); + public static final Pattern TAG_PATTERN = Pattern.compile("^[\\s\\w_.-]{1,1024}$"); + + public static final Integer ARTIFACT_NAME_LENGTH = 255; + public static final Integer API_URL_LENGTH = 100; + public static final Integer ARTIFACT_DESCRIPTION_MAX_LENGTH = 256; + + public static final Integer PRODUCT_FULL_NAME_MIN_LENGTH = 4; + public static final Integer PRODUCT_FULL_NAME_MAX_LENGTH = 100; public static final Integer FORWARDING_PATH_NAME_MAX_LENGTH = 100; - public final static Pattern FORWARDING_PATH_NAME_PATTERN = Pattern.compile("^[\\w][\\w \\.\\-\\_\\:\\+]{0," + (FORWARDING_PATH_NAME_MAX_LENGTH-1) + "}$"); + public static final Pattern FORWARDING_PATH_NAME_PATTERN = Pattern.compile("^[\\w][\\w \\.\\-\\_\\:\\+]{0," + (FORWARDING_PATH_NAME_MAX_LENGTH-1) + "}$"); - public final static Integer POLICY_MAX_LENGTH = 1024; - public final static Pattern POLICY_NAME_PATTERN = Pattern + public static final Integer POLICY_MAX_LENGTH = 1024; + public static final Pattern POLICY_NAME_PATTERN = Pattern .compile("^[\\w][\\w \\.\\-\\_\\:\\+]{0," + (POLICY_MAX_LENGTH-1) + "}$"); public static boolean validateArtifactLabel(String label) { @@ -456,10 +456,6 @@ public class ValidationUtils { } public static String normalizeFileName(String filename) { - // String[] split = filename.split(Pattern.quote(File.separator)); - // String name = ""; - // - // name = split[split.length - 1]; return cleanFileName(filename); } @@ -497,7 +493,6 @@ public class ValidationUtils { str = PLUS_PATTERN.matcher(str).replaceAll("+"); str = normaliseWhitespace(str); str = str.trim(); - // str = str.replaceAll(" ", ""); return str; } |