Solved

Please comment this code so I can understand it...

Posted on 2007-03-28
2
194 Views
Last Modified: 2010-03-31
Would someone comment this code so I can understand it?
import org.muos.management.managementSupport.Attribute;
import org.muos.management.managementSupport.Lab;
import org.muos.management.managementSupport.ManagementSupport;
import org.muos.management.managementSupport.ManagementSupportException;
import org.muos.management.managementSupport.ManagementSupportFactory;
import org.muos.management.managementSupport.RequirementVerificationID;
import org.muos.management.managementSupport.Tree;


public class SampleCode {

      /**
       * @param args
       */
      public static void main(String[] args) {
            String serviceLocation = "http://localhost:8080/axis2/services/TEService";
            ManagementSupport supporter = null;
            try {
                  supporter = ManagementSupportFactory.getManagementSupport(serviceLocation);
            } catch (ManagementSupportException e) {
                  //If can not initialize the TEServiceStub, do something here
                  e.printStackTrace();
            }

            if(supporter == null) {
                  return;
            }

            /*
             * Sample of deleteLab,
             */
            try {
                  supporter.deleteLab(123L);
                  //delete success
            } catch (ManagementSupportException e) {
                  //delete fail
                  e.printStackTrace();
            }

            /*
             * GetLabAttribute()
             */
            try {
                  String attribute = supporter.getLabAttribute(123L, "lab_attribute_name");
                  //Successfully get the attribute
                  System.out.println(attribute);
            } catch (ManagementSupportException e) {
                  //Fail
                  e.printStackTrace();
            }

            try {
                  String attribute = supporter.getLabChangeAttribute(1234L, "attribute_name");
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] labIds = supporter.getLabChanges();
                  for(long id : labIds) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] ids = supporter.getLabChangesByLab(123L); //LabId
                  for(long id : ids) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] ids = supporter.getLabChangesByNode(1234L);//NodeId
                  for(long id :ids) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] ids = supporter.getLabs();
                  for(long id : ids)  {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  String value = supporter.getNodeAttribute(1234L, "attribute_name");
                  System.out.println(value);
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] ids = supporter.getNodeChildren(1234L);
                  for(long id : ids) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  String value = supporter.getProjectAttribute(1234L, "attriubte_name");
                  System.out.println(value);
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] ids = supporter.getProjects();
                  for(long id : ids) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  String value = supporter.getRequirementVerificationAttribute("requirementId", 123L, "attibute_name");
                  System.out.println(value);
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  RequirementVerificationID[]  ids = supporter.getRequirementVerifications(1243L);
                  for(RequirementVerificationID id : ids) {
                        System.out.println(id.getRequirementId());
                        System.out.println(id.getTestLogId());
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] nodeIds = supporter.getRootNodes(1244L);
                  for(long id : nodeIds) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  String value = supporter.getSessionAttribute(134L, "attribute_name");
                  System.out.println(value);
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] sessionIds = supporter.getSessions();
                  for(long id : sessionIds) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  String xml = supporter.getSTDTree();
                  System.out.println(xml);
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  String value = supporter.getTestLogAttribute(1234L, "attribute_name");
                  System.out.println(value);
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] testlogIds = supporter.getTestLogs();
                  for(long id : testlogIds) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] ids = supporter.getTestLogsByNode(1345L);
                  for(long id : ids) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            Lab lab = new Lab();
            lab.setDescription("This is a lab");
            lab.setId(4564L);
            lab.setLocation("Where the lab is");
            lab.setOwner("who the owner is");
            try {
                  Attribute[] attributes = supporter.saveLab(lab);
                  for(Attribute attr : attributes) {
                        System.out.println("name :" + attr.getName() + " ; value = " + attr.getValue());
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            Attribute[] labChangeAttributes = new Attribute[2];
            Attribute attr1 = new Attribute();
            attr1.setName("attributeName");
            attr1.setValue("attributeValue");
            Attribute attr2 = new Attribute();
            attr2.setName("attributeName");
            attr2.setValue("attributeValue");
            labChangeAttributes[0] = attr1;
            labChangeAttributes[1] = attr2;
            try {
                  Attribute[] returnedAttributes = supporter.saveLabChange("test log UID", labChangeAttributes);
                  for(Attribute attr : returnedAttributes) {
                        System.out.println("name :" + attr.getName() + " ; value = " + attr.getValue());
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            Attribute[] requirementVerificationAttributes = new Attribute[2];
            attr1 = new Attribute();
            attr1.setName("attributeName");
            attr1.setValue("attributeValue");
            attr2 = new Attribute();
            attr2.setName("attributeName");
            attr2.setValue("attributeValue");
            labChangeAttributes[0] = attr1;
            labChangeAttributes[1] = attr2;
            try {
                  Attribute[] returnedAttributes = supporter.saveRequirementVerification("RequirementId", "testLogUID", requirementVerificationAttributes);
                  for(Attribute attr : returnedAttributes) {
                        System.out.println("name :" + attr.getName() + " ; value = " + attr.getValue());
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            Attribute[] sessionAttibutes = new Attribute[2];
            attr1 = new Attribute();
            attr1.setName("attributeName");
            attr1.setValue("attributeValue");
            attr2 = new Attribute();
            attr2.setName("attributeName");
            attr2.setValue("attributeValue");
            labChangeAttributes[0] = attr1;
            labChangeAttributes[1] = attr2;
            try {
                  Attribute[] returnedAttributes = supporter.saveSession(123L, "sessionUID", sessionAttibutes);
                  for(Attribute attr : returnedAttributes) {
                        System.out.println("name :" + attr.getName() + " ; value = " + attr.getValue());
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            Attribute[] testLogSession = new Attribute[2];
            attr1 = new Attribute();
            attr1.setName("attributeName");
            attr1.setValue("attributeValue");
            attr2 = new Attribute();
            attr2.setName("attributeName");
            attr2.setValue("attributeValue");
            labChangeAttributes[0] = attr1;
            labChangeAttributes[1] = attr2;
            try {
                  Attribute[] returnedAttributes = supporter.saveTestLog("sessionUID", "testLogUID", testLogSession);
                  for(Attribute attr : returnedAttributes) {
                        System.out.println("name :" + attr.getName() + " ; value = " + attr.getValue());
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  Tree tree = supporter.populateTree(1234L);
                  System.out.println(tree.getNode().getNodeId());
                  for(Attribute att : tree.getNode().getAttributes()) {
                        System.out.println(att.getName());
                        System.out.println(att.getValue());
                  }
                  System.out.println("has children : "  + tree.getChildren().size());
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }
      }

}
0
Comment
Question by:yankeebushsoftware
2 Comments
 
LVL 6

Expert Comment

by:_iskywalker_
ID: 18814648
first we must know what is the
org.muos.management.managementSupport
since most of functions are from it and the rest is documented.
0
 
LVL 8

Accepted Solution

by:
reach2piyush earned 500 total points
ID: 18814731
//Looks like you got a web service with the following address
String serviceLocation = "http://localhost:8080/axis2/services/TEService";

//ManagementSupportFactory class looks like a utility class to connect to that Web Service ^ returns you a stub to call methods on that Web service
supporter = ManagementSupportFactory.getManagementSupport(serviceLocation);

// The following piece of code  along with all other subsequent similar code demonstrate/test a business method call to the above mentioned web-service,
Each call is enclosed in a separate try-catch loop, this will ensure that the program will continue even if any of the calls fails.  
/*
* Sample of deleteLab,
*/
try {
supporter.deleteLab(123L);
//delete success
} catch (ManagementSupportException e) {
//delete fail
e.printStackTrace();
}
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 104
Problem to open text file 11 128
java stored proc example 9 44
maven not picking latest jar instead picking old jar from .m2 12 17
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question