Fix for Penetration test _ Session and cookie management
[vid.git] / vid-app-common / src / main / java / org / onap / vid / services / LocalWorkflowsServiceImpl.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.vid.services;
21
22 import static java.util.Collections.emptyList;
23
24 import com.google.common.collect.ImmutableList;
25 import com.google.common.collect.ImmutableMap;
26 import java.util.Map;
27 import org.onap.vid.model.LocalWorkflowParameterDefinition;
28 import org.onap.vid.model.LocalWorkflowParameterDefinitions;
29 import org.onap.vid.model.LocalWorkflowType;
30 import org.springframework.stereotype.Service;
31
32 @Service
33 public class LocalWorkflowsServiceImpl implements LocalWorkflowsService {
34
35     Map<String, LocalWorkflowParameterDefinitions> WORKFLOWS_WITH_PARAMETERS = ImmutableMap.<String, LocalWorkflowParameterDefinitions>builder()
36         .put("VNF Scale Out", new LocalWorkflowParameterDefinitions(
37             ImmutableList.of(
38                 new LocalWorkflowParameterDefinition(1, "configurationParameters", "Configuration Parameters", true, LocalWorkflowType.text,".*")
39             )
40         ))
41         .put("VNF In Place Software Update", new LocalWorkflowParameterDefinitions(
42             ImmutableList.of(
43                 new LocalWorkflowParameterDefinition(2, "operationTimeout", "Operations timeout", true, LocalWorkflowType.text,"[0-9]+"),
44                 new LocalWorkflowParameterDefinition(3, "existingSoftwareVersion", "Existing software version", true, LocalWorkflowType.text, "[-a-zA-Z0-9.]+"),
45                 new LocalWorkflowParameterDefinition(4, "newSoftwareVersion", "New software version", true, LocalWorkflowType.text, "[-a-zA-Z0-9.]+")
46             )
47         )).put("PNF Software Upgrade", new LocalWorkflowParameterDefinitions(
48             ImmutableList.of(
49                 new LocalWorkflowParameterDefinition(6, "targetSoftwareVersion", "Target software version", true, LocalWorkflowType.text, "[-a-zA-Z0-9.]+")
50             )
51         ))
52         .put("VNF Config Update", new LocalWorkflowParameterDefinitions(
53             ImmutableList.of(
54                 new LocalWorkflowParameterDefinition(5, "configUpdateFile", "Attach configuration file", true, LocalWorkflowType.FILE, ".*", "Invalid file type. Please select a file with a CSV extension.", "Invalid file structure.", ".csv")
55             )
56         ))
57         .build();
58
59
60     private LocalWorkflowParameterDefinitions defaultEmptyParams() {
61         return new LocalWorkflowParameterDefinitions(emptyList());
62     }
63
64     @Override
65     public LocalWorkflowParameterDefinitions getWorkflowParameterDefinitions(String workflowName) {
66         return WORKFLOWS_WITH_PARAMETERS.getOrDefault(workflowName, defaultEmptyParams());
67     }
68
69 }