summaryrefslogtreecommitdiffstats
path: root/aai-core/src/main/java
diff options
context:
space:
mode:
authorasgar <sammoham@in.ibm.com>2018-08-21 18:46:45 +0530
committerasgar <sammoham@in.ibm.com>2018-08-21 18:47:28 +0530
commit3b0d3167a2ad458bbe59e0f703b40ef4f4976424 (patch)
tree6f1d458201ddc64b3f498b06a448122184aebc04 /aai-core/src/main/java
parentac93ec514da91f8918d1fc93e334aa939af767f3 (diff)
Sonar issue fixes for PutOperation.java
Issue-ID: AAI-1525 Change-Id: I34e8618223c5ca4aeefbc37dc148b556877f444e Signed-off-by: Mohamed Asgar Samiulla <sammoham@in.ibm.com>
Diffstat (limited to 'aai-core/src/main/java')
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/genxsd/PutOperation.java167
1 files changed, 84 insertions, 83 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/util/genxsd/PutOperation.java b/aai-core/src/main/java/org/onap/aai/util/genxsd/PutOperation.java
index 16bbc2c7..cb5e779e 100644
--- a/aai-core/src/main/java/org/onap/aai/util/genxsd/PutOperation.java
+++ b/aai-core/src/main/java/org/onap/aai/util/genxsd/PutOperation.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright © 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -18,96 +20,95 @@
* ============LICENSE_END=========================================================
*/
package org.onap.aai.util.genxsd;
-import java.util.StringTokenizer;
import org.apache.commons.lang3.StringUtils;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.util.GenerateXsd;
public class PutOperation {
- private String useOpId;
- private String xmlRootElementName;
- private String tag;
- private String path;
- private String pathParams;
- private SchemaVersion version;
+ public static final String RELATIONSHIP = "relationship";
+ private String useOpId;
+ private String xmlRootElementName;
+ private String tag;
+ private String path;
+ private String pathParams;
+ private SchemaVersion version;
- public PutOperation(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, SchemaVersion v) {
- super();
- this.useOpId = useOpId;
- this.xmlRootElementName = xmlRootElementName;
- this.tag = tag;
- this.path = path;
- this.pathParams = pathParams;
- this.version = v;
- }
+ public PutOperation(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, SchemaVersion v) {
+ super();
+ this.useOpId = useOpId;
+ this.xmlRootElementName = xmlRootElementName;
+ this.tag = tag;
+ this.path = path;
+ this.pathParams = pathParams;
+ this.version = v;
+ }
- @Override
- public String toString() {
- StringTokenizer st = new StringTokenizer(path, "/");
- //a valid tag is necessary
- if ( StringUtils.isEmpty(tag) ) {
- return "";
- }
- //All Put operation paths end with "relationship"
- //or there is a parameter at the end of the path
- //and there is a parameter in the path
- if ( path.contains("/relationship/") ) { // filter paths with relationship-list
- return "";
- }
- if ( path.endsWith("/relationship-list")) {
- return "";
- }
- if ( !path.endsWith("/relationship") && !path.endsWith("}") ) {
- return "";
- }
- if ( path.startsWith("/search")) {
- return "";
- }
- StringBuffer pathSb = new StringBuffer();
- StringBuffer relationshipExamplesSb = new StringBuffer();
- if ( path.endsWith("/relationship") ) {
- pathSb.append(" " + path + ":\n" );
- }
- pathSb.append(" put:\n");
- pathSb.append(" tags:\n");
- pathSb.append(" - " + tag + "\n");
+ @Override
+ public String toString() {
+ //a valid tag is necessary
+ if ( StringUtils.isEmpty(tag) ) {
+ return "";
+ }
+ //All Put operation paths end with "relationship"
+ //or there is a parameter at the end of the path
+ //and there is a parameter in the path
+ if ( path.contains("/"+RELATIONSHIP+"/") ) { // filter paths with relationship-list
+ return "";
+ }
+ if ( path.endsWith("/"+RELATIONSHIP+"-list")) {
+ return "";
+ }
+ if ( !path.endsWith("/"+RELATIONSHIP) && !path.endsWith("}") ) {
+ return "";
+ }
+ if ( path.startsWith("/search")) {
+ return "";
+ }
+ StringBuffer pathSb = new StringBuffer();
+ StringBuffer relationshipExamplesSb = new StringBuffer();
+ if ( path.endsWith("/"+RELATIONSHIP) ) {
+ pathSb.append(" " + path + ":\n" );
+ }
+ pathSb.append(" put:\n");
+ pathSb.append(" tags:\n");
+ pathSb.append(" - " + tag + "\n");
- if ( path.endsWith("/relationship") ) {
- pathSb.append(" summary: see node definition for valid relationships\n");
- } else {
- pathSb.append(" summary: create or update an existing " + xmlRootElementName + "\n");
- pathSb.append(" description: |\n Create or update an existing " + xmlRootElementName + ".\n #\n Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement. An example can be found in the [PATCH section] below\n");
- }
- relationshipExamplesSb.append("[Valid relationship examples shown here](apidocs/relations/"+version.toString()+"/"+useOpId.replace("RelationshipListRelationship", "")+".json)");
- pathSb.append(" operationId: createOrUpdate" + useOpId + "\n");
- pathSb.append(" consumes:\n");
- pathSb.append(" - application/json\n");
- pathSb.append(" - application/xml\n");
- pathSb.append(" produces:\n");
- pathSb.append(" - application/json\n");
- pathSb.append(" - application/xml\n");
- pathSb.append(" responses:\n");
- pathSb.append(" \"default\":\n");
- pathSb.append(" " + GenerateXsd.getResponsesUrl());
-
- pathSb.append(" parameters:\n");
- pathSb.append(pathParams); // for nesting
- pathSb.append(" - name: body\n");
- pathSb.append(" in: body\n");
- pathSb.append(" description: " + xmlRootElementName + " object that needs to be created or updated. "+relationshipExamplesSb.toString()+"\n");
- pathSb.append(" required: true\n");
- pathSb.append(" schema:\n");
- pathSb.append(" $ref: \"#/definitions/" + xmlRootElementName + "\"\n");
- this.tagRelationshipPathMapEntry();
- return pathSb.toString();
- }
+ if ( path.endsWith("/"+RELATIONSHIP) ) {
+ pathSb.append(" summary: see node definition for valid relationships\n");
+ } else {
+ pathSb.append(" summary: create or update an existing " + xmlRootElementName + "\n");
+ pathSb.append(" description: |\n Create or update an existing " + xmlRootElementName + ".\n #\n Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement. An example can be found in the [PATCH section] below\n");
+ }
+ relationshipExamplesSb.append("[Valid relationship examples shown here](apidocs/relations/"+version.toString()+"/"+useOpId.replace("RelationshipListRelationship", "")+".json)");
+ pathSb.append(" operationId: createOrUpdate" + useOpId + "\n");
+ pathSb.append(" consumes:\n");
+ pathSb.append(" - application/json\n");
+ pathSb.append(" - application/xml\n");
+ pathSb.append(" produces:\n");
+ pathSb.append(" - application/json\n");
+ pathSb.append(" - application/xml\n");
+ pathSb.append(" responses:\n");
+ pathSb.append(" \"default\":\n");
+ pathSb.append(" " + GenerateXsd.getResponsesUrl());
+
+ pathSb.append(" parameters:\n");
+ pathSb.append(pathParams); // for nesting
+ pathSb.append(" - name: body\n");
+ pathSb.append(" in: body\n");
+ pathSb.append(" description: " + xmlRootElementName + " object that needs to be created or updated. "+relationshipExamplesSb.toString()+"\n");
+ pathSb.append(" required: true\n");
+ pathSb.append(" schema:\n");
+ pathSb.append(" $ref: \"#/definitions/" + xmlRootElementName + "\"\n");
+ this.tagRelationshipPathMapEntry();
+ return pathSb.toString();
+ }
- public String tagRelationshipPathMapEntry() {
- if ( path.endsWith("/relationship") ) {
- PutRelationPathSet.add(useOpId, path);
- }
- return "";
- }
-
- } \ No newline at end of file
+ public String tagRelationshipPathMapEntry() {
+ if ( path.endsWith("/"+RELATIONSHIP) ) {
+ PutRelationPathSet.add(useOpId, path);
+ }
+ return "";
+ }
+
+ } \ No newline at end of file