1 24 33 34 package org.datashare.objects; 35 36 import java.util.Date ; 37 import org.datashare.ChannelInfo; 38 import org.datashare.ClientInfo; 39 import org.datashare.SessionInfo; 40 import org.datashare.ConsumerInfo; 41 import org.datashare.SessionUtilities; 42 43 51 public class DefaultObjectInfo implements DSObjectInfoInterface, java.io.Serializable  52 { 53 57 static final long serialVersionUID = 9030593813711490593L; 58 59 63 protected String name; 64 65 69 protected String ownerName = ""; 70 71 74 protected String clientClass = ""; 75 76 81 protected String toString = "*"; 82 83 87 protected boolean active = false; 88 89 93 protected Date date; 94 95 105 protected String keyValue; 106 107 112 protected String infoString; 113 114 122 protected String originalType; 123 124 129 protected String parentKeyValue; 130 131 138 protected String grandparentKeyValue; 139 140 146 protected String databaseID; 147 148 153 protected boolean waitingForKey = true; 154 155 162 protected boolean keyHasBeenReturned = false; 163 164 167 protected String imageURL = ""; 168 169 172 protected String clientRealName = ""; 173 174 177 protected boolean privateOnly = false; 178 179 187 191 protected DefaultObjectInfo() 192 { 193 name = "no name"; 194 toString = name; 195 date = new Date (); } 198 199 205 public DefaultObjectInfo(String name, String type, String infoString) 206 { 207 this(); 208 this.name = name; 209 this.toString = name; 210 originalType = type; 211 this.infoString = infoString; 212 } 213 214 220 public DefaultObjectInfo(String name, String type, String clientClass, String infoString) 221 { 222 this(name, type, infoString); 223 this.clientClass = clientClass; 224 } 225 226 public DefaultObjectInfo(ChannelInfo infoObject) 227 { 228 this.date = infoObject.getDate(); 229 this.keyValue = infoObject.getKeyValue(); 230 this.name = infoObject.getConnectionDescriptor().name; 231 this.toString = infoObject.toString(); 232 this.infoString = infoObject.getInfo(); 233 this.originalType = infoObject.CHANNELTYPE; 234 this.parentKeyValue = infoObject.getParentKeyValue(); 235 this.ownerName = infoObject.getSessionInfo().getOwnerName(); 236 this.databaseID = infoObject.getDatabaseID(); 237 this.active = infoObject.getActive(); 238 this.clientClass = infoObject.getClientClass(); 239 } 241 242 public DefaultObjectInfo(ClientInfo infoObject) 243 { 244 this.date = infoObject.getDate(); 245 this.keyValue = infoObject.getKeyValue(); 246 this.name = infoObject.getName(); 247 this.toString = infoObject.toString(); this.infoString = infoObject.getInfo(); 249 this.originalType = infoObject.CLIENTTYPE; 250 this.imageURL = infoObject.getImageURL(); 251 this.clientRealName = infoObject.getClientRealName(); 252 this.databaseID = infoObject.getDatabaseID(); 253 this.active = infoObject.getActive(); 254 this.clientClass = infoObject.getClientClass(); 255 } 256 257 public DefaultObjectInfo(SessionInfo infoObject) 258 { 259 this.date = infoObject.getDate(); 260 this.keyValue = infoObject.getKeyValue(); 261 this.name = infoObject.toString(); 262 this.toString = infoObject.toString(); 263 this.infoString = infoObject.getInfo(); 264 this.originalType = infoObject.SESSIONTYPE; 265 this.ownerName = infoObject.getOwnerName(); 266 this.databaseID = infoObject.getDatabaseID(); 267 this.privateOnly = infoObject.getPrivate(); 268 this.active = infoObject.getActive(); 269 this.clientClass = infoObject.getClientClass(); 270 } 271 272 public DefaultObjectInfo(ConsumerInfo infoObject) 273 { 274 this.date = infoObject.getDate(); 275 this.keyValue = infoObject.getKeyValue(); 276 this.name = infoObject.getName(); 277 this.toString = infoObject.toString(); 278 this.infoString = infoObject.getInfo(); 279 this.originalType = infoObject.CONSUMERTYPE; 280 this.parentKeyValue = infoObject.getParentKeyValue(); 281 this.grandparentKeyValue = infoObject.getGrandParentKeyValue(); 282 this.imageURL = infoObject.getClientInfo().getImageURL(); 283 this.clientRealName = infoObject.getClientRealName(); 284 this.active = infoObject.getActive(); 285 this.clientClass = infoObject.getClientClass(); 286 } 288 289 294 public String  295 toString() 296 { 297 return toString; 298 } 299 300 305 public String  306 getName() 307 { 308 return name; 309 } 310 311 314 public String  315 getClientRealName() 316 { 317 return clientRealName; 318 } 319 320 329 334 public String  335 getDatabaseID() 336 { 337 return databaseID; 338 } 339 340 343 public String  344 retrieveEJB() 345 { 346 String thisKey = ""; 347 int count = 0; 348 Date startTime = new Date (); 349 Date stopTime = null; 350 351 SessionUtilities.getLoggingInterface().debugMsg(SessionUtilities.getLoggingInterface().DEBUG, 352 SessionUtilities.getLoggingInterface().DATABASE, 353 "Trying to retrieve a " + this.getType() + " ADSKey for " + getKeyValue()); 354 while(waitingForKey && count < 35) 356 { 357 count++; 358 try 359 { 360 Thread.sleep(1000); 361 } 362 catch(InterruptedException ie) 363 { 364 } 365 } 366 if(keyHasBeenReturned) 367 thisKey = databaseID; 368 else 369 { 370 stopTime = new Date (); 371 SessionUtilities.getLoggingInterface().debugMsg(SessionUtilities.getLoggingInterface().DEBUG, 372 SessionUtilities.getLoggingInterface().DATABASE, 373 "getDatabaseID("+this.getKeyValue()+") bad state: started EJBCreate at " + 374 SessionUtilities.getTimeString(startTime) + 375 " and gave up at " + 376 SessionUtilities.getTimeString(stopTime)); 377 } 378 return thisKey; 379 } 380 381 382 387 public String  388 getOwnerName() 389 { 390 return this.ownerName; 391 } 392 393 400 public String  401 getType() 402 { 403 return DEFAULTOBJECTTYPE; 404 } 405 406 411 public String  412 getOriginalType() 413 { 414 return originalType; 415 } 416 417 423 public Object  424 getObject() 425 { 426 return this; 427 } 428 429 432 public String  433 getClientClass() 434 { 435 return clientClass; 436 } 437 438 445 public String  446 getInfo() 447 { 448 if(infoString != null && infoString.length() != 0) 449 return infoString; 450 else 451 return "<tr><td>User Name:</td><td>"+name+"</td></tr>"; 452 } 453 454 459 public void 460 setInfo(String infoString) 461 { 462 this.infoString = infoString; 463 } 464 465 470 public boolean 471 getActive() 472 { 473 return active; 474 } 475 476 481 public void 482 setActive(boolean active) 483 { 484 this.active = active; 485 } 486 487 493 public Date  494 getDate() 495 { 496 return date; 497 } 498 499 500 507 public String  508 getKeyValue() 509 { 510 return keyValue; } 512 513 519 public String  520 getParentKeyValue() 521 { 522 if( parentKeyValue == null ) 523 return "NULL"; 524 else 525 return parentKeyValue; } 527 528 534 public String  535 getGrandParentKeyValue() 536 { 537 if( grandparentKeyValue == null ) 538 return "NULL"; 539 else 540 return grandparentKeyValue; } 542 543 549 public void 550 setKeyValue(String keyValue) 551 { 552 this.keyValue = keyValue; } 554 555 563 public void 564 setKeyHasBeenReturned(boolean value) 565 { 566 keyHasBeenReturned = value; 567 } 568 569 580 public void 581 setWaitingForKey(boolean value) 582 { 583 waitingForKey = value; 584 } 585 586 592 public void 593 setDatabaseID(String ak) 594 { 595 SessionUtilities.getLoggingInterface().debugMsg(SessionUtilities.getLoggingInterface().DEBUG, 596 SessionUtilities.getLoggingInterface().DATABASE, 597 "setDatabaseID(): EJB Key for " + this.getKeyValue() + " has value of " + ak); 598 databaseID = ak; 599 waitingForKey = false; 600 keyHasBeenReturned = true; 601 } 602 603 606 public String getImageURL() 607 { 608 return this.imageURL; 609 } 610 611 615 public boolean 616 getPrivate() 617 { 618 return this.privateOnly; 619 } 620 621 622 } 623 624
| Popular Tags
|