1 18 package sync4j.framework.server.session; 19 20 import java.util.ArrayList ; 21 import java.util.LinkedList ; 22 import java.util.List ; 23 24 import sync4j.framework.core.*; 25 import sync4j.framework.engine.dm.DeviceDMState; 26 import sync4j.framework.security.SecurityConstants; 27 import sync4j.framework.security.Sync4jPrincipal; 28 import sync4j.framework.server.SyncTimestamp; 29 import sync4j.framework.server.Sync4jDevice; 30 import sync4j.framework.protocol.ProtocolUtil; 31 import sync4j.framework.core.dm.ddf.DevInfo; 32 33 34 40 public class ManagementState 41 implements SecurityConstants { 42 43 45 47 50 private ArrayList clientCommands; 51 52 54 57 public Replace devInfReplaceCommand; 58 59 62 public DevInf deviceInfo; 63 64 67 public Sync4jDevice device; 68 69 72 public DeviceDMState dmstate; 73 74 77 public String sessionId; 78 79 82 public Cred loggedCredential; 83 84 87 public Sync4jPrincipal loggedPrincipal; 88 89 92 public String lastMsgIdFromClient; 93 94 97 public SyncTimestamp lastTimestamp; 98 99 102 public SyncTimestamp nextTimestamp; 103 104 113 public int authenticationState; 114 115 123 public int serverAuthenticationState; 124 125 128 public int type; 129 130 133 public boolean started; 134 135 136 139 public String syncMLVerProto; 140 141 142 145 private long maxMsgSize = 0; 146 public void setMaxMsgSize(long value) { 147 maxMsgSize = value; 148 } 149 150 public long getMaxMsgSize() { 151 return maxMsgSize; 152 } 153 154 157 private long maxObjSize = 0; 158 public long getMaxObjSize() { 159 return this.maxObjSize; 160 } 161 public void setMaxObjSize(long maxObjSize) { 162 this.maxObjSize = maxObjSize; 163 } 164 165 166 169 private long overheadHdr = 0; 170 public long getOverheadHdr() { 171 return this.overheadHdr; 172 } 173 public void setOverheadHdr(long overheadHdr) { 174 this.overheadHdr = overheadHdr; 175 } 176 177 178 181 private LinkedList listStatusCmdOut = new LinkedList (); 182 183 public void addStatusCmdOut(List statusList) { 184 listStatusCmdOut.addAll(statusList); 185 } 186 187 public LinkedList getStatusCmdOut() { 188 return listStatusCmdOut; 189 } 190 191 public void removeStatusCmdOut(List statusCommand) { 192 listStatusCmdOut.removeAll(statusCommand); 193 } 194 195 196 199 private LinkedList listAlertCmdOut = new LinkedList (); 200 201 public void addAlertCmdOut(List alertList) { 202 listAlertCmdOut.addAll(alertList); 203 } 204 205 public LinkedList getAlertCmdOut() { 206 return listAlertCmdOut; 207 } 208 209 public void removeAlertCmdOut(List alertList) { 210 listAlertCmdOut.removeAll(alertList); 211 } 212 213 214 217 private AbstractCommand splittedCommand = null; 218 219 public AbstractCommand getSplittedCommand() { 220 return splittedCommand; 221 } 222 223 public void setSplittedCommand(AbstractCommand splittedCommand) { 224 this.splittedCommand = splittedCommand; 225 } 226 227 228 231 private String receivedLargeObject = null; 232 233 public String getReceivedLargeObject() { 234 return receivedLargeObject; 235 } 236 237 public void setReceivedLargeObject(String receivedLargeObject) { 238 this.receivedLargeObject = receivedLargeObject; 239 } 240 241 244 private Long sizeOfReceivedLargeObject = null; 245 246 public void setSizeOfReceivedLargeObject(Long size) { 247 this.sizeOfReceivedLargeObject = size; 248 } 249 250 public Long getSizeOfReceivedLargeObject() { 251 return sizeOfReceivedLargeObject; 252 } 253 254 255 258 private String nextDataToSend = null; 259 260 public String getNextDataToSend() { 261 return nextDataToSend; 262 } 263 264 public void setNextDataToSend(String nextDataToSend) { 265 this.nextDataToSend = nextDataToSend; 266 } 267 268 269 270 273 private LinkedList listCmdOut = new LinkedList (); 274 275 public void addCmdOut(List cmdList) { 276 listCmdOut.addAll(cmdList); 277 } 278 279 public void addCmdOut(int index, List cmdList) { 280 listCmdOut.addAll(index, cmdList); 281 } 282 283 public LinkedList getCmdOut() { 284 return listCmdOut; 285 } 286 287 public void removeCmdOut(List abstractCommandsList) { 288 listCmdOut.removeAll(abstractCommandsList); 289 } 290 291 public void removeCmdOut(AbstractCommand abstractCommand) { 292 listCmdOut.remove(abstractCommand); 293 } 294 295 296 299 private long sizeStatusSyncHdr = 0; 300 public long getSizeStatusSyncHdr() { 301 return this.sizeStatusSyncHdr; 302 } 303 304 public void setSizeStatusSyncHdr(long sizeStatusSyncHdr) { 305 this.sizeStatusSyncHdr = sizeStatusSyncHdr; 306 } 307 308 311 private Status statusSyncHdr; 312 public void setStatusSyncHdr(Status statusSyncHdr) { 313 this.statusSyncHdr = statusSyncHdr; 314 } 315 316 public Status getStatusSyncHdr() { 317 return this.statusSyncHdr; 318 } 319 320 321 323 328 public ManagementState(String sessionId) { 329 this(); 330 this.sessionId = sessionId; 331 } 332 333 337 public ManagementState() { 338 reset(); 339 } 340 341 342 343 345 public void addClientCommands(AbstractCommand[] commands) { 346 for (int i=0; ((commands != null) && (i<commands.length)); i++) { 347 if (ProtocolUtil.hasLargeObject(commands[i])) { 348 continue; 350 } 351 clientCommands.add(commands[i]); 352 } 353 } 354 355 public AbstractCommand[] getClientCommands() { 356 return (AbstractCommand[])clientCommands.toArray(new AbstractCommand[clientCommands.size()]); 357 } 358 359 public void clearClientCommands() { 360 clientCommands.clear(); 361 } 362 363 364 369 protected void setSessionId(String sessionId) { 370 this.sessionId = sessionId; 371 } 372 373 378 public String getSessionId() { 379 return sessionId; 380 } 381 382 385 public void reset() { 386 loggedCredential = null; 387 loggedPrincipal = null; 388 lastMsgIdFromClient = null; 389 sessionId = null; 390 lastTimestamp = null; 391 nextTimestamp = null; 392 393 started = false; 394 395 type = AlertCode.UNKNOWN; 396 397 authenticationState = AUTH_UNAUTHENTICATED; 398 399 serverAuthenticationState = AUTH_UNAUTHENTICATED; 400 401 clientCommands = new ArrayList (); 402 } 403 } | Popular Tags |