Solved

What does this attribute array do in this java code snippet?

Posted on 2007-03-28
3
212 Views
Last Modified: 2010-03-31
What does this attribute array do in this Java Snippet?
public Attribute[] writeSessionLog(Session session) throws ManagementSupportException {

            TEServiceStub.SaveSession request = new TEServiceStub.SaveSession();
            request.setLabID(session.getLabid());
            request.setSessionUID(session.getSessionId());

            //create Attribute from the session
            TEServiceStub.AttributeArray array = new TEServiceStub.AttributeArray();

            TEServiceStub.Attribute hwVersion = new TEServiceStub.Attribute();
            hwVersion.setName("HW_VERSION");
            hwVersion.setValue(session.getHwVersion());
            array.addAttributes(hwVersion);

            TEServiceStub.Attribute startTime = new TEServiceStub.Attribute();
            startTime.setName("START_TIME");
            //FIXME: what format the time should be?
            startTime.setValue(session.getStartTime() == null ? new Date().toString() : session.getStartTime().toString());
            array.addAttributes(startTime);

            TEServiceStub.Attribute finishTime = new TEServiceStub.Attribute();
            finishTime.setName("FINISH_TIME");
            finishTime.setValue(session.getFinishTime() == null ? new Date().toString() : session.getFinishTime().toString());
            array.addAttributes(finishTime);

            TEServiceStub.Attribute tester = new TEServiceStub.Attribute();
            tester.setName("TESTER");
            tester.setValue(session.getTester());
            array.addAttributes(tester);

            TEServiceStub.Attribute testEvent = new TEServiceStub.Attribute();
            testEvent.setName("TEST_EVENT");
            testEvent.setValue(session.getTestEvent());
            array.addAttributes(testEvent);

            TEServiceStub.Attribute testOrg = new TEServiceStub.Attribute();
            testOrg.setName("TEST_ORG");
            testOrg.setValue(session.getTestOrg());
            array.addAttributes(testOrg);

            request.setAttributes(array);

            TEServiceStub.RequestStatus status = null;
            TEServiceStub.SaveSessionResponse response = null;
            try{
                  response = stub.saveSession(request);
                  status = response.getStatus();
            } catch(Exception e) {
                  logger.warn("Fail to call TEService :" + e);
                  throw new ManagementSupportException("Fail to call TEService :" + e);
            }

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

            return cast(response.getAttributes());
      }
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
3 Comments
 
LVL 11

Accepted Solution

by:
elfe69 earned 250 total points
ID: 18814086
I do not know what TEServiceStub does, but as I see, array is used to store an array of attributes in the HTTP session (in order to retrieve those attributes later).
0
 
LVL 37

Assisted Solution

by:zzynx
zzynx earned 250 total points
ID: 18814093
1. All kind of attributes are stored in the array

>> array.addAttributes(hwVersion);
>> ...
>> array.addAttributes(startTime);
>> ...
>> ...
>> array.addAttributes(testOrg);

2. Then the array is set as an attribute on 'request'
    That way all the attributes are passed to the party that made the request

>> request.setAttributes(array);
0
 
LVL 37

Expert Comment

by:zzynx
ID: 18814591
thanx 4 axxepting
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
In this post we will learn different types of Android Layout and some basics of an Android App.
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…

630 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