Solved

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

Posted on 2007-03-28
2
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

728 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