1 7 8 package org.enhydra.snapper.business; 9 10 12 import java.io.File ; 13 import java.sql.Timestamp ; 14 15 import org.enhydra.snapper.Log; 16 import org.enhydra.snapper.Snapper; 17 import org.enhydra.snapper.spec.*; 18 import org.enhydra.snapper.data.*; 19 20 import com.lutris.appserver.server.sql.DBTransaction; 21 import com.lutris.appserver.server.sql.ObjectId; 22 import com.lutris.dods.builder.generator.query.DataObjectException; 23 24 27 public class SiteImpl implements Site { 28 protected SitesDO sitesDO = null; 29 30 public SiteImpl() { 31 } 32 33 public SiteImpl(DBTransaction dbt) { 34 try { 35 this.sitesDO = SitesDO.createVirgin(dbt); 36 } catch (Exception ex) { 37 Log.log(ex.toString()); 38 } 39 40 } 41 42 public void createNew(DBTransaction dbt) { 43 try { 44 this.sitesDO = SitesDO.createVirgin(dbt); 45 } catch (Exception ex) { 46 Log.log(ex.toString()); 47 48 } 49 } 50 51 protected SiteImpl(SitesDO site, DBTransaction dbt) throws Exception { 52 this.sitesDO = SitesDO.createExisting(site.get_Handle(), dbt); 53 54 } 55 56 public String getMETADB() throws Exception { 57 try { 58 return sitesDO.getMETADB(); 59 } catch (DataObjectException ex) { 60 Log.logException(ex); 61 throw new Exception ("Error getting site's META DB", ex); 62 } 63 64 } 65 66 public void setMETADB(String str) throws Exception { 67 try { 68 sitesDO.setMETADB(str); 69 } catch (Exception ex) { 70 Log.logException(ex); 71 throw new Exception ("Error setting META db", ex); 72 } 73 } 74 75 public String getMETATABLE() throws Exception { 76 try { 77 return sitesDO.getMETATABLE(); 78 } catch (DataObjectException ex) { 79 Log.logException(ex); 80 throw new Exception ("Error getting site's META TABLE", ex); 81 } 82 } 83 84 public void setMETATABLE(String str) throws Exception { 85 try { 86 sitesDO.setMETATABLE(str); 87 } catch (Exception ex) { 88 Log.logException(ex); 89 throw new Exception ("Error setting meta TABLE", ex); 90 } 91 } 92 93 public void setMETAFILE(String str) throws Exception { 94 try { 95 sitesDO.setMETAFILECOLUMN(str); 96 } catch (Exception ex) { 97 Log.logException(ex); 98 throw new Exception ("Error setting META FILE COLUMN", ex); 99 } 100 } 101 102 public String getMETAFILE() throws Exception { 103 try { 104 return sitesDO.getMETAFILECOLUMN(); 105 } catch (DataObjectException ex) { 106 Log.logException(ex); 107 throw new Exception ("Error getting site's META FILE COLUMN", ex); 108 } 109 110 } 111 112 public void setMETAKEY(String str) throws Exception { 113 try { 114 sitesDO.setMETAKEYCOLUMN(str); 115 } catch (Exception ex) { 116 Log.logException(ex); 117 throw new Exception ("Error setting META KEY COLUMN", ex); 118 } 119 } 120 121 public String getMETAKEY() throws Exception { 122 try { 123 return sitesDO.getMETAKEYCOLUMN(); 124 } catch (DataObjectException ex) { 125 Log.logException(ex); 126 throw new Exception ("Error getting site's META KEY COLUMN", ex); 127 } 128 129 } 130 131 public void setMETAVALUE(String str) throws Exception { 132 try { 133 sitesDO.setMETAVALUECOLUMN(str); 134 } catch (Exception ex) { 135 Log.logException(ex); 136 throw new Exception ("Error setting META VALUE COLUMN", ex); 137 } 138 } 139 140 public String getMETAVALUE() throws Exception { 141 try { 142 return sitesDO.getMETAVALUECOLUMN(); 143 } catch (DataObjectException ex) { 144 Log.logException(ex); 145 throw new Exception ("Error getting site's META VALUE COLUMN", ex); 146 } 147 148 } 149 150 public String getINCLUDEDB() throws Exception { 151 try { 152 return sitesDO.getINCLUDEDB(); 153 } catch (DataObjectException ex) { 154 Log.logException(ex); 155 throw new Exception ("Error getting site's INCLUDE DB", ex); 156 } 157 158 } 159 160 public void setINCLUDEDB(String str) throws Exception { 161 try { 162 sitesDO.setINCLUDEDB(str); 163 } catch (Exception ex) { 164 Log.logException(ex); 165 throw new Exception ("Error setting INCLUDE db", ex); 166 } 167 } 168 169 public String getINCLUDETABLE() throws Exception { 170 try { 171 return sitesDO.getINCLUDETABLE(); 172 } catch (DataObjectException ex) { 173 Log.logException(ex); 174 throw new Exception ("Error getting site's INCLUDE TABLE", ex); 175 } 176 } 177 178 public void setINCLUDETABLE(String str) throws Exception { 179 try { 180 sitesDO.setINCLUDETABLE(str); 181 } catch (Exception ex) { 182 Log.logException(ex); 183 throw new Exception ("Error setting include TABLE", ex); 184 } 185 } 186 187 public void setINCLUDECOLUMN(String str) throws Exception { 188 try { 189 sitesDO.setINCLUDECOLUMN(str); 190 } catch (Exception ex) { 191 Log.logException(ex); 192 throw new Exception ("Error setting INCLUDE COLUMN", ex); 193 } 194 } 195 196 public String getINCLUDECOLUMN() throws Exception { 197 try { 198 return sitesDO.getINCLUDECOLUMN(); 199 } catch (DataObjectException ex) { 200 Log.logException(ex); 201 throw new Exception ("Error getting site's INCLUDE COLUMN", ex); 202 } 203 204 } 205 206 public void setINCLUDECOLUMNMODIFIED(String str) throws Exception { 207 try { 208 sitesDO.setINCLUDECOLUMNMODIFIED(str); 209 } catch (Exception ex) { 210 Log.logException(ex); 211 throw new Exception ("Error setting INCLUDE COLUMN", ex); 212 } 213 } 214 215 public String getINCLUDECOLUMNMODIFIED() throws Exception { 216 try { 217 return sitesDO.getINCLUDECOLUMNMODIFIED(); 218 } catch (DataObjectException ex) { 219 Log.logException(ex); 220 throw new Exception ("Error getting site's INCLUDE COLUMN", ex); 221 } 222 223 } 224 225 public String getFILTERDB() throws Exception { 226 try { 227 return sitesDO.getFILTERDB(); 228 } catch (DataObjectException ex) { 229 Log.logException(ex); 230 throw new Exception ("Error getting site's filter DB", ex); 231 } 232 233 } 234 235 public void setFILTERDB(String str) throws Exception { 236 try { 237 sitesDO.setFILTERDB(str); 238 } catch (Exception ex) { 239 Log.logException(ex); 240 throw new Exception ("Error setting filter db", ex); 241 } 242 } 243 244 public String getFILTERTABLE() throws Exception { 245 try { 246 return sitesDO.getFILTERTABLE(); 247 } catch (DataObjectException ex) { 248 Log.logException(ex); 249 throw new Exception ("Error getting site's filter TABLE", ex); 250 } 251 } 252 253 public void setFILTERTABLE(String str) throws Exception { 254 try { 255 sitesDO.setFILTERTABLE(str); 256 } catch (Exception ex) { 257 Log.logException(ex); 258 throw new Exception ("Error setting FILTER TABLE", ex); 259 } 260 } 261 262 public void setFILTERCOLUMN(String str) throws Exception { 263 try { 264 sitesDO.setFILTERCOLUMN(str); 265 } catch (Exception ex) { 266 Log.logException(ex); 267 throw new Exception ("Error setting FILTER COLUMN", ex); 268 } 269 } 270 271 public String getFILTERCOLUMN() throws Exception { 272 try { 273 return sitesDO.getFILTERCOLUMN(); 274 } catch (DataObjectException ex) { 275 Log.logException(ex); 276 throw new Exception ("Error getting site's FILTER COLUMN", ex); 277 } 278 279 } 280 281 public String getName() throws Exception { 282 try { 283 return sitesDO.getNAME(); 284 } catch (DataObjectException ex) { 285 Log.logException(ex); 286 throw new Exception ("Error getting site's name", ex); 287 } 288 289 } 290 291 public String getID() throws Exception { 292 try { 293 return sitesDO.get_Handle(); 294 } catch (Exception ex) { 295 Log.logException(ex); 296 throw new Exception ("Error getting site's ID", ex); 297 } 298 299 } 300 301 public void setName(String str) throws Exception { 302 try { 303 sitesDO.setNAME(str); 304 } catch (Exception ex) { 305 Log.logException(ex); 306 throw new Exception ("Error setting name", ex); 307 } 308 } 309 310 public void setLanguage(String str) throws Exception { 311 try { 312 sitesDO.oid_setLANGUAGE(str); 313 } catch (Exception ex) { 314 Log.logException(ex); 315 throw new Exception ("Error setting language", ex); 316 } 317 } 318 319 public String getLanguage() throws Exception { 320 try { 321 return String.valueOf(sitesDO.oid_getLANGUAGE()); 322 } catch (Exception ex) { 323 Log.logException(ex); 324 throw new Exception ("Error getting site's language", ex); 325 } 326 327 } 328 329 public void setSize(String str) throws Exception { 330 try { 331 int size = Integer.parseInt(str); 332 sitesDO.setMAXSIZE(size); 333 } catch (Exception ex) { 334 Log.logException(ex); 335 throw new Exception ("Error setting size"); 336 } 337 } 338 339 public int getSize() throws Exception { 340 try { 341 return sitesDO.getMAXSIZE(); 342 } catch (Exception ex) { 343 Log.logException(ex); 344 throw new Exception ("Error getting site's max. size"); 345 } 346 347 } 348 349 public int getAge() throws Exception { 350 try { 351 return sitesDO.getMAXAGE(); 352 } catch (Exception ex) { 353 Log.logException(ex); 354 throw new Exception ("Error getting site's max. age"); 355 } 356 357 } 358 359 public void setAge(String str) throws Exception { 360 try { 361 int age = Integer.parseInt(str); 362 sitesDO.setMAXAGE(age); 363 } catch (Exception ex) { 364 Log.logException(ex); 365 throw new Exception ("Error setting age"); 366 } 367 } 368 369 public void setLOCKED(String str) throws Exception { 370 try { 371 boolean x; 372 if (str == null) 373 x = false; 374 else 375 x = true; 376 sitesDO.setLOCKED(x); 377 } catch (Exception ex) { 378 Log.logException(ex); 379 throw new Exception ("Error setting locked"); 380 } 381 } 382 383 public boolean getLOCKED() throws Exception { 384 try { 385 return sitesDO.getLOCKED(); 386 } catch (Exception ex) { 387 Log.logException(ex); 388 throw new Exception ("Error getting locked"); 389 } 390 } 391 public void setOTHER(String str) throws Exception { 392 try { 393 boolean x; 394 if (str == null) 395 x = false; 396 else 397 x = true; 398 sitesDO.setOTHER(x); 399 } catch (Exception ex) { 400 401 throw new Exception ("Error setting other"); 402 } 403 } 404 405 public boolean getOTHER() throws Exception { 406 try { 407 return sitesDO.getOTHER(); 408 } catch (Exception ex) { 409 throw new Exception ("Error getting other"); 410 } 411 } 412 413 public void setRTF(String str) throws Exception { 414 try { 415 boolean x; 416 if (str == null) 417 x = false; 418 else 419 x = true; 420 sitesDO.setRTF(x); 421 } catch (Exception ex) { 422 Log.logException(ex); 423 throw new Exception ("Error setting rtf"); 424 } 425 } 426 427 public boolean getRTF() throws Exception { 428 try { 429 return sitesDO.getRTF(); 430 } catch (Exception ex) { 431 Log.logException(ex); 432 throw new Exception ("Error getting rtf"); 433 } 434 } 435 436 public void setDOC(String str) throws Exception { 437 try { 438 boolean x; 439 if (str == null) 440 x = false; 441 else 442 x = true; 443 sitesDO.setWORD(x); 444 } catch (Exception ex) { 445 Log.logException(ex); 446 throw new Exception ("Error setting doc"); 447 } 448 } 449 450 public boolean getDOC() throws Exception { 451 try { 452 return sitesDO.getWORD(); 453 } catch (Exception ex) { 454 Log.logException(ex); 455 throw new Exception ("Error getting word"); 456 } 457 } 458 459 public void setTXT(String str) throws Exception { 460 try { 461 boolean x; 462 if (str == null) 463 x = false; 464 else 465 x = true; 466 sitesDO.setTEXT(x); 467 } catch (Exception ex) { 468 Log.logException(ex); 469 throw new Exception ("Error setting txt"); 470 } 471 } 472 473 public boolean getTXT() throws Exception { 474 try { 475 return sitesDO.getTEXT(); 476 } catch (Exception ex) { 477 Log.logException(ex); 478 throw new Exception ("Error getting txt"); 479 } 480 } 481 482 public void setHTML(String str) throws Exception { 483 try { 484 boolean x; 485 if (str == null) 486 x = false; 487 else 488 x = true; 489 sitesDO.setHTML(x); 490 } catch (Exception ex) { 491 Log.logException(ex); 492 throw new Exception ("Error setting html"); 493 } 494 } 495 496 public boolean getHTML() throws Exception { 497 try { 498 return sitesDO.getHTML(); 499 } catch (Exception ex) { 500 Log.logException(ex); 501 throw new Exception ("Error getting html"); 502 } 503 } 504 505 public void setMSG(String str) throws Exception { 506 try { 507 boolean x; 508 if (str == null) 509 x = false; 510 else 511 x = true; 512 sitesDO.setMSG(x); 513 } catch (Exception ex) { 514 Log.logException(ex); 515 throw new Exception ("Error setting msg"); 516 } 517 } 518 519 public boolean getMSG() throws Exception { 520 try { 521 return sitesDO.getMSG(); 522 } catch (Exception ex) { 523 Log.logException(ex); 524 throw new Exception ("Error getting msg"); 525 } 526 } 527 528 public void setPDF(String str) throws Exception { 529 try { 530 boolean x; 531 if (str == null) 532 x = false; 533 else 534 x = true; 535 sitesDO.setPDF(x); 536 } catch (Exception ex) { 537 Log.logException(ex); 538 throw new Exception ("Error setting pdf"); 539 } 540 } 541 542 public boolean getPDF() throws Exception { 543 try { 544 return sitesDO.getPDF(); 545 } catch (Exception ex) { 546 Log.logException(ex); 547 throw new Exception ("Error getting pdf"); 548 } 549 } 550 551 public void setXLS(String str) throws Exception { 552 try { 553 boolean x; 554 if (str == null) 555 x = false; 556 else 557 x = true; 558 sitesDO.setEXCEL(x); 559 } catch (Exception ex) { 560 Log.logException(ex); 561 throw new Exception ("Error setting xls"); 562 } 563 } 564 565 public boolean getXLS() throws Exception { 566 try { 567 return sitesDO.getEXCEL(); 568 } catch (Exception ex) { 569 Log.logException(ex); 570 throw new Exception ("Error getting xls"); 571 } 572 } 573 574 public void setZIP(String str) throws Exception { 575 try { 576 boolean x; 577 if (str == null) 578 x = false; 579 else 580 x = true; 581 sitesDO.setZIP(x); 582 } catch (Exception ex) { 583 Log.logException(ex); 584 throw new Exception ("Error setting zip"); 585 } 586 } 587 588 public boolean getZIP() throws Exception { 589 try { 590 return sitesDO.getZIP(); 591 } catch (Exception ex) { 592 Log.logException(ex); 593 throw new Exception ("Error getting zip"); 594 } 595 } 596 597 public void setOO(String str) throws Exception { 598 try { 599 boolean x; 600 if (str == null) 601 x = false; 602 else 603 x = true; 604 sitesDO.setOO(x); 605 } catch (Exception ex) { 606 Log.logException(ex); 607 throw new Exception ("Error setting OO"); 608 } 609 } 610 611 public boolean getOO() throws Exception { 612 try { 613 return sitesDO.getOO(); 614 } catch (Exception ex) { 615 Log.logException(ex); 616 throw new Exception ("Error getting OO"); 617 } 618 } 619 620 public void setPPT(String str) throws Exception { 621 try { 622 boolean x; 623 if (str == null) 624 x = false; 625 else 626 x = true; 627 sitesDO.setPPT(x); 628 } catch (Exception ex) { 629 Log.logException(ex); 630 throw new Exception ("Error setting ppt"); 631 } 632 } 633 634 public boolean getPPT() throws Exception { 635 try { 636 return sitesDO.getPPT(); 637 } catch (Exception ex) { 638 Log.logException(ex); 639 throw new Exception ("Error getting ppt"); 640 } 641 } 642 643 public void setPPS(String str) throws Exception { 644 try { 645 boolean x; 646 if (str == null) 647 x = false; 648 else 649 x = true; 650 sitesDO.setPPS(x); 651 } catch (Exception ex) { 652 Log.logException(ex); 653 throw new Exception ("Error setting pps"); 654 } 655 } 656 657 public boolean getPPS() throws Exception { 658 try { 659 return sitesDO.getPPS(); 660 } catch (Exception ex) { 661 Log.logException(ex); 662 throw new Exception ("Error getting pps"); 663 } 664 } 665 666 public void setEML(String str) throws Exception { 667 try { 668 boolean x; 669 if (str == null) 670 x = false; 671 else 672 x = true; 673 sitesDO.setEML(x); 674 } catch (Exception ex) { 675 Log.logException(ex); 676 throw new Exception ("Error setting eml"); 677 } 678 } 679 680 public boolean getEML() throws Exception { 681 try { 682 return sitesDO.getEML(); 683 } catch (Exception ex) { 684 Log.logException(ex); 685 throw new Exception ("Error getting eml"); 686 } 687 } 688 689 public boolean getSEARCH() throws Exception { 690 try { 691 return sitesDO.getSEARCH(); 692 } catch (Exception ex) { 693 Log.logException(ex); 694 throw new Exception ("Error getting search"); 695 } 696 697 } 698 699 public void setSEARCH(String str) throws Exception { 700 try { 701 boolean x; 702 if (str == null) 703 x = false; 704 else 705 x = true; 706 sitesDO.setSEARCH(x); 707 } catch (Exception ex) { 708 Log.logException(ex); 709 throw new Exception ("Error setting search"); 710 } 711 } 712 713 public boolean getDOWNLOAD() throws Exception { 714 try { 715 return sitesDO.getDOWNLOAD(); 716 } catch (Exception ex) { 717 Log.logException(ex); 718 throw new Exception ("Error getting download"); 719 } 720 } 721 722 public void setDOWNLOAD(String str) throws Exception { 723 try { 724 boolean x; 725 if (str == null) 726 x = false; 727 else 728 x = true; 729 sitesDO.setDOWNLOAD(x); 730 } catch (Exception ex) { 731 Log.logException(ex); 732 throw new Exception ("Error setting download"); 733 } 734 } 735 736 public String getINDEXDIR() throws Exception { 737 try { 738 return sitesDO.getINDEXDIR(); 739 } catch (Exception ex) { 740 Log.logException(ex); 741 throw new Exception ("Error getting indexdir"); 742 } 743 744 } 745 746 public void setINDEXDIR(String str) throws Exception { 747 try { 748 sitesDO.setINDEXDIR(str); 749 } catch (Exception ex) { 750 Log.logException(ex); 751 throw new Exception ("Error setting indexname", ex); 752 } 753 } 754 755 public void save() throws Exception { 756 try { 757 this.sitesDO.save(); 758 } catch (Exception ex) { 759 Log.logException(ex); 760 throw new Exception ("Read-only table: DML operations not allowed"); 761 } 762 } 763 764 public void delete() throws Exception { 765 try { 766 this.sitesDO.delete(); 767 } catch (Exception ex) { 768 Log.logException(ex); 769 throw new Exception ("Read-only table: DML operations not allowed"); 770 } 771 } 772 773 public Site findSiteByID(String id, DBTransaction dbt) throws Exception { 774 SiteImpl site = null; 775 try { 776 SitesQuery query = new SitesQuery(dbt); 777 query.setQueryOId(new ObjectId(id)); 779 query.requireUniqueInstance(); 781 SitesDO sitesDO = query.getNextDO(); 782 site = new SiteImpl(sitesDO, dbt); 783 return site; 784 } catch (Exception ex) { 785 Log.logException(ex); 786 throw new Exception ("Exception in findDiscsByID()"); 787 } 788 } 789 790 public Timestamp getLASTUPDATE() throws Exception { 791 try { 792 return sitesDO.getLASTUPDATE(); 793 } catch (Exception ex) { 794 Log.logException(ex); 795 throw new Exception ("Error getting lastupdate"); 796 } 797 } 798 799 public Timestamp getLASTQUERY() throws Exception { 800 try { 801 return sitesDO.getLASTQUERY(); 802 } catch (Exception ex) { 803 Log.logException(ex); 804 throw new Exception ("Error getting lastquery"); 805 } 806 } 807 808 public int getFILENR() throws Exception { 809 try { 810 return sitesDO.getFILENR(); 811 } catch (Exception ex) { 812 Log.logException(ex); 813 throw new Exception ("Error getting filenr"); 814 } 815 } 816 817 public int getQUERYNR() throws Exception { 818 try { 819 return sitesDO.getQUERYNR(); 820 } catch (Exception ex) { 821 Log.logException(ex); 822 throw new Exception ("Error getting querynr"); 823 } 824 } 825 826 public void setLASTUPDATE(Timestamp str) throws Exception { 827 try { 828 sitesDO.setLASTUPDATE(str); 829 } catch (Exception ex) { 830 Log.logException(ex); 831 throw new Exception ("Error setting lastupdate", ex); 832 } 833 } 834 835 public void setLASTQUERY(Timestamp str) throws Exception { 836 try { 837 sitesDO.setLASTQUERY(str); 838 } catch (Exception ex) { 839 Log.logException(ex); 840 throw new Exception ("Error setting lastupdate", ex); 841 } 842 } 843 844 public void setFILENR(int str) throws Exception { 845 try { 846 sitesDO.setFILENR(str); 847 } catch (Exception ex) { 848 Log.logException(ex); 849 throw new Exception ("Error setting filenr", ex); 850 } 851 852 } 853 854 public void setQUERYNR(int str) throws Exception { 855 try { 856 sitesDO.setQUERYNR(str); 857 } catch (Exception ex) { 858 Log.logException(ex); 859 throw new Exception ("Error setting querynr", ex); 860 } 861 862 } 863 864 public void deleteDir(String index) throws Exception { 865 try { 866 File dir = new File (Snapper.getIndexDir() + File.separator 867 + index); 868 if (dir.exists()) { 869 if (dir.canRead()) { 870 if (dir.isDirectory()) { 871 String [] files = dir.list(); 872 if (files != null) { 873 for (int p = 0; p < files.length; p++) { 874 File originalFile = new File (dir, files[p]); 875 originalFile.delete(); 876 } 877 } 878 dir.delete(); 879 } 880 } 881 } 882 } catch (Exception ex) { 883 Log.logException(ex); 884 } 885 } 886 887 } | Popular Tags |