2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.aai.schemagen.genxsd;
23 import java.util.HashMap;
24 import java.util.StringTokenizer;
25 import org.apache.commons.lang3.StringUtils;
26 import org.onap.aai.schemagen.GenerateXsd;
28 public class DeleteOperation {
29 private String useOpId;
30 private String xmlRootElementName;
33 private String pathParams;
35 public static HashMap<String, String> deletePaths = new HashMap<String, String>();
37 public DeleteOperation(String useOpId, String xmlRootElementName, String tag, String path,
40 this.useOpId = useOpId;
41 this.xmlRootElementName = xmlRootElementName;
44 this.pathParams = pathParams;
48 public String toString() {
50 st = new StringTokenizer(path, "/");
51 //a valid tag is necessary
52 if (StringUtils.isEmpty(tag)) {
55 if (path.contains("/relationship/")) { // filter paths with relationship-list
58 if (path.endsWith("/relationship-list")) {
61 if (path.startsWith("/search")) {
64 //All Delete operation paths end with "relationship"
65 //or there is a parameter at the end of the path
66 //and there is a parameter in the path
68 if (!path.endsWith("/relationship") && !path.endsWith("}")) {
71 StringBuilder pathSb = new StringBuilder();
72 pathSb.append(" delete:\n");
73 pathSb.append(" tags:\n");
74 pathSb.append(" - ").append(tag).append("\n");
75 pathSb.append(" summary: delete an existing ").append(xmlRootElementName)
78 pathSb.append(" description: delete an existing ").append(xmlRootElementName)
81 pathSb.append(" operationId: delete").append(useOpId).append("\n");
82 pathSb.append(" consumes:\n");
83 pathSb.append(" - application/json\n");
84 pathSb.append(" - application/xml\n");
85 pathSb.append(" produces:\n");
86 pathSb.append(" - application/json\n");
87 pathSb.append(" - application/xml\n");
88 pathSb.append(" responses:\n");
89 pathSb.append(" \"default\":\n");
90 pathSb.append(" ").append(GenerateXsd.getResponsesUrl());
91 pathSb.append(" parameters:\n");
93 pathSb.append(pathParams); // for nesting
94 if (!path.endsWith("/relationship")) {
95 pathSb.append(" - name: resource-version\n");
97 pathSb.append(" in: query\n");
98 pathSb.append(" description: resource-version for concurrency\n");
99 pathSb.append(" required: true\n");
100 pathSb.append(" type: string\n");
102 this.objectPathMapEntry();
103 return pathSb.toString();
106 public String objectPathMapEntry() {
107 if (!path.endsWith("/relationship")) {
108 deletePaths.put(path, xmlRootElementName);
110 return (xmlRootElementName + ":" + path);