Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do these two functions work?

Posted on 2007-03-29
1
Medium Priority
?
253 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
[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
1 Comment
 
LVL 30

Accepted Solution

by:
Mayank S earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This video teaches viewers about errors in exception handling.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

704 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