Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping3 challenge 14 70
t-sql sp_addlinkedserver possible risks 3 54
hibernate insert example 13 15
Python 3.5.2 32 virtualenv problems 3 15
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…
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 tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

863 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

21 Experts available now in Live!

Get 1:1 Help Now