2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
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.ccsdk.sli.adaptors.aai;
24 import static org.junit.Assert.assertTrue;
25 import static org.junit.Assert.fail;
28 import java.io.IOException;
29 import java.lang.annotation.Annotation;
30 import java.lang.reflect.Field;
31 import java.lang.reflect.Method;
32 import java.lang.reflect.Modifier;
34 import java.util.ArrayList;
35 import java.util.Arrays;
36 import java.util.HashMap;
37 import java.util.List;
39 import java.util.Scanner;
41 import java.util.Stack;
42 import java.util.UUID;
44 import javax.xml.bind.SchemaOutputResolver;
45 import javax.xml.bind.annotation.XmlElement;
46 import javax.xml.parsers.DocumentBuilder;
47 import javax.xml.parsers.DocumentBuilderFactory;
48 import javax.xml.transform.Result;
49 import javax.xml.transform.stream.StreamResult;
50 import javax.xml.xpath.XPath;
51 import javax.xml.xpath.XPathConstants;
52 import javax.xml.xpath.XPathExpression;
53 import javax.xml.xpath.XPathFactory;
55 import org.apache.commons.lang.RandomStringUtils;
56 import org.apache.commons.lang.StringUtils;
57 import org.junit.AfterClass;
58 import org.junit.BeforeClass;
59 import org.junit.FixMethodOrder;
60 import org.junit.Test;
61 import org.junit.runners.MethodSorters;
62 import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
63 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
64 import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
65 import org.onap.aai.inventory.v19.GenericVnf;
66 import org.slf4j.Logger;
67 import org.slf4j.LoggerFactory;
68 import org.springframework.core.annotation.AnnotationUtils;
69 import org.w3c.dom.Document;
70 import org.w3c.dom.Element;
71 import org.w3c.dom.Node;
72 import org.w3c.dom.NodeList;
74 import com.fasterxml.jackson.annotation.JsonProperty;
75 import com.fasterxml.jackson.databind.ObjectMapper;
78 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
79 public class AutoGeneratedRegressionTest {
82 System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "INFO");
83 System.setProperty(org.slf4j.impl.SimpleLogger.LOG_FILE_KEY, String.format("AutoGeneratedRegressionTest-%d.txt", System.currentTimeMillis()));
85 private static final Logger LOG = LoggerFactory.getLogger(AutoGeneratedRegressionTest.class);
88 protected static AAIClient client;
90 protected Map<String, String> cache = new HashMap<String, String>();
93 public static void setUp() throws Exception {
94 URL url = AAIService.class.getResource(AAIService.AAICLIENT_PROPERTIES);
95 client = new AAIService(url);
96 LOG.info("----------------------- aicAAIResourceTest.setUp -----------------------");
100 public static void tearDown() throws Exception {
102 LOG.info("----------------------- AAIResourceTest.tearDown -----------------------");
107 public void mainLoadTest ()
111 String currentDir = System.getProperty("user.dir");
112 File dir = new File(currentDir);
116 dir = new File(dir, "src/main/resources");
120 // parse the document
121 File file = new File(dir, "aai_schema_v11.xsd");
127 DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
128 DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
129 Document doc = dBuilder.parse(file);
131 Stack<String> stack = new Stack<String>();
132 List<String> commands = new ArrayList<String>();
133 listSubNodes("network", doc, stack, commands);
134 listSubNodes("cloud-infrastructure", doc, stack, commands);
135 listSubNodes("service-design-and-creation", doc, stack, commands);
136 listSubNodes("license-management", doc, stack, commands);
137 listSubNodes("business", doc, stack, commands);
139 String[] requestDefinition = commands.toArray(new String[0]);
140 LOG.info("\n----------------------------");
142 executeTests(requestDefinition);
151 public void testFromFile() {
152 String filename = "testCommands.txt";
153 List<String> lines = new ArrayList<String>();
154 Scanner scanner = null;
157 File testFile = new File(filename);
158 if(!testFile.exists())
160 scanner = new Scanner(testFile);
161 while (scanner.hasNextLine()) {
162 lines.add(scanner.nextLine());
164 } catch (Exception exc) {
171 String[] requestDefinition = lines.toArray(new String[0]);
172 executeTests(requestDefinition);
177 public void test01AutoGeneratedRequest() {
179 String[] requestDefinition = {
180 "save|generic-vnf|generic-vnf.vnf-id:assign:value:adb28ac0-a260-4b7d-9ce5-adf15733c458",
181 "update|generic-vnf|generic-vnf.vnf-id:assign:value:adb28ac0-a260-4b7d-9ce5-adf15733c458",
182 "query|generic-vnf|generic-vnf.vnf-id:assign:value:adb28ac0-a260-4b7d-9ce5-adf15733c458",
183 "delete|generic-vnf|generic-vnf.vnf-id:assign:value:adb28ac0-a260-4b7d-9ce5-adf15733c458"
186 executeTests(requestDefinition);
189 public void executeTests(String[] requestDefinition) {
191 for(String line : requestDefinition){
192 LOG.info("Executing: " + line);
194 // parse request line resource | key structure
195 String[] segments = line.split("\\|");
196 String action = segments[0];
197 String resource = segments[1];
198 String[] tmpKeys = segments[2].split("&");
199 // String array keyStructure can be tmpKey.
200 // options :assign:uuid:cache
205 String localId = null;
207 List<String> keys = new ArrayList<String>();
208 String keyLine = null;
210 for(String instruction : tmpKeys) {
211 String[] parts = instruction.split(":");
212 String identifier = parts[0];
213 String method = parts[2];
215 if(identifier.startsWith(resource)) {
216 localId = identifier;
217 } else if(identifier.startsWith("l-interface") && "l2-bridge-bgf".equals(resource)) {
218 localId = identifier;
219 } else if(identifier.startsWith("l-interface") && "l2-bridge-sbg".equals(resource)) {
220 localId = identifier;
221 } else if("nodes-query".equals(resource)) {
222 localId = identifier;
227 String postProcesss = parts[3];
228 keyLine = processAssign(identifier, method, postProcesss);
229 if(keyLine != null && !keyLine.trim().isEmpty()) {
234 keyLine = processCached(identifier, method);
235 if(keyLine != null && !keyLine.trim().isEmpty()) {
243 List<String> x = Arrays.asList(localId.split("\\."));
246 testAutoGeneratedSaveRequest(resource, keys, x.get(x.size() - 1), cache.get(localId));
249 testAutoGeneratedUpdateRequest(resource, keys, x.get(x.size() - 1), cache.get(localId));
253 test03AutoGeneratedQueryRequest(resource, keys);
256 test03AutoGeneratedDeleteRequest(resource, keys);
265 public void testAutoGeneratedSaveRequest(String resource, List<String> requestKeys, String identifier, String idValue) {
266 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
270 Map<String, String> nameValues = keyToHashMap(StringUtils.join(requestKeys, " AND "), new SvcLogicContext());
271 AAIRequest request = AAIRequest.createRequest(resource, nameValues);
272 Class<AAIDatum> resourceClass = (Class<AAIDatum>) (request==null ? GenericVnf.class : request.getModelClass());
274 Map<String, String> data = new HashMap<String, String>();
276 for(Field field : resourceClass.getDeclaredFields()) {
277 String type = field.getType().getName();
281 type = Boolean.class.getName();
284 type = Integer.class.getName();
287 type = Long.class.getName();
291 if(type.startsWith("java.lang.")){
292 Annotation[] fieldAnnotations = field.getAnnotations();
293 for(int i = 0; i < fieldAnnotations.length; i++) {
294 Annotation a = fieldAnnotations[i];
295 if(a instanceof JsonProperty){
296 JsonProperty pa = (JsonProperty)a;
297 String name = pa.value();
300 case "java.lang.Integer":
301 case "java.lang.Long":
302 value = RandomStringUtils.random(6, false, true);
304 case "java.lang.Boolean":
308 if(name.equals(identifier)) {
311 value = RandomStringUtils.random(10, true, false);
314 data.put(name, value);
316 if(a instanceof javax.xml.bind.annotation.XmlElement) {
317 XmlElement xe = (XmlElement)a;
318 String name = xe.name();
319 if("model-version-id".equals(name)) {
322 if("model-invariant-id".equals(name)) {
325 if("link-type".equals(name)){
326 data.put(name, "roadmTail");
329 if("operational-status".equals(name)){
330 data.put(name, "available");
333 if(name.equals(identifier)) {
334 data.put(name, idValue);
340 case "java.lang.Integer":
341 case "java.lang.Long":
342 value = RandomStringUtils.random(6, false, true);
344 case "java.lang.Boolean":
348 if(name.equals(identifier)) {
351 value = RandomStringUtils.random(10, true, false);
354 data.put(name, value);
360 SvcLogicContext ctx = new SvcLogicContext();
362 data.remove("resource-version");
364 QueryStatus resp = null;
366 //(String resource, boolean force, boolean localOnly, String key, Map<String, String> parms, String prefix, SvcLogicContext ctx)
367 resp = client.save(resource, false, false, StringUtils.join(requestKeys, " AND "), data, "aaidata", ctx);
368 if(resp == QueryStatus.SUCCESS) {
369 LOG.info(String.format("Save %s successfull", resource));
371 LOG.info(String.format("Save %s failed due to : %s", resource, ctx.getAttribute("aaidata.error.message")));
376 LOG.error("Caught exception", e);
377 fail("Caught exception");
381 public void test03AutoGeneratedQueryRequest(String resource, List<String> requestKeys) {
382 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
384 SvcLogicContext ctx = new SvcLogicContext();
388 QueryStatus response = null;
390 response = client.query(resource, false, null, StringUtils.join(requestKeys, " AND "), "aaiTest", null, ctx);
391 if(response == QueryStatus.SUCCESS) {
392 LOG.info(String.format("Query %s successfull", resource));
393 Set<String> tokens = ctx.getAttributeKeySet();
394 Map<String, String> reponseData = new HashMap<String, String>();
396 String responsePrefix = String.format("%s", "aaiTest");
398 for(String token : tokens) {
399 if(token.startsWith(responsePrefix)){
400 reponseData.put(token, ctx.getAttribute(token));
402 LOG.info(String.format("%s = ", token, ctx.getAttribute(token)));
406 LOG.info("AAIResponse: " + response.toString());
407 assertTrue("AAIRequest:"+resource, reponseData.size() > 0);
409 LOG.info(String.format("Query %s failed due to : %s", resource, ctx.getAttribute("aaidata.error.message")));
415 LOG.error("Caught exception", e);
420 public void test03AutoGeneratedDeleteRequest(String resource, List<String> requestKeys) {
421 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
425 SvcLogicContext ctx = new SvcLogicContext();
427 QueryStatus response = null;
429 response = client.delete(resource, StringUtils.join(requestKeys, " AND "), ctx);
430 if(response == QueryStatus.SUCCESS) {
431 LOG.info(String.format("Delete %s successfull", resource));
433 LOG.info(String.format("Delete %s failed due to : %s", resource, ctx.getAttribute("aaiDelete.error.message")));
438 LOG.error("Caught exception", e);
439 fail("Caught exception");
443 public void testAutoGeneratedUpdateRequest(String resource, List<String> requestKeys, String identifier, String idValue) {
444 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
448 Map<String, String> nameValues = keyToHashMap(StringUtils.join(requestKeys, " AND "), new SvcLogicContext());
449 AAIRequest request = AAIRequest.createRequest(resource, nameValues);
450 Class<AAIDatum> resourceClass = (Class<AAIDatum>) (request==null ? GenericVnf.class : request.getModelClass());
452 Map<String, String> data = new HashMap<String, String>();
454 boolean skipFirst = true;
455 boolean breakLoop = false;
456 for(Field field : resourceClass.getDeclaredFields()) {
464 String type = field.getType().getName();
465 if(type.startsWith("java.lang.")){
466 Annotation[] fieldAnnotations = field.getAnnotations();
467 for(int i = 0; i < fieldAnnotations.length; i++) {
468 Annotation a = fieldAnnotations[i];
469 if(a instanceof JsonProperty){
470 JsonProperty pa = (JsonProperty)a;
471 String name = pa.value();
474 case "java.lang.Integer":
475 case "java.lang.Long":
476 value = RandomStringUtils.random(6, false, true);
478 case "java.lang.Boolean":
482 if(name.equals(identifier)) {
485 value = RandomStringUtils.random(10, true, false);
488 data.put(name, value);
491 if(a instanceof javax.xml.bind.annotation.XmlElement) {
492 XmlElement xe = (XmlElement)a;
493 String name = xe.name();
494 if("link-type".equals(name)){
495 data.put(name, "roadmTail");
498 if("operational-status".equals(name)){
499 data.put(name, "available");
504 case "java.lang.Integer":
505 case "java.lang.Long":
506 value = RandomStringUtils.random(6, false, true);
508 case "java.lang.Boolean":
512 if(name.equals(identifier)) {
515 value = RandomStringUtils.random(10, true, false);
518 data.put(name, value);
525 SvcLogicContext ctx = new SvcLogicContext();
527 data.remove("resource-version");
529 QueryStatus resp = null;
531 //client.update("ipsec-configuration", "ipsec-configuration.ipsec-configuration-id = 'testConfigurationId01'", data, "aaiTest", ctx);
532 resp = client.update(resource, StringUtils.join(requestKeys, " AND "), data, "aaidata", ctx);
533 if(resp == QueryStatus.SUCCESS) {
534 LOG.info(String.format("Update %s successfull", resource));
536 LOG.info(String.format("Update %s failed due to : %s", resource, ctx.getAttribute("aaidata.error.message")));
542 LOG.error("Caught exception", e);
543 fail("Caught exception");
547 static ArrayList<Method> findSetters(Class<?> c) {
548 ArrayList<Method> list = new ArrayList<Method>();
549 Method[] methods = c.getDeclaredMethods();
550 for (Method method : methods)
551 if (isGetter(method))
557 public static boolean isGetter(Method method) {
558 if (Modifier.isPublic(method.getModifiers()) &&
559 method.getParameterTypes().length == 0) {
560 if (method.getName().matches("^get[A-Z].*") &&
561 !method.getReturnType().equals(void.class))
563 if (method.getName().matches("^is[A-Z].*") &&
564 method.getReturnType().equals(boolean.class))
570 public static boolean isSetter(Method method) {
571 return Modifier.isPublic(method.getModifiers()) &&
572 method.getReturnType().equals(void.class) &&
573 method.getParameterTypes().length == 1 &&
574 method.getName().matches("^set[A-Z].*");
577 private String processAssign(String identifier, String method, String postProcess) {
579 if("uuid".equals(method)) {
580 value = UUID.randomUUID().toString();
583 if("cache".equals(postProcess)) {
584 cache.put(identifier, value);
587 if("value".equals(method)) {
588 cache.put(identifier, postProcess);
592 String key = String.format("%s = '%s'", identifier, value);
596 private String processCached(String identifier, String method) {
597 String value = cache.get(identifier);
599 String key = String.format("%s = '%s'", identifier, value);
603 protected HashMap<String,String> keyToHashMap(String key, SvcLogicContext ctx) {
608 LOG.debug("Converting key [" + key + "] to where clause");
610 if (key.startsWith("'") && key.endsWith("'")) {
611 key = key.substring(1, key.length() - 1);
613 LOG.debug("Stripped outer single quotes - key is now [" + key + "]");
616 String[] keyTerms = key.split("\\s+");
621 HashMap<String, String> results = new HashMap<String, String>();
623 for (int i = 0; i < keyTerms.length; i++) {
625 if ("and".equalsIgnoreCase(keyTerms[i])
626 || "or".equalsIgnoreCase(keyTerms[i])) {
629 term1 = resolveTerm(keyTerms[i], ctx);
631 } else if (op == null) {
632 if ("==".equals(keyTerms[i])) {
638 term2 = resolveTerm(keyTerms[i], ctx);
639 term2 = term2.trim().replace("'", "").replace("$", "").replace("'", "");
640 results.put(term1, term2);
651 private String resolveTerm(String term, SvcLogicContext ctx) {
656 LOG.debug("resolveTerm: term is " + term);
658 if (term.startsWith("$") && (ctx != null)) {
659 // Resolve any index variables.
661 return ("'" + resolveCtxVariable(term.substring(1), ctx) + "'");
662 } else if (term.startsWith("'") || term.startsWith("\"")) {
665 return (term.replaceAll("-", "_"));
671 private String resolveCtxVariable(String ctxVarName, SvcLogicContext ctx) {
673 if (ctxVarName.indexOf('[') == -1) {
674 // Ctx variable contains no arrays
675 return (ctx.getAttribute(ctxVarName));
678 // Resolve any array references
679 StringBuffer sbuff = new StringBuffer();
680 String[] ctxVarParts = ctxVarName.split("\\[");
681 sbuff.append(ctxVarParts[0]);
682 for (int i = 1; i < ctxVarParts.length; i++) {
683 if (ctxVarParts[i].startsWith("$")) {
684 int endBracketLoc = ctxVarParts[i].indexOf("]");
685 if (endBracketLoc == -1) {
686 // Missing end bracket ... give up parsing
687 LOG.warn("Variable reference " + ctxVarName
688 + " seems to be missing a ']'");
689 return (ctx.getAttribute(ctxVarName));
692 String idxVarName = ctxVarParts[i].substring(1, endBracketLoc);
693 String remainder = ctxVarParts[i].substring(endBracketLoc);
696 sbuff.append(ctx.getAttribute(idxVarName));
697 sbuff.append(remainder);
700 // Index is not a variable reference
702 sbuff.append(ctxVarParts[i]);
706 return (ctx.getAttribute(sbuff.toString()));
710 public void test90QueryTenantRequest()
712 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
717 url = client.requestVserverURLNodeQuery("bpsx0001vm001bps001");
718 url = new URL("https://mtanjv9aaas03.aic.cip.att.com:8443/aai/v4/cloud-infrastructure/tenants/tenant/6b012c07bdf1427190ae58f794a86344/vservers/vserver/5acfe828-82e9-swgk092815-13-4d2c-85bb-9c2c1fafcce6");
719 client.getTenantIdFromVserverUrl(url);
720 } catch (Exception e) {
721 // TODO Auto-generated catch block
726 static class MySchemaOutputResolver extends SchemaOutputResolver {
728 public Result createOutput(String namespaceURI, String suggestedFileName) throws IOException {
729 File file = new File(suggestedFileName);
730 StreamResult result = new StreamResult(file);
731 result.setSystemId(file.getAbsolutePath());
737 private static void listSubNodes(String parent, Document doc, Stack<String> stack, List<String> commands) throws Exception {
738 XPathFactory xFactory = XPathFactory.newInstance();
739 XPath xPath = xFactory.newXPath();
740 String format = "/schema/element[@name='%s']/complexType/sequence/element[@ref]";
742 String path = String.format(format, parent);
744 // XPathExpression exp = xPath.compile("/schema/element[@name='generic-vnf']/complexType/sequence/element[@ref]");
745 XPathExpression exp = xPath.compile(path);
747 NodeList nl = (NodeList)exp.evaluate(doc.getFirstChild(), XPathConstants.NODESET);
748 LOG.debug("Nodes to process : "+nl.getLength());
749 for (int index = 0; index < nl.getLength(); index++) {
751 Node node = nl.item(index);
753 if(!(node instanceof Element))
756 String classAlias = null;
758 if(node.hasAttributes())
760 String nm = ((Element)node).getAttribute("ref");
761 if(nm != null && !nm.isEmpty()) {
762 String[] split = nm.split(":");
763 classAlias = split[split.length - 1];
764 if("relationship-list".equals(classAlias))
766 if("metadata".equals(classAlias))
768 if("classes-of-service".equals(classAlias)) {
769 classAlias = "class-of-service";
770 } else if("l3-interface-ipv4-address-list".equals(classAlias)) {
772 } else if("l3-interface-ipv6-address-list".equals(classAlias)) {
774 } else if("cvlan-tags".equals(classAlias)) {
775 classAlias = "cvlan-tag-entry";
776 } else if("network-policies".equals(classAlias)) {
777 classAlias = "network-policy";
778 } else if("complexes".equals(classAlias)) {
779 classAlias = "complex";
780 } else if("dvs-switches".equals(classAlias)) {
781 classAlias = "dvs-switch";
782 } else if("service-capabilities".equals(classAlias)) {
783 classAlias = "service-capability";
785 classAlias = classAlias.substring(0, classAlias.length() -1);
787 AAIRequest request = AAIRequest.createRequest(classAlias, new HashMap<String, String>());
788 if(request != null) {
789 Class<?> clazz = request.getModelClass();
790 Field[] fieldz = clazz.getDeclaredFields();
791 Field field = fieldz[0];
792 String fieldName = field.getName();
793 XmlElement annotation = field.getAnnotation(XmlElement.class);
795 Map<String, Object> map = AnnotationUtils.getAnnotationAttributes(annotation);
796 String id = (String)map.get("name");
797 if("##default".equals(id)) {
801 if("cloud-region".equals(classAlias)) {
802 String keystring = "cloud-region.cloud-owner:assign:value:att-aic&cloud-region.cloud-region-id:assign:value:AAIAIC25";
803 stack.push(keystring);
804 String[] array = stack.toArray(new String[0]);
805 String key = StringUtils.join(array, "&");
807 String query = String.format("query|%s|%s", classAlias, key);
809 listSubNodes(classAlias, doc, stack, commands);
811 } else if("entitlement".equals(classAlias)) {
812 String keystring = "entitlement.group-uuid:assign:value:"+UUID.randomUUID()+"&entitlement.resource-uuid:assign:value:"+UUID.randomUUID();
813 stack.push(keystring);
814 String[] array = stack.toArray(new String[0]);
815 String key = StringUtils.join(array, "&");
817 String query = String.format("query|%s|%s", classAlias, key);
819 listSubNodes(classAlias, doc, stack, commands);
821 } else if("license".equals(classAlias)) {
822 String keystring = "license.group-uuid:assign:value:"+UUID.randomUUID()+"&license.resource-uuid:assign:value:"+UUID.randomUUID();
823 stack.push(keystring);
824 String[] array = stack.toArray(new String[0]);
825 String key = StringUtils.join(array, "&");
827 String query = String.format("query|%s|%s", classAlias, key);
829 listSubNodes(classAlias, doc, stack, commands);
831 } else if("route-target".equals(classAlias)) {
832 String keystring = "route-target.global-route-target:assign:value:"+UUID.randomUUID()+"&route-target.route-target-role:assign:value:"+UUID.randomUUID();
833 stack.push(keystring);
834 String[] array = stack.toArray(new String[0]);
835 String key = StringUtils.join(array, "&");
837 String query = String.format("query|%s|%s", classAlias, key);
839 listSubNodes(classAlias, doc, stack, commands);
841 } else if("service-capability".equals(classAlias)) {
842 String keystring = "service-capability.service-type:assign:value:"+UUID.randomUUID()+"&service-capability.vnf-type:assign:value:"+UUID.randomUUID();
843 stack.push(keystring);
844 String[] array = stack.toArray(new String[0]);
845 String key = StringUtils.join(array, "&");
847 String query = String.format("query|%s|%s", classAlias, key);
849 listSubNodes(classAlias, doc, stack, commands);
851 } else if("ctag-pool".equals(classAlias)) {
852 String keystring = "ctag-pool.target-pe:assign:value:"+UUID.randomUUID()+"&ctag-pool.availability-zone-name:assign:value:"+UUID.randomUUID();
853 stack.push(keystring);
854 String[] array = stack.toArray(new String[0]);
855 String key = StringUtils.join(array, "&");
857 String query = String.format("query|%s|%s", classAlias, key);
859 listSubNodes(classAlias, doc, stack, commands);
862 String keystring = String.format("%s.%s:assign:value:%s", classAlias, id, UUID.randomUUID());
863 stack.push(keystring);
864 String[] array = stack.toArray(new String[0]);
865 String key = StringUtils.join(array, "&");
867 String save = String.format("save|%s|%s", classAlias, key);
870 String query = String.format("query|%s|%s", classAlias, key);
873 String update = String.format("update|%s|%s", classAlias, key);
874 commands.add(update);
876 if(!parent.equals(classAlias) && !containsCircular(classAlias, id, stack)) {
877 listSubNodes(classAlias, doc, stack, commands);
879 String delete = String.format("delete|%s|%s", classAlias, key);
880 commands.add(delete);
889 public static boolean containsCircular(String classAlias, String id, Stack<String> stack) {
890 String keystring = String.format("%s.%s", classAlias, id);
892 Stack<String> localStack = new Stack<String>();
893 localStack.addAll(stack);
897 while(!localStack.isEmpty()) {
898 String instruction = localStack.pop();
899 if(instruction.contains(keystring)) {