Solved

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

Posted on 2007-03-28
3
203 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
  • 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

707 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

11 Experts available now in Live!

Get 1:1 Help Now