GenericUserSessionImpl.java |
1 /* 2 * Copyright 2000-2001,2004 The Apache Software Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.apache.wsrp4j.consumer.driver; 18 19 import java.util.Hashtable; 20 import java.util.Iterator; 21 22 import org.apache.wsrp4j.consumer.GroupSession; 23 import org.apache.wsrp4j.consumer.GroupSessionMgr; 24 import org.apache.wsrp4j.consumer.UserSessionMgr; 25 import org.apache.wsrp4j.exception.WSRPException; 26 27 public abstract class GenericUserSessionImpl extends InitCookieInfoImpl 28 implements UserSessionMgr { 29 30 // ID of the user this session belongs to 31 private String userID = null; 32 33 // ID of the producer this user session is bind to 34 private String producerID = null; 35 36 // mapping access points to hashtable of group sessions 37 protected Hashtable groupSessions = null; 38 39 public GenericUserSessionImpl(String producerID, String userID, 40 String markupURL) throws WSRPException { 41 super(markupURL); 42 this.producerID = producerID; 43 this.userID = userID; 44 } 45 46 /** 47 * Get ID of the user this session is bind to 48 * 49 * @return User ID 50 **/ 51 public String getUserID() { 52 return this.userID; 53 } 54 55 /** 56 * Set the ID of the user this session is bind to 57 * 58 * @param userID ID of the user 59 **/ 60 public void setUserID(String userID) { 61 if (userID != null) { 62 this.userID = userID; 63 } 64 } 65 66 /** 67 * Get ID of the producer this session is bind to 68 * 69 * @return ID of the producer 70 **/ 71 public String getProducerID() { 72 return this.producerID; 73 } 74 75 /** 76 * Set the ID of the producer this session is bind to. 77 * 78 * @param producerID ID of the producer 79 **/ 80 public void setProducerID(String producerID) { 81 this.producerID = producerID; 82 } 83 84 /** 85 * Get the group session for this group ID 86 * 87 * @param groupID ID of the portlet application 88 * @return The a group session for the provided group ID or a new groupSession 89 **/ 90 public abstract GroupSessionMgr getGroupSession(String groupID) 91 throws WSRPException; 92 93 /** 94 * Add a group session to the user session 95 * 96 * @param groupSession A group session 97 **/ 98 public void addGroupSession(GroupSession groupSession) { 99 if (groupSession != null) { 100 this.groupSessions.put(groupSession.getGroupID(), groupSession); 101 } 102 } 103 104 /** 105 * Get all group session 106 * 107 * @return Iterator with all group sessions for the given producer access point 108 **/ 109 public Iterator getAllGroupSessions() { 110 return this.groupSessions.values().iterator(); 111 } 112 113 /** 114 * Remove a group session from the user session 115 * 116 * @param groupID ID of the portlet application 117 **/ 118 public void removeGroupSession(String groupID) { 119 if (groupID != null) { 120 this.groupSessions.remove(groupID); 121 } 122 } 123 124 /** 125 * Remove all group sessions 126 * 127 **/ 128 public void removeAllGroupSessions() { 129 this.groupSessions.clear(); 130 } 131 132 /** 133 * Check if a group session exists for the given group ID 134 * 135 * @param groupID ID of the portlet group 136 * @return True if a group session exists for the provided group ID 137 **/ 138 public boolean existsGroupSession(String groupID) { 139 if (groupID == null) 140 return false; 141 142 return this.groupSessions.containsKey(groupID); 143 } 144 145 protected void setGroupSessionTable(Hashtable groupSessions) { 146 this.groupSessions = groupSessions; 147 } 148 }