Solved

How do these two functions work?

Posted on 2007-03-29
1
240 Views
Last Modified: 2010-03-31
Could someone show me how this code works or add some comments to it?
public String populateTreeAsXML() throws ManagementSupportException {
            StringBuffer buffer = new StringBuffer();
            long[] projectIds = this.getProjects();
            for(long id : projectIds) {
                  buffer.append(this.populateTreeAsXML(id)).append("\n");
            }
            return buffer.toString();
      }

      public String populateTreeAsXML(long nodeId) throws ManagementSupportException {
            TEServiceStub.GetProjectTree request = new TEServiceStub.GetProjectTree();

            request.setNodeID(nodeId);

            TEServiceStub.GetProjectTreeResponse response = null;
            try {
                  response = stub.getProjectTree(request);
            } catch (RemoteException e) {
                  logger.warn("Fail to call TEService :" + e);
                  throw new ManagementSupportException("Fail to call TEService :" + e);
            }

            if(!response.getStatus().getSuccess()) {
                  logger.warn("TEService return failure while call saveTestLog()");
                  throw new ManagementSupportException("TEService return failure while call saveTestLog()");
            }

            return response.getOMElement(TEServiceStub.GetProjectTreeResponse.MY_QNAME, OMAbstractFactory.getOMFactory()).toString();
      }
0
Comment
Question by:yankeebushsoftware
1 Comment
 
LVL 30

Accepted Solution

by:
mayankeagle earned 500 total points
ID: 18818990
public String populateTreeAsXML() throws ManagementSupportException {
            StringBuffer buffer = new StringBuffer(); // create a new string buffer
            long[] projectIds = this.getProjects(); // get the project IDs in an array
            for(long id : projectIds) { // iterate through the array
                  // append the ID after populating the tree as XML, followed by new line
                  buffer.append(this.populateTreeAsXML(id)).append("\n");
            }
            // return the string contents
            return buffer.toString();
      }

      public String populateTreeAsXML(long nodeId) throws ManagementSupportException {
            TEServiceStub.GetProjectTree request = new TEServiceStub.GetProjectTree(); // create a new tree or tree node, I guess

            request.setNodeID(nodeId); // set the node ID for the tree or tree node

            TEServiceStub.GetProjectTreeResponse response = null;
            try {
                  // probably invoke a web service or something with the request
                  // and obtain a response
                  response = stub.getProjectTree(request);
            } catch (RemoteException e) {
                  logger.warn("Fail to call TEService :" + e);
                  throw new ManagementSupportException("Fail to call TEService :" + e);
            }

            // if the status is not success, throw an exception
            if(!response.getStatus().getSuccess()) {
                  logger.warn("TEService return failure while call saveTestLog()");
                  throw new ManagementSupportException("TEService return failure while call saveTestLog()");
            }

            return response.getOMElement(TEServiceStub.GetProjectTreeResponse.MY_QNAME, OMAbstractFactory.getOMFactory()).toString(); // return the OM element
      }
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now