blob: 550db19af4bca2f9e3d89075d781e17549ee09d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package org.onap.so.apihandlerinfra.infra.rest.validators;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern;
import org.onap.so.apihandlerinfra.Action;
import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class VolumeGroupDeleteValidator implements RequestValidator {
@Autowired
AAIDataRetrieval aaiDataRetrieval;
@Override
public boolean shouldRunFor(String requestUri, ServiceInstancesRequest request, Actions action) {
return Pattern.compile("[Vv][5-8]/serviceInstances/[^/]+/volumeGroups/[^/]+").matcher(requestUri).matches()
&& action.equals(Action.deleteInstance);
}
@Override
public Optional<String> validate(Map<String, String> instanceIdMap, ServiceInstancesRequest request,
Map<String, String> queryParams, Actions action) {
if (aaiDataRetrieval.isVolumeGroupRelatedToVFModule(instanceIdMap.get("volumeGroupInstanceId"))) {
return Optional.of("Cannot delete volume group it is related to existing vf-modules");
} else {
return Optional.empty();
}
}
}
|