diff options
Diffstat (limited to 'common-app-api/src')
13 files changed, 147 insertions, 464 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java index 7d37de7965..c962500c2b 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java @@ -82,6 +82,7 @@ public class Configuration extends BasicConfiguration { private List<String> resourceTypes; private List<String> excludeResourceCategory; + private List<String> excludeResourceType; private Map<String, Object> deploymentResourceArtifacts; private Map<String, Object> deploymentResourceInstanceArtifacts; private Map<String, Object> toscaArtifacts; @@ -361,6 +362,15 @@ public class Configuration extends BasicConfiguration { public void setExcludeResourceCategory(List<String> excludeResourceCategory) { this.excludeResourceCategory = excludeResourceCategory; } + + public List<String> getExcludeResourceType() { + return excludeResourceType; + } + + public void setExcludeResourceType(List<String> excludeResourceType) { + this.excludeResourceType = excludeResourceType; + } + public Map<String, Object> getToscaArtifacts() { return toscaArtifacts; @@ -842,6 +852,7 @@ public class Configuration extends BasicConfiguration { String host; Integer port; String downloadCsarUri; + String healthCheckUri; public String getProtocol() { return protocol; @@ -875,6 +886,14 @@ public class Configuration extends BasicConfiguration { this.downloadCsarUri = downloadCsarUri; } + public String getHealthCheckUri() { + return healthCheckUri; + } + + public void setHealthCheckUri(String healthCheckUri) { + this.healthCheckUri = healthCheckUri; + } + @Override public String toString() { return "OnboardingConfig [protocol=" + protocol + ", host=" + host + ", port=" + port + ", downloadCsarUri=" diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java index 56e26ce55e..1bef188d0d 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java @@ -64,6 +64,8 @@ public class DistributionEngineConfiguration extends BasicConfiguration { private Integer defaultArtifactInstallationTimeout = 60; + private boolean useHttpsWithDmaap; + public static class DistribNotifServiceArtifacts { Map<String, Object> service; @@ -260,6 +262,14 @@ public class DistributionEngineConfiguration extends BasicConfiguration { this.defaultArtifactInstallationTimeout = defaultArtifactInstallationTimeout; } + public boolean isUseHttpsWithDmaap() { + return useHttpsWithDmaap; + } + + public void setUseHttpsWithDmaap(boolean useHttpsWithDmaap) { + this.useHttpsWithDmaap = useHttpsWithDmaap; + } + public static class CreateTopicConfig { private Integer partitionCount; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java index 6e7ebc1854..f13984bc67 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java @@ -31,7 +31,7 @@ public enum ArtifactTypeEnum { CHEF("CHEF"), PUPPET("PUPPET"), YANG("YANG"), SHELL_SCRIPT("SHELL_SCRIPT"), SHELL("SHELL"), ICON("ICON"), UNKNOWN("UNKNOWN"), HEAT("HEAT"), DG_XML("DG_XML"), MURANO_PKG("MURANO_PKG"), HEAT_ENV("HEAT_ENV"), YANG_XML("YANG_XML"), HEAT_VOL("HEAT_VOL"), HEAT_NET("HEAT_NET"), OTHER("OTHER"), WORKFLOW("WORKFLOW"), NETWORK_CALL_FLOW("NETWORK_CALL_FLOW"), TOSCA_TEMPLATE("TOSCA_TEMPLATE"), TOSCA_CSAR("TOSCA_CSAR"), VNF_CATALOG("VNF_CATALOG"), VF_LICENSE("VF_LICENSE"), BPEL("BPEL"), VENDOR_LICENSE("VENDOR_LICENSE"), MODEL_INVENTORY_PROFILE("MODEL_INVENTORY_PROFILE"), MODEL_QUERY_SPEC("MODEL_QUERY_SPEC"), APPC_CONFIG("APPC_CONFIG"), HEAT_NESTED("HEAT_NESTED"), HEAT_ARTIFACT("HEAT_ARTIFACT"), - VF_MODULES_METADATA("VF_MODULES_METADATA"), LIFECYCLE_OPERATIONS("LIFECYCLE_OPERATIONS"), VES_EVENTS("VES_EVENTS"), PERFORMANCE_COUNTER("PERFORMANCE_COUNTER"), + VF_MODULES_METADATA("VF_MODULES_METADATA"), LIFECYCLE_OPERATIONS("LIFECYCLE_OPERATIONS"), VES_EVENTS("VES_EVENTS"), PERFORMANCE_COUNTER("PERFORMANCE_COUNTER"),UCPE_LAYER_2_CONFIGURATION("UCPE_LAYER_2_CONFIGURATION"), // DCAE Artifacts DCAE_TOSCA("DCAE_TOSCA"), DCAE_JSON("DCAE_JSON"), DCAE_POLICY("DCAE_POLICY"), DCAE_DOC("DCAE_DOC"), DCAE_EVENT("DCAE_EVENT"), DCAE_INVENTORY_TOSCA("DCAE_INVENTORY_TOSCA"), DCAE_INVENTORY_JSON("DCAE_INVENTORY_JSON"), DCAE_INVENTORY_POLICY("DCAE_INVENTORY_POLICY"), DCAE_INVENTORY_DOC("DCAE_INVENTORY_DOC"), DCAE_INVENTORY_BLUEPRINT("DCAE_INVENTORY_BLUEPRINT"), DCAE_INVENTORY_EVENT("DCAE_INVENTORY_EVENT"), diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java index b1f4117aaf..fcde7f13ac 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java @@ -40,6 +40,7 @@ public interface Constants { public static final String LAST_NAME_HEADER = "HTTP_CSP_LASTNAME"; public static final String USER_ID_HEADER = "USER_ID"; public static final String MD5_HEADER = "Content-MD5"; + public static final String CONTENT_LENGTH_HEADER = "Content-Length"; public static final String CONTENT_DISPOSITION_HEADER = "Content-Disposition"; public static final String CONTENT_TYPE_HEADER = "Content-Type"; public static final String ORIGIN_HEADER = "HTTP_IV_REMOTE_ADDRESS"; @@ -124,5 +125,6 @@ public interface Constants { public static final String VF_LICENSE_DESCRIPTION = "VF license file"; public static final String GET_INPUT = "get_input"; public static final String SERVICE_TEMPLATE_FILE_POSTFIX = "ServiceTemplate.yaml"; + public static final String SERVICE_TEMPLATES_CONTAINING_FOLDER = "Definitions/"; public static final String UNBOUNDED = "unbounded"; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java index 653b8b0866..2e4f54f153 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java @@ -20,12 +20,19 @@ package org.openecomp.sdc.common.api; +import java.lang.reflect.Type; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; + public class HealthCheckInfo { private HealthCheckComponent healthCheckComponent; private HealthCheckStatus healthCheckStatus; private String version; private String description; + private List<HealthCheckInfo> componentsInfo; public HealthCheckInfo(HealthCheckComponent healthCheckComponent, HealthCheckStatus healthCheckStatus, String version, String description) { @@ -36,6 +43,16 @@ public class HealthCheckInfo { this.description = description; } + public HealthCheckInfo(HealthCheckComponent healthCheckComponent, HealthCheckStatus healthCheckStatus, + String version, String description, List<HealthCheckInfo> componentsInfo) { + super(); + this.healthCheckComponent = healthCheckComponent; + this.healthCheckStatus = healthCheckStatus; + this.version = version; + this.description = description; + this.componentsInfo = componentsInfo; + } + public HealthCheckInfo() { super(); } @@ -48,6 +65,14 @@ public class HealthCheckInfo { return healthCheckStatus; } + public List<HealthCheckInfo> getComponentsInfo() { + return componentsInfo; + } + + public void setComponentsInfo(List<HealthCheckInfo> componentsInfo) { + this.componentsInfo = componentsInfo; + } + public String getVersion() { return version; } @@ -61,7 +86,8 @@ public class HealthCheckInfo { } public enum HealthCheckComponent { - FE, BE, TITAN, ES, DE; + FE, BE, TITAN, DE, ON_BOARDING, CASSANDRA, + CAS, ZU;//Amdocs components } public enum HealthCheckStatus { @@ -71,6 +97,14 @@ public class HealthCheckInfo { @Override public String toString() { return "HealthCheckInfo [healthCheckComponent=" + healthCheckComponent + ", healthCheckStatus=" - + healthCheckStatus + ", version=" + version + ", description=" + description + "]"; + + healthCheckStatus + ", version=" + version + ", description=" + description + ", componentsInfo=" + + componentsInfo + "]"; + } + + public static void main(String[] args) { + String des = "[{healthCheckComponent=BE4, healthCheckStatus=UP, version=0.0.1-SNAPSHOT, description=OK}, {healthCheckComponent=BE, healthCheckStatus=UP, version=1710.0.0-SNAPSHOT, description=OK}, {healthCheckComponent=BE5, healthCheckStatus=UP, version=2.1.9, description=OK}]"; + Type listType = new TypeToken<List<HealthCheckInfo>>(){}.getType(); + List<HealthCheckInfo> componentsInfo = new Gson().fromJson(des.toString(), listType); + System.out.println(componentsInfo.toString()); } } 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 0f45d34886..aaee26004f 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 @@ -26,7 +26,7 @@ public enum EcompErrorCode { "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: Titan DB, Elasticsearch, UEB Cluster. Please check the logs for more information."), E_201( + E_200("ASDC Backend probably lost connectivity to either one of the following components: Titan DB, Cassandra, Onboarding, UEB Cluster. Please check the logs for more information."), E_201( "ASDC Backend probably lost connectivity to Titan 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.", @@ -34,7 +34,7 @@ public enum EcompErrorCode { "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: Titan DB, Elasticsearch, UEB Cluster."), E_206( + E_205("ASDC Backend Recovery to either one of the following components: Titan DB, Cassandra, Onboarding, UEB Cluster."), E_206( "ASDC Backend connection recovery to Titan DB."), E_207( "ASDC Backend connection recovery to ElasticSearch."), E_208( "ASDC Backend connection recovery to UEB Cluster."), E_209( diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/CapList.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/CapList.java deleted file mode 100644 index d202715fae..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/CapList.java +++ /dev/null @@ -1,324 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.common.datastructure; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -/** - * Thread Safe List with a cap for Max elements.<br> - * If an element would be inserted to the list and it is full, the oldest - * element will be taken out. - * - * @author mshitrit - * - * @param <T> - */ -public class CapList<T> implements List<T> { - private static final int DEFAULT_CAP = 1000; - private int cap; - private ReadWriteLock readWriteLock; - private List<T> innerList; - - public CapList() { - this(DEFAULT_CAP); - } - - public CapList(int cap) { - if (cap < 1) { - throw new RuntimeException("List Cap Must Be Positive"); - } - this.cap = cap; - innerList = new ArrayList<>(); - readWriteLock = new ReentrantReadWriteLock(); - } - - @Override - public boolean add(T e) { - try { - readWriteLock.writeLock().lock(); - boolean result = innerList.add(e); - removeExtras(); - return result; - - } finally { - readWriteLock.writeLock().unlock(); - } - - } - - private void removeExtras() { - while (innerList.size() > cap) { - innerList.remove(0); - } - } - - @Override - public void add(int index, T element) { - try { - readWriteLock.writeLock().lock(); - innerList.add(index, element); - } finally { - readWriteLock.writeLock().unlock(); - } - - } - - @Override - public boolean addAll(Collection<? extends T> c) { - try { - readWriteLock.writeLock().lock(); - boolean result = innerList.addAll(c); - removeExtras(); - return result; - } finally { - readWriteLock.writeLock().unlock(); - } - } - - @Override - public boolean addAll(int index, Collection<? extends T> c) { - try { - readWriteLock.writeLock().lock(); - boolean result = innerList.addAll(index, c); - removeExtras(); - return result; - } finally { - readWriteLock.writeLock().unlock(); - } - } - - @Override - public void clear() { - try { - readWriteLock.writeLock().lock(); - innerList.clear(); - } finally { - readWriteLock.writeLock().unlock(); - } - - } - - @Override - public boolean contains(Object o) { - try { - readWriteLock.readLock().lock(); - return innerList.contains(o); - - } finally { - readWriteLock.readLock().unlock(); - } - - } - - @Override - public boolean containsAll(Collection<?> c) { - try { - readWriteLock.readLock().lock(); - return innerList.containsAll(c); - - } finally { - readWriteLock.readLock().unlock(); - } - } - - @Override - public T get(int index) { - try { - readWriteLock.readLock().lock(); - return innerList.get(index); - - } finally { - readWriteLock.readLock().unlock(); - } - } - - @Override - public int indexOf(Object o) { - try { - readWriteLock.readLock().lock(); - return innerList.indexOf(o); - - } finally { - readWriteLock.readLock().unlock(); - } - } - - @Override - public boolean isEmpty() { - try { - readWriteLock.readLock().lock(); - return innerList.isEmpty(); - - } finally { - readWriteLock.readLock().unlock(); - } - } - - @Override - public Iterator<T> iterator() { - try { - readWriteLock.readLock().lock(); - return innerList.iterator(); - - } finally { - readWriteLock.readLock().unlock(); - } - } - - @Override - public int lastIndexOf(Object o) { - try { - readWriteLock.readLock().lock(); - return innerList.lastIndexOf(o); - - } finally { - readWriteLock.readLock().unlock(); - } - } - - @Override - public ListIterator<T> listIterator() { - try { - readWriteLock.readLock().lock(); - return innerList.listIterator(); - - } finally { - readWriteLock.readLock().unlock(); - } - } - - @Override - public ListIterator<T> listIterator(int index) { - try { - readWriteLock.readLock().lock(); - return innerList.listIterator(index); - - } finally { - readWriteLock.readLock().unlock(); - } - } - - @Override - public boolean remove(Object o) { - try { - readWriteLock.writeLock().lock(); - return innerList.remove(o); - - } finally { - readWriteLock.writeLock().unlock(); - } - } - - @Override - public T remove(int index) { - try { - readWriteLock.writeLock().lock(); - return innerList.remove(index); - - } finally { - readWriteLock.writeLock().unlock(); - } - } - - @Override - public boolean removeAll(Collection<?> c) { - try { - readWriteLock.writeLock().lock(); - return innerList.removeAll(c); - - } finally { - readWriteLock.writeLock().unlock(); - } - } - - @Override - public boolean retainAll(Collection<?> c) { - try { - readWriteLock.writeLock().lock(); - return innerList.retainAll(c); - - } finally { - readWriteLock.writeLock().unlock(); - } - } - - @Override - public T set(int index, T element) { - try { - readWriteLock.writeLock().lock(); - return innerList.set(index, element); - - } finally { - readWriteLock.writeLock().unlock(); - } - } - - @Override - public int size() { - try { - readWriteLock.readLock().lock(); - return innerList.size(); - - } finally { - readWriteLock.readLock().unlock(); - } - } - - @Override - public List<T> subList(int fromIndex, int toIndex) { - try { - readWriteLock.readLock().lock(); - return innerList.subList(fromIndex, toIndex); - - } finally { - readWriteLock.readLock().unlock(); - } - } - - @Override - public Object[] toArray() { - try { - readWriteLock.readLock().lock(); - return innerList.toArray(); - - } finally { - readWriteLock.readLock().unlock(); - } - } - - @Override - public <T> T[] toArray(T[] a) { - try { - readWriteLock.readLock().lock(); - return innerList.toArray(a); - - } finally { - readWriteLock.readLock().unlock(); - } - } - -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/jsongraph/util/CommonUtility.java b/common-app-api/src/main/java/org/openecomp/sdc/common/jsongraph/util/CommonUtility.java index 8f94d8042c..dfcf5b58c0 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/jsongraph/util/CommonUtility.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/jsongraph/util/CommonUtility.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ + package org.openecomp.sdc.common.jsongraph.util; import org.slf4j.Logger; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java index c89eeaf535..0b55fd1845 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java @@ -153,4 +153,14 @@ public class GeneralUtility { byte[] encodeBase64 = Base64.encodeBase64(calculatedMd5.getBytes()); return new String(encodeBase64); } + + + /** + * + * @param String + * @return String is null or Empty + */ + public static boolean isEmptyString(String str) { + return str == null || str.trim().isEmpty(); + } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java index 3dd313b824..eb6c29ce4a 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 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. + * ============LICENSE_END========================================================= + */ + package org.openecomp.sdc.common.util; import org.apache.commons.lang3.tuple.ImmutablePair; 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 3ea780a7f9..6c47659dad 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 @@ -66,14 +66,18 @@ public class ValidationUtils { public final static Pattern ENGLISH_PATTERN = Pattern.compile("^[\\p{Graph}\\x20]+$"); public final static Integer COMPONENT_DESCRIPTION_MAX_LENGTH = 1024; + public final static Integer SERVICE_TYPE_MAX_LENGTH = 400; + public final static Integer SERVICE_ROLE_MAX_LENGTH = 400; + 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 = 25; + public final static Integer VENDOR_NAME_MAX_LENGTH = 60; public final static 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 .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/<?>\\*:|\"/]+"); @@ -318,14 +322,18 @@ public class ValidationUtils { return true; } - public static boolean validateVendorName(String ventorName) { - return VENDOR_NAME_PATTERN.matcher(ventorName).matches(); + public static boolean validateVendorName(String vendorName) { + return VENDOR_NAME_PATTERN.matcher(vendorName).matches(); } - public static boolean validateVendorNameLength(String ventorName) { - return ventorName.length() <= VENDOR_NAME_MAX_LENGTH; + public static boolean validateVendorNameLength(String vendorName) { + return vendorName.length() <= VENDOR_NAME_MAX_LENGTH; } + public static boolean validateResourceVendorModelNumberLength(String resourceVendorModelNumber) { + return resourceVendorModelNumber.length() <= RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH; + } + public static boolean validateVendorRelease(String vendorRelease) { return VENDOR_RELEASE_PATTERN.matcher(vendorRelease).matches(); } @@ -333,6 +341,16 @@ public class ValidationUtils { public static boolean validateVendorReleaseLength(String vendorRelease) { return vendorRelease.length() <= VENDOR_RELEASE_MAX_LENGTH; } + + public static boolean validateServiceTypeLength(String serviceType) { + return serviceType.length() <= SERVICE_TYPE_MAX_LENGTH; + } + + public static boolean validateServiceRoleLength(String serviceRole) { + return serviceRole.length() <= SERVICE_ROLE_MAX_LENGTH; + } + + public static boolean hasBeenCertified(String version) { return NumberUtils.toDouble(version) >= 1; @@ -509,5 +527,5 @@ public class ValidationUtils { String stripped = HtmlCleaner.stripHtml(htmlText, false); return stripped; } - + } diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/data_structure/CapListTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/data_structure/CapListTest.java deleted file mode 100644 index 7aeb2ac70d..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/data_structure/CapListTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.common.data_structure; - -import static org.junit.Assert.assertTrue; - -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.junit.Test; -import org.openecomp.sdc.common.datastructure.CapList; - -public class CapListTest { - public enum LIST_ACTION { - Add, Remove, Size, Get - } - - @Test - public void testCap() { - List<Integer> testList = new CapList<>(10); - for (int i = 0; i < 100; i++) { - testList.add(i); - } - assertTrue(testList.size() == 10); - for (int i = 0; i < testList.size(); i++) { - assertTrue(testList.get(i) == (i + 90)); - } - } - - @Test - public void testThreadSafe() { - List<Integer> testList = new CapList<>(1000); - - ExecutorService executor = Executors.newFixedThreadPool(4); - for (int i = 0; i < 10; i++) { - Runnable worker; - // 0 - 4 - if (i < 5) { - worker = new ThreadWorker(i, LIST_ACTION.Add, testList); - } - // 5, 8 - else if (i == 5 || i == 8) { - worker = new ThreadWorker(i, LIST_ACTION.Remove, testList); - } - // 6 - else if (i == 6) { - worker = new ThreadWorker(i, LIST_ACTION.Size, testList); - } - // 7, 9 - else { - worker = new ThreadWorker(i, LIST_ACTION.Get, testList); - } - executor.execute(worker); - } - executor.shutdown(); - while (!executor.isTerminated()) { - } - assertTrue(testList.size() == 60); - } - - public static class ThreadWorker implements Runnable { - private LIST_ACTION action; - private List<Integer> list; - private Integer id; - - ThreadWorker(Integer id, LIST_ACTION action, List<Integer> list) { - this.action = action; - this.list = list; - this.id = id; - } - - @Override - public void run() { - for (int i = 0; i < 20; i++) { - threadNap(); - switch (action) { - case Add: - list.add(id * 100 + i); - break; - case Remove: { - int index = (int) (Math.random() * 10); - list.remove(index); - break; - } - case Get: - int index = (int) (Math.random() * 10); - Integer integer = list.get(index); - - break; - case Size: - int size = list.size(); - break; - } - } - - } - - private void threadNap() { - long napTime = (long) (Math.random() * 100); - try { - Thread.sleep(napTime); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } -} diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java index 50c2b79d63..ae882d8a92 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java @@ -257,7 +257,7 @@ public class CommonUtilsTest { @Test public void validateVendorNameLengthTest() { assertTrue(ValidationUtils.validateVendorNameLength("fsdlfsdlk.sdsd;")); - assertFalse(ValidationUtils.validateVendorNameLength("ddddddddddddddddddddddsdfs")); + assertFalse(ValidationUtils.validateVendorNameLength("ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddsdfs")); } @Test @@ -271,8 +271,8 @@ public class CommonUtilsTest { @Test public void validateVendorReleaseLengthTest() { - assertTrue(ValidationUtils.validateVendorNameLength("fsdlfsdlk.sdsd;")); - assertFalse(ValidationUtils.validateVendorNameLength("ddddddddddddddddddddddsdfs")); + assertTrue(ValidationUtils.validateVendorReleaseLength("fsdlfsdlk.sdsd;")); + assertFalse(ValidationUtils.validateVendorReleaseLength("ddddddddddddddddddddddsdfs")); } @Test |