1 17 package org.alfresco.filesys.smb.server.notify; 18 19 import java.util.Vector ; 20 21 import org.alfresco.filesys.server.filesys.NetworkFile; 22 import org.alfresco.filesys.smb.server.SMBSrvSession; 23 24 27 public class NotifyRequestList 28 { 29 30 32 private Vector <NotifyRequest> m_requests; 33 34 37 public NotifyRequestList() 38 { 39 m_requests = new Vector <NotifyRequest>(); 40 } 41 42 48 public final synchronized NotifyRequest getRequest(int idx) 49 { 50 51 53 if (idx >= m_requests.size()) 54 return null; 55 56 58 return (NotifyRequest) m_requests.elementAt(idx); 59 } 60 61 67 public final synchronized int getGlobalFilter() 68 { 69 70 72 int filter = 0; 73 74 if (m_requests.size() > 0) 75 { 76 77 79 for (int i = 0; i < m_requests.size(); i++) 80 { 81 NotifyRequest req = m_requests.get(i); 82 filter |= req.getFilter(); 83 } 84 } 85 86 88 return filter; 89 } 90 91 96 public final synchronized void addRequest(NotifyRequest req) 97 { 98 m_requests.addElement(req); 99 } 100 101 110 public final synchronized NotifyRequest findRequest(int mid, int tid, int uid, int pid) 111 { 112 113 115 for (int i = 0; i < m_requests.size(); i++) 116 { 117 118 120 NotifyRequest curReq = (NotifyRequest) m_requests.elementAt(i); 121 if (curReq.getMultiplexId() == mid && curReq.getTreeId() == tid && curReq.getUserId() == uid 122 && curReq.getProcessId() == pid) 123 { 124 125 127 return curReq; 128 } 129 } 130 131 133 return null; 134 } 135 136 143 public final synchronized NotifyRequest findRequest(NetworkFile dir, int filter, boolean watchTree) 144 { 145 146 148 for (int i = 0; i < m_requests.size(); i++) 149 { 150 151 153 NotifyRequest curReq = (NotifyRequest) m_requests.elementAt(i); 154 if (curReq.getDirectory() == dir && curReq.getFilter() == filter && curReq.hasWatchTree() == watchTree) 155 { 156 157 159 return curReq; 160 } 161 } 162 163 165 return null; 166 } 167 168 173 public final synchronized NotifyRequest removeRequest(NotifyRequest req) 174 { 175 176 178 for (int i = 0; i < m_requests.size(); i++) 179 { 180 181 183 NotifyRequest curReq = (NotifyRequest) m_requests.elementAt(i); 184 if (curReq == req) 185 { 186 187 189 m_requests.removeElementAt(i); 190 return curReq; 191 } 192 } 193 194 196 return null; 197 } 198 199 204 public final synchronized NotifyRequest removeRequestAt(int idx) 205 { 206 207 209 if (idx < 0 || idx >= m_requests.size()) 210 return null; 211 212 214 NotifyRequest req = (NotifyRequest) m_requests.elementAt(idx); 215 m_requests.removeElementAt(idx); 216 return req; 217 } 218 219 224 public final synchronized void removeAllRequestsForSession(SMBSrvSession sess) 225 { 226 227 229 int idx = 0; 230 231 while (idx < m_requests.size()) 232 { 233 234 236 NotifyRequest curReq = (NotifyRequest) m_requests.elementAt(idx); 237 if (curReq.getSession() == sess) 238 { 239 240 242 m_requests.removeElementAt(idx); 243 } 244 else 245 idx++; 246 } 247 } 248 249 255 public final synchronized void removeAllRequestsForSession(SMBSrvSession sess, int tid) 256 { 257 258 260 int idx = 0; 261 262 while (idx < m_requests.size()) 263 { 264 265 267 NotifyRequest curReq = (NotifyRequest) m_requests.elementAt(idx); 268 if (curReq.getSession() == sess && curReq.getTreeId() == tid) 269 { 270 271 273 m_requests.removeElementAt(idx); 274 } 275 else 276 idx++; 277 } 278 } 279 280 283 public final synchronized void clearRequestList() 284 { 285 m_requests.removeAllElements(); 286 } 287 288 293 public final synchronized int numberOfRequests() 294 { 295 return m_requests.size(); 296 } 297 } 298 | Popular Tags |