Java Reference
In-Depth Information
52. Contact contact = (Contact)editContacts.get(new Long(sessionID));
53. if (contact == null){
54. throw new SessionException("You must select a contact before removing an address",
55. SessionException.CONTACT_SELECT_REQUIRED);
56. }
57. if (addresses.indexOf(address) == -1){
58. throw new SessionException("There is no record of this address",
59. SessionException.ADDRESS_DOES_NOT_EXIST);
60. }
61. contact.removeAddress(address);
62. return sessionID;
63. }
64.
65. public static long finalizeContact(long sessionID) throws SessionException{
66. if (sessionID <= NO_SESSION_ID){
67. throw new SessionException("A valid session ID is required to finalize a contact",
68.
SessionException.SESSION_ID_REQUIRED);
69. }
70. Contact contact = (Contact)editContacts.get(new Long(sessionID));
71. if (contact == null){
72. throw new SessionException("You must select and edit a contact before committing
changes",
73. SessionException.CONTACT_SELECT_REQUIRED);
74. }
75. editContacts.remove(new Long(sessionID));
76. return NO_SESSION_ID;
77. }
78.
79. private static long getSessionID(){
80. return nextSessionID++;
81. }
82.
83. public static ArrayList getContacts(){ return contacts; }
84. public static ArrayList getAddresses(){ return addresses; }
85. public static ArrayList getEditContacts(){ return new ArrayList( editContacts.values()); }
86. }
SessionServerDelegate generates a session ID for clients when they perform their first operation, adding a
Contact. Subsequent operations on the Contact's addresses require the session ID, since the ID is used to
associate the addresses with a specific Contact within the SessionServerDelegate .
 
Search WWH ::




Custom Search