2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.so.apihandlerinfra.validation;
24 import java.util.HashMap;
26 import org.onap.so.exceptions.ValidationException;
27 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
28 import org.onap.so.utils.UUIDChecker;
30 public class InstanceIdMapValidation implements ValidationRule{
33 public ValidationInformation validate(ValidationInformation info) throws ValidationException{
34 HashMap<String, String> instanceIdMap = info.getInstanceIdMap();
35 ServiceInstancesRequest sir = info.getSir();
36 if(instanceIdMap != null){
37 if(instanceIdMap.get("serviceInstanceId") != null){
38 if (!UUIDChecker.isValidUUID (instanceIdMap.get ("serviceInstanceId"))) {
39 throw new ValidationException ("serviceInstanceId");
41 sir.setServiceInstanceId(instanceIdMap.get("serviceInstanceId"));
44 if(instanceIdMap.get("vnfInstanceId") != null){
45 if (!UUIDChecker.isValidUUID (instanceIdMap.get ("vnfInstanceId"))) {
46 throw new ValidationException ("vnfInstanceId");
48 sir.setVnfInstanceId(instanceIdMap.get("vnfInstanceId"));
51 if(instanceIdMap.get("vfModuleInstanceId") != null){
52 if (!UUIDChecker.isValidUUID (instanceIdMap.get ("vfModuleInstanceId"))) {
53 throw new ValidationException ("vfModuleInstanceId");
55 sir.setVfModuleInstanceId(instanceIdMap.get("vfModuleInstanceId"));
58 if(instanceIdMap.get("volumeGroupInstanceId") != null){
59 if (!UUIDChecker.isValidUUID (instanceIdMap.get ("volumeGroupInstanceId"))) {
60 throw new ValidationException ("volumeGroupInstanceId");
62 sir.setVolumeGroupInstanceId(instanceIdMap.get("volumeGroupInstanceId"));
65 if(instanceIdMap.get("networkInstanceId") != null){
66 if (!UUIDChecker.isValidUUID (instanceIdMap.get ("networkInstanceId"))) {
67 throw new ValidationException ("networkInstanceId");
69 sir.setNetworkInstanceId(instanceIdMap.get("networkInstanceId"));
72 if(instanceIdMap.get("configurationInstanceId") != null){
73 if (!UUIDChecker.isValidUUID (instanceIdMap.get ("configurationInstanceId"))) {
74 throw new ValidationException ("configurationInstanceId");
76 sir.setConfigurationId(instanceIdMap.get("configurationInstanceId"));