2 * Copyright © 2016-2017 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.validation.impl.validators.namingconvention;
19 import org.apache.commons.collections4.MapUtils;
20 import org.apache.commons.lang3.tuple.ImmutablePair;
21 import org.apache.commons.lang3.tuple.Pair;
22 import org.openecomp.core.validation.ErrorMessageCode;
23 import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
24 import org.openecomp.core.validation.types.GlobalValidationContext;
25 import org.openecomp.sdc.common.errors.Messages;
26 import org.openecomp.sdc.datatypes.error.ErrorLevel;
27 import org.openecomp.sdc.heat.datatypes.DefinedHeatParameterTypes;
28 import org.openecomp.sdc.heat.datatypes.model.Environment;
29 import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
30 import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
31 import org.openecomp.sdc.heat.datatypes.model.Resource;
32 import org.openecomp.sdc.heat.datatypes.model.ResourceReferenceFunctions;
33 import org.openecomp.sdc.heat.services.HeatStructureUtil;
34 import org.openecomp.sdc.logging.types.LoggerErrorDescription;
35 import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
36 import org.openecomp.sdc.validation.ResourceValidator;
37 import org.openecomp.sdc.validation.ValidationContext;
38 import org.openecomp.sdc.validation.type.NamingConventionValidationContext;
39 import org.openecomp.sdc.validation.util.ValidationUtil;
41 import java.util.ArrayList;
42 import java.util.Arrays;
43 import java.util.Collection;
44 import java.util.Comparator;
45 import java.util.HashMap;
46 import java.util.LinkedList;
47 import java.util.List;
49 import java.util.Objects;
50 import java.util.TreeMap;
52 import static java.util.Objects.nonNull;
54 public class NovaServerNamingConventionGuideLineValidator implements ResourceValidator {
55 private static final String AVAILABILITY_ZONE = "availability_zone";
56 private static final String SERVER = "Server";
57 private static final ErrorMessageCode ERROR_CODE_NNS1 = new ErrorMessageCode("NNS1");
58 private static final ErrorMessageCode ERROR_CODE_NNS2 = new ErrorMessageCode("NNS2");
59 private static final ErrorMessageCode ERROR_CODE_NNS3 = new ErrorMessageCode("NNS3");
60 private static final ErrorMessageCode ERROR_CODE_NNS4 = new ErrorMessageCode("NNS4");
61 private static final ErrorMessageCode ERROR_CODE_NNS5 = new ErrorMessageCode("NNS5");
62 private static final ErrorMessageCode ERROR_CODE_NNS6 = new ErrorMessageCode("NNS6");
63 private static final ErrorMessageCode ERROR_CODE_NNS7 = new ErrorMessageCode("NNS7");
64 private static final ErrorMessageCode ERROR_CODE_NNS8 = new ErrorMessageCode("NNS8");
65 private static final ErrorMessageCode ERROR_CODE_NNS9 = new ErrorMessageCode("NNS9");
66 private static final ErrorMessageCode ERROR_CODE_NNS10 = new ErrorMessageCode("NNS10");
67 private static final ErrorMessageCode ERROR_CODE_NNS11 = new ErrorMessageCode("NNS11");
68 private static final ErrorMessageCode ERROR_CODE_NNS12 = new ErrorMessageCode("NNS12");
69 private static final ErrorMessageCode ERROR_CODE_NNS13 = new ErrorMessageCode("NNS13");
70 private static final ErrorMessageCode ERROR_CODE_NNS14 = new ErrorMessageCode("NNS14");
73 public void validate(String fileName, Map.Entry<String, Resource> resourceEntry,
74 GlobalValidationContext globalContext, ValidationContext validationContext) {
76 NamingConventionValidationContext namingConventionValidationContext =
77 (NamingConventionValidationContext)validationContext;
78 validateHeatNovaResource(fileName, namingConventionValidationContext.getEnvFileName(),
79 namingConventionValidationContext.getHeatOrchestrationTemplate(),
83 private void validateHeatNovaResource(String fileName, String envFileName,
84 HeatOrchestrationTemplate heatOrchestrationTemplate,
85 GlobalValidationContext globalContext) {
86 Map<String, String> uniqueResourcePortNetworkRole = new HashMap<>();
87 //if no resources exist return
88 if (MapUtils.isEmpty(heatOrchestrationTemplate.getResources())) {
92 heatOrchestrationTemplate
96 .filter(entry -> entry.getValue().getType()
97 .equals(HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource()))
98 .forEach( entry -> validateNovaServerResourceType(entry.getKey(), fileName, envFileName,
99 entry, uniqueResourcePortNetworkRole, heatOrchestrationTemplate, globalContext));
102 private void validateNovaServerResourceType(String resourceId, String fileName,
104 Map.Entry<String, Resource> resourceEntry,
105 Map<String, String> uniqueResourcePortNetworkRole,
106 HeatOrchestrationTemplate heatOrchestrationTemplate,
107 GlobalValidationContext globalContext) {
108 validateNovaServerResourceMetaData(fileName, resourceId,
109 heatOrchestrationTemplate.getResources().get(resourceId), globalContext);
110 validateNovaServerResourceNetworkUniqueRole(fileName, resourceId, uniqueResourcePortNetworkRole,
111 heatOrchestrationTemplate, globalContext);
112 validateAvailabilityZoneName(fileName, resourceEntry, globalContext);
113 validateNovaServerNameImageAndFlavor(fileName, envFileName, resourceEntry, globalContext);
116 @SuppressWarnings("unchecked")
117 private void validateNovaServerResourceMetaData(String fileName, String resourceId,
119 GlobalValidationContext globalValidationContext) {
120 Map<String, Object> novaServerProp = resource.getProperties();
121 Object novaServerPropMetadata;
122 if (MapUtils.isNotEmpty(novaServerProp)) {
123 novaServerPropMetadata = novaServerProp.get("metadata");
124 if (novaServerPropMetadata == null) {
125 globalValidationContext.addMessage(
128 ErrorMessagesFormatBuilder
129 .getErrorWithParameters(
130 ERROR_CODE_NNS1, Messages.MISSING_NOVA_SERVER_METADATA.getErrorMessage(),
132 LoggerTragetServiceName.VALIDATE_NOVA_META_DATA_NAME,
133 LoggerErrorDescription.MISSING_NOVA_PROPERTIES);
134 } else if (novaServerPropMetadata instanceof Map) {
135 TreeMap<String, Object> propertyMap = new TreeMap((Comparator<String>) String::compareToIgnoreCase);
136 propertyMap.putAll((Map) novaServerPropMetadata);
137 if (!propertyMap.containsKey("vf_module_id")) {
138 globalValidationContext.addMessage(
141 ErrorMessagesFormatBuilder.getErrorWithParameters(
142 ERROR_CODE_NNS2, Messages.MISSING_NOVA_SERVER_VF_MODULE_ID.getErrorMessage(),
144 LoggerTragetServiceName.VALIDATE_NOVA_META_DATA_NAME,
145 LoggerErrorDescription.MISSING_NOVA_PROPERTIES);
147 if (!propertyMap.containsKey("vnf_id")) {
148 globalValidationContext.addMessage(
149 fileName, ErrorLevel.WARNING,
150 ErrorMessagesFormatBuilder
151 .getErrorWithParameters(
152 ERROR_CODE_NNS3, Messages.MISSING_NOVA_SERVER_VNF_ID.getErrorMessage(),
154 LoggerTragetServiceName.VALIDATE_NOVA_META_DATA_NAME,
155 LoggerErrorDescription.MISSING_NOVA_PROPERTIES);
161 private void validateNovaServerResourceNetworkUniqueRole(String fileName, String resourceId,
162 Map<String, String> uniqueResourcePortNetworkRole,
163 HeatOrchestrationTemplate heatOrchestrationTemplate,
164 GlobalValidationContext globalValidationContext) {
165 Object propertyNetworkValue =
166 heatOrchestrationTemplate.getResources().get(resourceId).getProperties().get("networks");
167 if (propertyNetworkValue != null && propertyNetworkValue instanceof List) {
168 List<String> portResourceIdList =
169 getNovaNetworkPortResourceList(fileName, (List) propertyNetworkValue,
170 globalValidationContext);
171 for (String portResourceId : portResourceIdList) {
172 Resource portResource = heatOrchestrationTemplate.getResources().get(portResourceId);
174 if (portResource != null && portResource.getType()
175 .equals(HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource())) {
176 validateUniqueResourcePortNetworkRole(fileName, resourceId,
177 uniqueResourcePortNetworkRole, globalValidationContext,
178 portResourceId, portResource);
184 private void validateUniqueResourcePortNetworkRole(String fileName, String resourceId,
185 Map<String, String> uniqueResourcePortNetworkRole,
186 GlobalValidationContext globalValidationContext,
187 String portResourceId, Resource portResource) {
191 getPortNetwork(fileName, resourceId, portResource, globalValidationContext);
192 if (Objects.nonNull(portNetwork)) {
193 network = portNetwork.get("get_param");
194 if (Objects.nonNull(network)) {
195 if (network instanceof String ){
196 role = getNetworkRole((String)network);
197 }else if (network instanceof List){
198 role = getNetworkRole((String)((List) network).get(0));
200 if (role != null && uniqueResourcePortNetworkRole.containsKey(role)) {
201 globalValidationContext.addMessage(
204 ErrorMessagesFormatBuilder.getErrorWithParameters(
205 ERROR_CODE_NNS12, Messages.RESOURCE_CONNECTED_TO_TWO_EXTERNAL_NETWORKS_WITH_SAME_ROLE
206 .getErrorMessage(), resourceId, role),
207 LoggerTragetServiceName.VALIDATE_RESOURCE_NETWORK_UNIQUE_ROLW,
208 LoggerErrorDescription.RESOURCE_UNIQUE_NETWORK_ROLE);
210 uniqueResourcePortNetworkRole.put(role, portResourceId);
216 private List<String> getNovaNetworkPortResourceList(String filename, List propertyNetworkValue,
217 GlobalValidationContext globalContext) {
218 globalContext.setMessageCode(ERROR_CODE_NNS14);
219 List<String> portResourceIdList = new ArrayList<>();
220 for (Object propValue : propertyNetworkValue) {
221 Object portPropValue = ((Map) propValue).get("port");
222 Collection<String> portResourceIds = HeatStructureUtil
223 .getReferencedValuesByFunctionName(filename, "get_resource", portPropValue,
225 if (portResourceIds != null) {
226 portResourceIdList.addAll(portResourceIds);
230 return portResourceIdList;
233 private String getNetworkRole(String network) {
234 if (network == null) {
237 if (network.contains("_net_id")) {
238 return network.substring(0, network.indexOf("_net_id"));
239 } else if (network.contains("_net_name")) {
240 return network.substring(0, network.indexOf("_net_name"));
241 } else if (network.contains("_net_fqdn")) {
242 return network.substring(0, network.indexOf("_net_fqdn"));
247 private Map getPortNetwork(String fileName, String resourceId, Resource portResource,
248 GlobalValidationContext globalValidationContext) {
249 Object portNetwork = portResource.getProperties().get("network_id");
250 if (portNetwork == null) {
251 portNetwork = portResource.getProperties().get("network");
253 if (!(portNetwork instanceof Map)) {
254 globalValidationContext.addMessage(
257 ErrorMessagesFormatBuilder
258 .getErrorWithParameters(
259 ERROR_CODE_NNS4, Messages.MISSING_GET_PARAM.getErrorMessage(),
260 "network or network_id", resourceId),
261 LoggerTragetServiceName.VALIDATE_RESOURCE_NETWORK_UNIQUE_ROLW,
262 LoggerErrorDescription.MISSING_GET_PARAM);
265 return (Map) portNetwork;
268 private void validateAvailabilityZoneName(String fileName,
269 Map.Entry<String, Resource> resourceEntry,
270 GlobalValidationContext globalContext) {
271 String[] regexList = new String[]{"availability_zone_(\\d+)"};
273 if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) {
277 Object availabilityZoneMap = resourceEntry.getValue().getProperties()
278 .get(AVAILABILITY_ZONE);
280 if (nonNull(availabilityZoneMap)) {
281 if (availabilityZoneMap instanceof Map) {
282 String availabilityZoneName = ValidationUtil.getWantedNameFromPropertyValueGetParam
283 (availabilityZoneMap);
285 if (availabilityZoneName != null && !ValidationUtil
286 .evalPattern(availabilityZoneName, regexList)) {
287 globalContext.addMessage(
289 ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters(
290 ERROR_CODE_NNS5, Messages.PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES.getErrorMessage(),
291 ValidationUtil.getMessagePartAccordingToResourceType(resourceEntry),
292 "Availability Zone", availabilityZoneName, resourceEntry.getKey()),
293 LoggerTragetServiceName.VALIDATE_AVAILABILITY_ZONE_NAME,
294 LoggerErrorDescription.NAME_NOT_ALIGNED_WITH_GUIDELINES);
297 globalContext.addMessage(
299 ErrorLevel.WARNING, ErrorMessagesFormatBuilder
300 .getErrorWithParameters(
301 ERROR_CODE_NNS6, Messages.MISSING_GET_PARAM.getErrorMessage(),
302 AVAILABILITY_ZONE, resourceEntry.getKey()),
303 LoggerTragetServiceName.VALIDATE_AVAILABILITY_ZONE_NAME,
304 LoggerErrorDescription.MISSING_GET_PARAM);
309 private void validateNovaServerNameImageAndFlavor(String fileName, String envFileName,
310 Map.Entry<String, Resource> resourceEntry,
311 GlobalValidationContext globalContext) {
313 validateNovaServerNamingConvention(fileName, envFileName, resourceEntry, globalContext);
314 Map<String, String> legalNovaNamingConventionMap =
315 validateImageAndFlavorFromNovaServer(fileName, resourceEntry, globalContext);
317 if (Objects.nonNull(novaName)) {
318 legalNovaNamingConventionMap.put("name", novaName);
321 if (legalNovaNamingConventionMap.keySet().size() > 1) {
322 validateNovaServerNameImageAndFlavorSync(fileName, resourceEntry,
323 legalNovaNamingConventionMap, globalContext);
327 private String validateNovaServerNamingConvention(String fileName, String envFileName,
328 Map.Entry<String, Resource> resourceEntry,
329 GlobalValidationContext globalContext) {
330 if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) {
333 return checkIfNovaNameByGuidelines(fileName, envFileName, resourceEntry, globalContext);
336 private Map<String, String> validateImageAndFlavorFromNovaServer(String fileName,
337 Map.Entry<String, Resource> resourceEntry,
338 GlobalValidationContext globalContext) {
339 if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) {
343 Pair<String, String> imagePair = new ImmutablePair<>("image", ".*_image_name");
344 Pair<String, String> flavorPair = new ImmutablePair<>("flavor", ".*_flavor_name");
345 List<Pair<String, String>> imageFlavorPairs = Arrays.asList(imagePair, flavorPair);
346 Map<String, Object> propertiesMap = resourceEntry.getValue().getProperties();
347 Map<String, String> imageAndFlavorLegalNames = new HashMap<>();
349 for (Pair<String, String> imageOrFlavor : imageFlavorPairs) {
350 boolean isErrorInImageOrFlavor =
351 isErrorExistWhenValidatingImageOrFlavorNames(fileName, imageOrFlavor, resourceEntry,
352 propertiesMap, globalContext);
353 if (!isErrorInImageOrFlavor) {
354 Object nameValue = propertiesMap.get(imageOrFlavor.getKey());
355 String imageOrFlavorName = ValidationUtil.getWantedNameFromPropertyValueGetParam
357 imageAndFlavorLegalNames.put(imageOrFlavor.getKey(), imageOrFlavorName);
360 return imageAndFlavorLegalNames;
363 private String checkIfNovaNameByGuidelines(String fileName, String envFileName,
364 Map.Entry<String, Resource> resourceEntry,
365 GlobalValidationContext globalContext) {
366 if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) {
369 Object novaNameGetParam = getNovaServerName(resourceEntry);
370 String novaName = null;
371 if (nonNull(novaNameGetParam)) {
373 checkNovaNameGetParamValueMap(fileName, novaNameGetParam, resourceEntry, globalContext);
374 checkIfNovaNameParameterInEnvIsStringOrList(fileName, envFileName, novaName, resourceEntry,
377 globalContext.addMessage(
379 ErrorLevel.WARNING, ErrorMessagesFormatBuilder
380 .getErrorWithParameters(
381 ERROR_CODE_NNS7, Messages.MISSING_GET_PARAM.getErrorMessage(),
382 "nova server name", resourceEntry.getKey()),
383 LoggerTragetServiceName.VALIDATE_NOVA_SERVER_NAME,
384 LoggerErrorDescription.MISSING_GET_PARAM);
390 private boolean isErrorExistWhenValidatingImageOrFlavorNames(String fileName,
391 Pair<String, String> propertyNameAndRegex,
392 Map.Entry<String, Resource> resourceEntry,
393 Map<String, Object> propertiesMap,
394 GlobalValidationContext globalContext) {
395 String propertyName = propertyNameAndRegex.getKey();
396 Object nameValue = propertiesMap.get(propertyName);
397 String[] regexList = new String[]{propertyNameAndRegex.getValue()};
400 if (nonNull(nameValue)) {
401 if (nameValue instanceof Map) {
402 globalContext.setMessageCode(ERROR_CODE_NNS13);
403 if (ValidationUtil.validateMapPropertyValue(fileName, resourceEntry, globalContext,
405 nameValue, regexList)) {
409 globalContext.addMessage(
411 ErrorLevel.WARNING, ErrorMessagesFormatBuilder
412 .getErrorWithParameters(
413 ERROR_CODE_NNS8, Messages.MISSING_GET_PARAM.getErrorMessage(),
414 propertyName, resourceEntry.getKey()),
415 LoggerTragetServiceName.VALIDATE_IMAGE_AND_FLAVOR_NAME,
416 LoggerErrorDescription.MISSING_GET_PARAM);
425 private Object getNovaServerName(Map.Entry<String, Resource> resourceEntry) {
426 Object novaServerName = resourceEntry.getValue().getProperties().get("name");
428 if (nonNull(novaServerName) && novaServerName instanceof Map) {
429 novaNameMap = (Map) novaServerName;
430 return novaNameMap.get(ResourceReferenceFunctions.GET_PARAM.getFunction());
436 @SuppressWarnings("unchecked")
437 private String checkNovaNameGetParamValueMap(String fileName, Object getParamValue,
438 Map.Entry<String, Resource> resourceEntry,
439 GlobalValidationContext globalContext) {
440 if (getParamValue instanceof List) {
441 List<Object> getParamNameList = (List) getParamValue;
442 String[] regexName = new String[]{".*_names"};
443 return isNovaNameAsListLegal(fileName, regexName, getParamNameList, resourceEntry,
445 } else if (getParamValue instanceof String) {
446 String[] regexName = new String[]{".*_name_(\\d+)"};
447 return isNovaNameAsStringLegal(fileName, (String) getParamValue, regexName, resourceEntry,
454 private void checkIfNovaNameParameterInEnvIsStringOrList(String fileName,
456 String novaServerName,
457 Map.Entry<String, Resource> resourceEntry,
458 GlobalValidationContext globalContext) {
459 if (nonNull(envFileName)) {
460 Environment environment = ValidationUtil.validateEnvContent(envFileName, globalContext);
462 if (environment != null && MapUtils.isNotEmpty(environment.getParameters())) {
463 Object novaServerNameEnvValue = environment.getParameters()
464 .get(novaServerName);
465 if (Objects.nonNull(novaServerNameEnvValue) && !DefinedHeatParameterTypes
466 .isNovaServerEnvValueIsFromRightType(novaServerNameEnvValue)) {
467 globalContext.addMessage(
469 ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters(
470 ERROR_CODE_NNS9, Messages.PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES.getErrorMessage(),
472 novaServerNameEnvValue.toString(), resourceEntry.getKey()),
473 LoggerTragetServiceName.VALIDATE_NOVA_SERVER_NAME,
474 LoggerErrorDescription.NAME_NOT_ALIGNED_WITH_GUIDELINES);
480 private String isNovaNameAsListLegal(String fileName,
482 List<Object> getParamNameList,
483 Map.Entry<String, Resource> resourceEntry,
484 GlobalValidationContext globalContext) {
486 if (getParamNameList.size() != 2 || !ValidationUtil.evalPattern(getParamNameList.get(0),
488 globalContext.addMessage(
491 ErrorMessagesFormatBuilder.getErrorWithParameters(
492 ERROR_CODE_NNS10, Messages.PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES.getErrorMessage(),
494 "name", getParamNameList.toString(), resourceEntry.getKey()),
495 LoggerTragetServiceName.VALIDATE_NOVA_SERVER_NAME,
496 LoggerErrorDescription.NAME_NOT_ALIGNED_WITH_GUIDELINES);
500 return (String) getParamNameList.get(0);
503 private String isNovaNameAsStringLegal(String fileName,
506 Map.Entry<String, Resource> resourceEntry,
507 GlobalValidationContext globalContext) {
508 if (!ValidationUtil.evalPattern(novaName, regexName)) {
509 globalContext.addMessage(
512 ErrorMessagesFormatBuilder.getErrorWithParameters(
513 ERROR_CODE_NNS10, Messages.PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES.getErrorMessage(),
515 "name", novaName, resourceEntry.getKey()),
516 LoggerTragetServiceName.VALIDATE_NOVA_SERVER_NAME,
517 LoggerErrorDescription.NAME_NOT_ALIGNED_WITH_GUIDELINES);
523 private void validateNovaServerNameImageAndFlavorSync(String fileName,
524 Map.Entry<String, Resource> resourceEntry,
525 Map<String, String> legalNovaNamingConventionNames,
526 GlobalValidationContext globalContext) {
527 List<String> vmNames = new LinkedList<>();
529 for (Map.Entry<String, String> nameEntry : legalNovaNamingConventionNames.entrySet()) {
530 vmNames.add(getVmName(nameEntry.getValue(), nameEntry.getKey()));
533 vmNames.removeIf(Objects::isNull);
535 if (!isVmNameSync(vmNames)) {
536 globalContext.addMessage(
539 ErrorMessagesFormatBuilder.getErrorWithParameters(
540 ERROR_CODE_NNS11, Messages.NOVA_NAME_IMAGE_FLAVOR_NOT_CONSISTENT.getErrorMessage(),
541 resourceEntry.getKey()),
542 LoggerTragetServiceName.VALIDATE_IMAGE_AND_FLAVOR_NAME,
543 LoggerErrorDescription.NAME_NOT_ALIGNED_WITH_GUIDELINES);
547 private String getVmName(String nameToGetVmNameFrom, String stringToGetIndexOf) {
549 nameToGetVmNameFrom == null ? -1 : nameToGetVmNameFrom.indexOf(stringToGetIndexOf);
550 String vmName = null;
551 if (nameToGetVmNameFrom != null) {
552 vmName = vmIndex < 0 ? null
553 : trimNonAlphaNumericCharactersFromEndOfString(nameToGetVmNameFrom.substring(0, vmIndex));
558 private boolean isVmNameSync(List<String> namesToCompare) {
559 int size = namesToCompare.size();
560 for (int i = 0; i < size - 1; i++) {
561 if (!namesToCompare.get(i).equals(namesToCompare.get(i + 1))) {
568 private String trimNonAlphaNumericCharactersFromEndOfString(String toTrim) {
569 int stringSize = toTrim.length();
570 int stringLength = stringSize - 1;
571 String[] regexList = new String[]{"[^a-zA-Z0-9]"};
573 while (stringLength >= 0) {
574 if (!ValidationUtil.evalPattern(String.valueOf(toTrim.charAt(stringLength)), regexList)) {
580 return toTrim.substring(0, stringLength + 1);