001/** 002 * Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ 003 * 004 * This file is part of Dicoogle/dicoogle. 005 * 006 * Dicoogle/dicoogle is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Dicoogle/dicoogle is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. 018 */ 019 020package pt.ua.dicoogle.core; 021 022/** 023 * 024 * @author Marco Pereira 025 * @modified Luís A. Bastião Silva <bastiao@ua.pt> 026 * @modified Samuel da Costa Campos <samuelcampos@ua.pt> 027 */ 028 029 030import pt.ua.dicoogle.sdk.datastructs.MoveDestination; 031import pt.ua.dicoogle.sdk.settings.types.ServerDirectoryPath; 032import pt.ua.dicoogle.server.*; 033 034import java.io.*; 035 036// SAX classes. 037import org.xml.sax.*; 038import org.xml.sax.helpers.*; 039 040//JAXP 041import javax.xml.transform.*; 042import javax.xml.transform.stream.*; 043import javax.xml.transform.sax.*; 044 045import java.io.FileOutputStream; 046import java.util.ArrayList; 047import java.util.HashMap; 048import java.util.List; 049 050import javax.swing.DefaultListModel; 051 052import org.xml.sax.XMLReader; 053import org.dcm4che2.data.UID; 054import org.slf4j.Logger; 055import org.slf4j.LoggerFactory; 056 057import pt.ua.dicoogle.sdk.Utils.Platform; 058 059public class XMLSupport extends DefaultHandler 060{ 061 private static final Logger logger = LoggerFactory.getLogger(XMLSupport.class); 062 063 private boolean isEncrypt = false; 064 private boolean isPort = false; 065 private boolean isRGUIPort = false; 066 private boolean isRGUIExtIP = false; 067 private boolean isIndexEffort = false; 068 private boolean isZIPFile = false; 069 private boolean isGZIPStorage = false; 070 private boolean isTS = false; 071 private boolean isAET = false; 072 private boolean isCAET = false; 073 private boolean isPermitAllAETitles = false; 074 private boolean isPath = false; 075 private boolean isDicoogleDir = false; 076 private boolean isFullContentIndex = false; 077 private boolean isSaveThumbnails = false; 078 private boolean isThumbnailsMatrix = false; 079 080 private boolean isStorage = false; 081 082 083 /** P2P **/ 084 private boolean isP2P = false ; 085 private boolean autoConnect = false ; 086 private boolean maxmsg = false; 087 private boolean isNode = false ; 088 private boolean isNodeName = false ; 089 private boolean isDefined = false ; 090 091 /** 092 * 093 * Query Retreive Server configs 094 */ 095 private boolean isQRConfigs = false ; 096 private boolean isDeviceDescription = false ; 097 private boolean isLocalAETName = false ; 098 private boolean isPermitedRemoteAETsNames = false ; 099 private boolean isPermitedLocalInterfaces = false ; 100 private boolean isPermitedRemoveHostnames = false ; 101 private boolean isRspDelay = false ; 102 private boolean isDIMSERspTimeout = false ; 103 private boolean isIdleTimeout = false ; 104 private boolean isAcceptTimeout = false ; 105 private boolean isConnectTimeout = false ; 106 private boolean isTransfCap = false ; 107 private boolean isSOPClass = false ; 108 private boolean QREnable = false; 109 private boolean isMaxClientAssoc = false ; 110 private boolean isMaxPDULengthReceive = false ; 111 private boolean isMaxPDULengthSend = false ; 112 113 private boolean isWeb = false ; 114 115 private boolean isMonitorWatcher = false; 116 117 private boolean options = false ; 118 private boolean modality = false ; 119 private boolean cfind = false ; 120 private boolean find = false ; 121 122 123 private String sopId = null; 124 125 private boolean destinations = false ; 126 private boolean dest = false ; 127 128 private int port = 0 ; 129 private String AETitle = null ; 130 private String IP = null ; 131 private String description; 132 private String isPublic; 133 134 private boolean priorityAET = false; 135 136 137 private String currentService; 138 139 private SOPList list; 140 private ServerSettings s; 141 private TransfersStorage LocalTS; 142 public TransfersStorage getLocalTS() { 143 return LocalTS; 144 } 145 146 private DefaultListModel m; 147 148 149 private boolean isIndexAnonymous = false; 150 private boolean isWANModeEnabled = false; 151 152 153 154 public XMLSupport() 155 { 156 list = SOPList.getInstance(); 157 s = ServerSettings.getInstance(); 158 LocalTS = new TransfersStorage(); 159 m = new DefaultListModel(); 160 } 161 162 @Override 163 public void startElement( String uri, String localName, String qName, Attributes attribs ) 164 { 165 if (localName.equals("QueryRetrieve")) 166 { 167 isQRConfigs = true ; 168 }else if(localName.equals("WANModeEnabled")) 169 { 170 isWANModeEnabled = true; 171 } 172 else if(localName.equals("EncryptUsersFile")) 173 { 174 isEncrypt = true; 175 } 176 else if(localName.equals( "IndexEffort" )){ 177 isIndexEffort = true; 178 } 179 else if( localName.equals( "Port" ) && !isQRConfigs ) 180 { 181 isPort = true; 182 } 183 else if( localName.equals( "IndexAnonymous" ) ) 184 { 185 isIndexAnonymous = true; 186 } 187 else if( localName.equals( "IndexZipFiles" ) ) 188 { 189 isZIPFile = true; 190 } 191 else if( localName.equals( "GZipStorage" ) ) 192 { 193 isGZIPStorage = true; 194 } 195 else if( localName.equals( "MonitorWatcher" ) ) 196 { 197 isMonitorWatcher = true ; 198 } 199 else if( localName.equals( "P2P" ) && !isQRConfigs ) 200 { 201 isP2P = true; 202 } 203 else if( localName.equals( "AutoConnect" ) && isP2P ) 204 { 205 autoConnect = true ; 206 } 207 else if( localName.equals( "MaxMsg" ) && isP2P ) 208 { 209 maxmsg = true ; 210 } 211 else if( localName.equals( "Node" ) && isP2P ) 212 { 213 isNode = true ; 214 } 215 else if( localName.equals( "name" ) && isP2P && isNode) 216 { 217 isNodeName = true ; 218 } 219 else if( localName.equals( "defined" ) && isP2P && isNode) 220 { 221 isDefined = true ; 222 } 223 224 else if( localName.equals( "Storage" )) 225 { 226 isStorage = true; 227 } 228 else if( localName.equals( "DicoogleDir" ) ) 229 { 230 isDicoogleDir = true; 231 } 232 else if(localName.equals("fullContentIndex")) 233 { 234 isFullContentIndex = true; 235 } 236 else if(localName.equals("SaveThumbnails")) 237 { 238 isSaveThumbnails = true; 239 } 240 else if(localName.equals("ThumbnailsMatrix")) 241 { 242 isThumbnailsMatrix = true; 243 } 244 else if(localName.equals("AETitle")) 245 { 246 isAET = true; 247 } 248 else if(localName.equals("CAETitle")) 249 { 250 isCAET = true; 251 } 252 else if(localName.equals("PermitAllAETitles")) 253 { 254 isPermitAllAETitles = true; 255 } 256 else if(localName.equals("Path")) 257 { 258 isPath = true; 259 } 260 else if(localName.equals("Service")) 261 { 262 currentService = resolveAttrib(uri, localName, attribs, UID.VerificationSOPClass); 263 } 264 else if(localName.equals("TS")) 265 { 266 isTS = true; 267 } 268 /** Now Worklist Server parsing */ 269 else if (localName.equals("DeviceDescription")) 270 { 271 isDeviceDescription = true; 272 } 273 else if (localName.equals("LocalAETName")) 274 { 275 isLocalAETName = true ; 276 } 277 else if (localName.equals("PermitedRemoteAETsNames")) 278 { 279 isPermitedRemoteAETsNames = true ; 280 } 281 else if (localName.equals("Port") && isQRConfigs) 282 { 283 isPort = true ; 284 } 285 else if (localName.equals("PermitedLocalInterfaces")) 286 { 287 isPermitedLocalInterfaces = true ; 288 } 289 else if (localName.equals("PermitedRemoveHostnames")) 290 { 291 isPermitedRemoveHostnames = true ; 292 } 293 else if (localName.equals("RspDelay")) 294 { 295 isRspDelay = true ; 296 } 297 else if (localName.equals("DIMSERspTimeout")) 298 { 299 isDIMSERspTimeout = true ; 300 } 301 else if (localName.equals("IdleTimeout")) 302 { 303 isIdleTimeout = true ; 304 } 305 else if (localName.equals("AcceptTimeout")) 306 { 307 isAcceptTimeout = true ; 308 } 309 else if (localName.equals("ConnectionTimeout")) 310 { 311 isConnectTimeout = true ; 312 } 313 else if (localName.equals("SOPClass")) 314 { 315 isSOPClass = true ; 316 } 317 else if (localName.equals("QREnable")) 318 { 319 QREnable = true ; 320 } 321 else if (localName.equals("MAX_CLIENT_ASSOCS")) 322 { 323 isMaxClientAssoc = true ; 324 } 325 else if (localName.equals("MAX_PDU_LENGTH_RECEIVE")) 326 { 327 isMaxPDULengthReceive = true ; 328 } 329 else if (localName.equals("MAX_PDU_LENGTH_SEND")) 330 { 331 isMaxPDULengthSend = true ; 332 } 333 334 if (localName.equals("options")) 335 { 336 this.options = true ; 337 } 338 else if (localName.equals("modality") && this.options) 339 { 340 this.modality = true ; 341 } 342 else if (localName.equals("cfind") && this.options && this.modality) 343 { 344 this.cfind = true ; 345 } 346 else if (localName.equals("find") && this.options && this.modality && 347 this.cfind) 348 { 349 this.find = true ; 350 sopId = resolveAttrib(uri, localName, attribs, localName); 351 352 } 353 354 else if(localName.equals("destinations")) 355 { 356 this.destinations = true ; 357 } 358 359 else if (destinations && localName.equals("dest")) 360 { 361 this.dest = true ; 362 this.AETitle = this.resolveAttrib("ae", attribs, localName); 363 this.port = Integer.parseInt(this.resolveAttrib("port", attribs, localName)); 364 this.IP = this.resolveAttrib("ip", attribs, localName); 365 this.description = this.resolveAttrib("description", attribs, ""); 366 this.isPublic = this.resolveAttrib("public", attribs, "false"); 367 368 MoveDestination tmp = new MoveDestination(this.AETitle, this.IP, 369 this.port, this.isPublic.contains("true"), this.description); 370 s.add(tmp); 371 } 372 373 else if(localName.equals("CSTOREPriorities")) 374 { 375 this.priorityAET = true ; 376 } 377 else if (priorityAET && localName.equals("aetitle")) 378 { 379 String aet = this.resolveAttrib("aetitle", attribs, localName); 380 //ServerSettings.getInstance().addPriorityAETitle(aet); 381 } 382 383 384 else if (localName.equals("web")) 385 { 386 this.isWeb = true ; 387 } 388 else if (localName.equals("server") && this.isWeb) 389 { 390 String tmp = ""; 391 ServerSettings.Web web = ServerSettings.getInstance().getWeb() ; 392 tmp = this.resolveAttrib("enable", attribs, localName); 393 web.setWebServer(Boolean.parseBoolean(tmp)); 394 int port = Integer.valueOf(this.resolveAttrib("port", attribs, localName)); 395 web.setServerPort(port); 396 397 String allowedOrigins = this.resolveAttrib("allowedOrigins", attribs, ""); 398 web.setAllowedOrigins(allowedOrigins); 399 } 400 401 else if (localName.equals("services") && this.isWeb) 402 { 403 String tmp = ""; 404 ServerSettings.Web web = ServerSettings.getInstance().getWeb() ; 405 tmp = this.resolveAttrib("enable", attribs, localName); 406 if (tmp.equals("true")) 407 { 408 web.setWebServices(true); 409 } 410 else 411 { 412 web.setWebServices(false); 413 } 414 int port = Integer.valueOf(this.resolveAttrib("port", attribs, localName)); 415 web.setServicePort(port); 416 417 418 419 } 420 else if( localName.equals("RGUIPort") ) 421 { 422 isRGUIPort = true; 423 } 424 else if(localName.equals("RGUIExtIP")) 425 { 426 isRGUIExtIP = true; 427 } 428 429 430 431 } 432 433 @Override 434 public void endElement( String uri, String localName, String qName ) { 435 436 if (localName.equals("QueryRetrieve")) 437 { 438 isQRConfigs = false ; 439 }else if(localName.equals("WANModeEnabled")) 440 { 441 isWANModeEnabled = false; 442 } 443 else if(localName.equals("EncryptUsersFile")) 444 { 445 isEncrypt = false; 446 } 447 else if( localName.equals( "Port" ) ) 448 { 449 isPort = false; 450 } 451 else if(localName.equals( "IndexEffort" )){ 452 isIndexEffort = false; 453 } 454 455 else if( localName.equals( "IndexAnonymous" ) ) 456 { 457 isIndexAnonymous = false; 458 } 459 460 else if( localName.equals( "IndexZipFiles" ) ) 461 { 462 isZIPFile = false ; 463 } 464 else if( localName.equals( "GZipStorage" ) ) 465 { 466 isGZIPStorage = false; 467 } 468 else if( localName.equals( "MonitorWatcher" ) ) 469 { 470 isMonitorWatcher = false ; 471 } 472 473 else if( localName.equals( "P2P" ) ) 474 { 475 isP2P = false; 476 } 477 else if( localName.equals( "AutoConnect" ) && isP2P ) 478 { 479 autoConnect = false ; 480 } 481 else if( localName.equals( "MaxMsg" ) && isP2P ) 482 { 483 maxmsg = false ; 484 } 485 else if( localName.equals( "Node" ) && isP2P ) 486 { 487 isNode = false ; 488 } 489 else if( localName.equals( "name" ) && isP2P && isNode) 490 { 491 isNodeName = false ; 492 } 493 else if( localName.equals( "defined" ) && isP2P && isNode) 494 { 495 isDefined = false ; 496 } 497 498 499 else if( localName.equals( "Storage" ) ) 500 { 501 isStorage = false; 502 } 503 else if( localName.equals( "DicoogleDir" ) ) 504 { 505 isDicoogleDir = false; 506 } 507 else if( localName.equals( "fullContentIndex" ) ) 508 { 509 isFullContentIndex = false; 510 } 511 else if( localName.equals( "SaveThumbnails" ) ) 512 { 513 isSaveThumbnails = false; 514 } 515 else if( localName.equals( "ThumbnailsMatrix" ) ) 516 { 517 isThumbnailsMatrix = false; 518 } 519 else if(localName.equals("AETitle")) 520 { 521 isAET = false; 522 } 523 else if(localName.equals("CAETitle")) 524 { 525 isCAET = false; 526 } 527 else if(localName.equals("PermitAllAETitles")) 528 { 529 isPermitAllAETitles = false; 530 } 531 else if(localName.equals("Path")) 532 { 533 isPath = false; 534 } 535 else if(localName.equals("TS")) 536 { 537 isTS = false; 538 } 539 if(localName.equals("Service")) 540 { 541 list.updateTS(currentService, LocalTS.getTS(), true); 542 } 543 544 /** Worklist Server */ 545 if (localName.equals("DeviceDescription")) 546 { 547 isDeviceDescription = false ; 548 } 549 else if (localName.equals("LocalAETName")) 550 { 551 isLocalAETName = false ; 552 } 553 else if (localName.equals("PermitedRemoveAETsNames")) 554 { 555 isPermitedRemoteAETsNames = false ; 556 } 557 else if (localName.equals("PermitedLocalInterfaces")) 558 { 559 isPermitedLocalInterfaces = false ; 560 } 561 else if (localName.equals("PermitedRemoveHostnames")) 562 { 563 isPermitedRemoveHostnames = false ; 564 } 565 else if (localName.equals("RspDelay")) 566 { 567 isRspDelay = false ; 568 } 569 else if (localName.equals("DIMSERspTimeout")) 570 { 571 isDIMSERspTimeout = false ; 572 } 573 else if (localName.equals("IdleTimeout")) 574 { 575 isIdleTimeout = false ; 576 } 577 else if (localName.equals("AcceptTimeout")) 578 { 579 isAcceptTimeout = false ; 580 } 581 else if (localName.equals("ConnectionTimeout")) 582 { 583 isConnectTimeout = false ; 584 } 585 else if (localName.equals("SOPClass")) 586 { 587 isSOPClass = false ; 588 } 589 else if (localName.equals("QREnable")) 590 { 591 QREnable = false ; 592 } 593 else if (localName.equals("MAX_CLIENT_ASSOCS")) 594 { 595 isMaxClientAssoc = false ; 596 } 597 else if (localName.equals("MAX_PDU_LENGTH_RECEIVE")) 598 { 599 isMaxPDULengthReceive = false ; 600 } 601 else if (localName.equals("MAX_PDU_LENGTH_SEND")) 602 { 603 isMaxPDULengthSend = false; 604 } 605 if (localName.equals("options")) 606 { 607 this.options = false ; 608 } 609 else if (localName.equals("modality") && this.options) 610 { 611 this.modality = false ; 612 } 613 else if (localName.equals("cfind") && this.options && this.modality) 614 { 615 this.cfind = false ; 616 } 617 else if (localName.equals("find") && this.options && this.modality && 618 this.cfind) 619 { 620 this.find = false ; 621 } 622 623 else if(this.options && this.destinations && localName.equals("dest")) 624 { 625 this.dest = false ; 626 } 627 628 else if (this.options && localName.equals("destinations")) 629 { 630 this.destinations = false ; 631 } 632 633 else if (this.priorityAET && localName.equals("CSTOREPriorities")) 634 { 635 this.priorityAET = false ; 636 } 637 638 639 640 else if (isWeb && localName.equals("web")) 641 { 642 this.isWeb = false ; 643 } 644 else if(isRGUIPort && localName.equals("RGUIPort") ) 645 { 646 isRGUIPort = false; 647 } 648 else if(localName.equals("RGUIExtIP")) 649 { 650 isRGUIExtIP = false; 651 } 652 653 654 } 655 656 @Override 657 public void characters( char[] data, int start, int length ) { 658 if (isIndexEffort) { 659 String sEffort = new String(data, start, length); 660 s.setIndexerEffort(Integer.parseInt(sEffort)); 661 return; 662 } 663 if (isPort && !isQRConfigs) { 664 String sPort = new String(data, start, length); 665 s.setStoragePort(Integer.parseInt(sPort)); 666 return; 667 } 668 if (isPort && isQRConfigs) { 669 String sPort = new String(data, start, length); 670 s.setWlsPort(Integer.parseInt(sPort)); 671 return; 672 } 673 if (isEncrypt) { 674 String sView = new String(data, start, length); 675 boolean result = false; 676 677 if (sView.compareToIgnoreCase("true") == 0) 678 result = true; 679 680 s.setEncryptUsersFile(result); 681 return; 682 } 683 684 685 if (isZIPFile) { 686 String sView = new String(data, start, length); 687 boolean result = false; 688 if (sView.compareToIgnoreCase("true") == 0) 689 result = true; 690 s.setIndexZIPFiles(result); 691 return; 692 } 693 694 if (isGZIPStorage) { 695 String sView = new String(data, start, length); 696 boolean result = false; 697 if (sView.compareToIgnoreCase("true") == 0) 698 result = true; 699 s.setGzipStorage(result); 700 return; 701 702 } 703 704 if (isIndexAnonymous) { 705 String sView = new String(data, start, length); 706 boolean result = false; 707 if (sView.compareToIgnoreCase("true") == 0) 708 result = true; 709 s.setIndexAnonymous(result); 710 return; 711 } 712 713 if (isMonitorWatcher) { 714 String sView = new String(data, start, length); 715 boolean result = false; 716 if (sView.compareToIgnoreCase("true") == 0) 717 result = true; 718 s.setMonitorWatcher(result); 719 return; 720 } 721 if (isP2P) { 722 723 if (autoConnect) { 724 String sView = new String(data, start, length); 725 boolean result = false; 726 if (sView.compareToIgnoreCase("true") == 0) 727 result = true; 728// s.setP2P(result); 729 return; 730 731 } else if (maxmsg) { 732 String max = new String(data, start, length); 733 734 735 int maxMsg = Integer.valueOf(max); 736 s.setMaxMessages(maxMsg); 737 return; 738 739 } else if (isNode && isNodeName) { 740 String nodeName = new String(data, start, length); 741 s.setNodeName(nodeName); 742 } else if (isNode && isDefined) { 743 String tmp = new String(data, start, length); 744 boolean result = false; 745 if (tmp.compareToIgnoreCase("true") == 0) 746 result = true; 747 s.setNodeNameDefined(result); 748 return; 749 } 750 } 751 752 if (priorityAET) 753 { 754 String aetitle = new String(data, start, length); 755 s.addPriorityAETitle(aetitle); 756 return; 757 758 } 759 760 if(isStorage) 761 { 762 String sView = new String(data, start, length); 763 boolean result = false; 764 if (sView.compareToIgnoreCase("true") == 0) 765 result = true; 766 s.setStorage(result); 767 return; 768 } 769 if(isDicoogleDir) //( "DicoogleDir" ) ) 770 { 771 String sView = new String(data, start, length); 772 s.setDicoogleDir(sView); 773 return; 774 } 775 if(isFullContentIndex) 776 { 777 String sView = new String(data, start, length); 778 boolean result = false; 779 if (sView.compareToIgnoreCase("true") == 0) 780 result = true; 781 s.setFullContentIndex(result); 782 return; 783 } 784 if(isSaveThumbnails) 785 { 786 String sView = new String(data, start, length); 787 boolean result = false; 788 if (sView.compareToIgnoreCase("true") == 0) 789 result = true; 790 s.setSaveThumbnails(result); 791 return; 792 } 793 if(isThumbnailsMatrix) 794 { 795 String sView = new String(data, start, length); 796 s.setThumbnailsMatrix(sView); 797 return; 798 } 799 if(isAET) 800 { 801 String sAET = new String(data, start, length); 802 if(sAET.equals(" ")) 803 { 804 s.setAE(null); 805 } 806 else 807 { 808 s.setAE(sAET); 809 } 810 return; 811 } 812 if(isCAET) 813 { 814 String sCAET = new String(data, start, length); 815 m.addElement(sCAET); 816 String [] CAET = new String[m.getSize()]; 817 m.copyInto(CAET); 818 s.setCAET(CAET); 819 return; 820 } 821 if(isPermitAllAETitles){ 822 String sPermit = new String(data, start, length); 823 boolean result = false; 824 if (sPermit.compareToIgnoreCase("true") == 0) 825 result = true; 826 s.setPermitAllAETitles(result); 827 return; 828 } 829 if(isPath) 830 { 831 String sPath = new String(data, start, length); 832 if(sPath.equals(" ")) 833 { 834 s.setPath("."); 835 } 836 else 837 { 838 s.setPath(sPath); 839 } 840 return; 841 } 842 if(isTS) 843 { 844 String sTS = new String(data, start, length); 845 if(UID.ImplicitVRLittleEndian.equals(sTS)) 846 { 847 LocalTS.setTS(true, 0); 848 return; 849 } 850 if(UID.ExplicitVRLittleEndian.equals(sTS)) 851 { 852 LocalTS.setTS(true, 1); 853 return; 854 } 855 if(UID.DeflatedExplicitVRLittleEndian.equals(sTS)) 856 { 857 LocalTS.setTS(true, 2); 858 return; 859 } 860 if(UID.ExplicitVRBigEndian.equals(sTS)) 861 { 862 LocalTS.setTS(true, 3); 863 return; 864 } 865 if(UID.JPEGLossless.equals(sTS)) 866 { 867 LocalTS.setTS(true, 4); 868 return; 869 } 870 if(UID.JPEGLSLossless.equals(sTS)) 871 { 872 LocalTS.setTS(true, 5); 873 return; 874 } 875 if(UID.JPEGLosslessNonHierarchical14.equals(sTS)) 876 { 877 LocalTS.setTS(true, 6); 878 return; 879 } 880 if(UID.JPEG2000LosslessOnly.equals(sTS)) 881 { 882 LocalTS.setTS(true, 7); 883 return; 884 } 885 if(UID.JPEGBaseline1.equals(sTS)) 886 { 887 LocalTS.setTS(true, 8); 888 return; 889 } 890 if(UID.JPEGExtended24.equals(sTS)) 891 { 892 LocalTS.setTS(true, 9); 893 return; 894 } 895 if(UID.JPEGLSLossyNearLossless.equals(sTS)) 896 { 897 LocalTS.setTS(true, 10); 898 return; 899 } 900 if(UID.JPEG2000.equals(sTS)) 901 { 902 LocalTS.setTS(true, 11); 903 return; 904 } 905 if(UID.RLELossless.equals(sTS)) 906 { 907 LocalTS.setTS(true, 12); 908 return; 909 } 910 if(UID.MPEG2.equals(sTS)) 911 { 912 LocalTS.setTS(true, 13); 913 return; 914 } 915 } 916 917 /** QueryRetrieve Server */ 918 if (isQRConfigs && QREnable) 919 { 920 String tmp = new String(data, start, length); 921 if(tmp.equals("true")){ 922 s.setQueryRetrive(true); 923 } 924 else{ 925 s.setQueryRetrive(false); 926 //DebugManager.getInstance().debug("QueryRetrieve service is disable by default"); 927 } 928 return; 929 930 } 931 if (isQRConfigs && isSOPClass) 932 { 933 String tmp = new String(data, start, length); 934 return; 935 } 936 if (isQRConfigs && isTransfCap) 937 { 938 return; 939 } 940 941 if (isQRConfigs && options && modality && cfind ) 942 { 943 if (find) 944 { 945 String sop = new String(data, start, length); 946 947 s.addModalityFind(sopId, sop.trim()); 948 return ; 949 } 950 951 } 952 if (isQRConfigs && options && destinations) 953 { 954 return; 955 956 957 } 958 if(isMaxClientAssoc){ 959 String sNumber = new String(data, start, length); 960 s.setMaxClientAssoc(Integer.parseInt(sNumber)); 961 return; 962 } 963 if(isMaxPDULengthReceive){ 964 String sNumber = new String(data, start, length); 965 s.setMaxPDULengthReceive(Integer.parseInt(sNumber)); 966 return; 967 } 968 if(isMaxPDULengthSend){ 969 String sNumber = new String(data, start, length); 970 s.setMaxPDULengthSend(Integer.parseInt(sNumber)); 971 return; 972 } 973 if(isRspDelay){ 974 String sNumber = new String(data, start, length); 975 s.setRspDelay(Integer.parseInt(sNumber)); 976 return; 977 } 978 if(isIdleTimeout){ 979 String sNumber = new String(data, start, length); 980 s.setIdleTimeout(Integer.parseInt(sNumber)); 981 return; 982 } 983 if(isAcceptTimeout){ 984 String sNumber = new String(data, start, length); 985 s.setAcceptTimeout(Integer.parseInt(sNumber)); 986 return; 987 } 988 if(isConnectTimeout){ 989 String sNumber = new String(data, start, length); 990 s.setConnectionTimeout(Integer.parseInt(sNumber)); 991 return; 992 } 993 if(isRGUIPort){ 994 String sPort = new String(data, start, length); 995 s.setRemoteGUIPort(Integer.parseInt(sPort)); 996 return; 997 } 998 if(isRGUIExtIP){ 999 String sPort = new String(data, start, length); 1000 s.setRGUIExternalIP(sPort); 1001 return; 1002 } 1003 if(isWANModeEnabled){ 1004 String a = new String(data, start, length); 1005 boolean b = Boolean.parseBoolean(a); 1006 s.setWanmode(b); 1007 return; 1008 } 1009 1010 } 1011 1012 1013 1014 private String resolveAttrib( String attr, Attributes attribs, String defaultValue) 1015 { 1016 1017 String tmp = attribs.getValue(attr); 1018 1019 1020 1021 return (tmp!=null)?(tmp):(defaultValue); 1022 } 1023 1024 1025 private String resolveAttrib( String uri, String localName, Attributes attribs, String defaultValue) { 1026 String tmp = attribs.getValue("UID"); 1027 return (tmp!=null)?(tmp):(defaultValue); 1028 } 1029 1030 /** 1031 * Worklist Server - Verify if qr is enable 1032 * @param uri 1033 * @param localName 1034 * @param attribs 1035 * @param defaultValue 1036 * @return 1037 */ 1038 private boolean getStatus( String uri, String localName, Attributes attribs, String defaultValue) { 1039 String tmp = attribs.getValue("state"); 1040 return (tmp!=null && tmp.equals("on"))?(true):(false); 1041 } 1042 1043 1044 1045 public ServerSettings getXML() 1046 { 1047 try 1048 { 1049 File file = new File(Platform.homePath() + "config.xml"); 1050 if (!file.exists()) 1051 { 1052 s.setDefaultSettings(); 1053 list.setDefaultSettings(); 1054 printXML(); 1055 return s; 1056 } 1057 InputSource src = new InputSource( new FileInputStream(file) ); 1058 XMLReader r = XMLReaderFactory.createXMLReader(); 1059 r.setContentHandler(this); 1060 r.parse(src); 1061 return s; 1062 } 1063 catch (IOException | SAXException ex) 1064 { 1065 logger.warn("Failed to read XML config file", ex); 1066 } 1067 return null; 1068 } 1069 1070 public void printXML() 1071 { 1072 FileOutputStream out = null; 1073 list.CleanList(); 1074 try { 1075 out = new FileOutputStream(Platform.homePath() + "config.xml"); 1076 PrintWriter pw = new PrintWriter(out); 1077 StreamResult streamResult = new StreamResult(pw); 1078 SAXTransformerFactory tf = (SAXTransformerFactory) TransformerFactory.newInstance(); 1079 // SAX2.0 ContentHandler. 1080 TransformerHandler hd = tf.newTransformerHandler(); 1081 Transformer serializer = hd.getTransformer(); 1082 serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); 1083 serializer.setOutputProperty(OutputKeys.METHOD, "xml"); 1084 serializer.setOutputProperty(OutputKeys.INDENT, "yes"); 1085 serializer.setOutputProperty(OutputKeys.STANDALONE, "yes"); 1086 hd.setResult(streamResult); 1087 hd.startDocument(); 1088 1089 //Get a processing instruction 1090 //hd.processingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"mystyle.xsl\""); 1091 AttributesImpl atts = new AttributesImpl(); 1092 1093 //root element 1094 hd.startElement("", "", "Config", atts); 1095 1096 1097 String curTitle = String.valueOf(s.getStoragePort()); 1098 //port 1099 hd.startElement("", "", "Port", atts); 1100 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1101 hd.endElement("", "", "Port"); 1102 1103 atts.clear(); 1104 hd.startElement("", "", "RemoteGUI", atts); 1105 1106 curTitle = String.valueOf(s.getRemoteGUIPort()); 1107 //GUIport 1108 hd.startElement("", "", "RGUIPort", atts); 1109 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1110 hd.endElement("", "", "RGUIPort"); 1111 1112 1113 curTitle = s.getRGUIExternalIP(); 1114 if(curTitle != null && !curTitle.equals("")) 1115 { 1116 hd.startElement("", "", "RGUIExtIP", atts); 1117 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1118 hd.endElement("", "", "RGUIExtIP"); 1119 } 1120 hd.endElement("", "", "RemoteGUI"); 1121 1122 1123 curTitle = s.getPath(); 1124 //path 1125 hd.startElement("", "", "Path", atts); 1126 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1127 hd.endElement("", "", "Path"); 1128 1129 curTitle = String.valueOf(s.getIndexerEffort()); 1130 //path 1131 hd.startElement("", "", "IndexEffort", atts); 1132 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1133 hd.endElement("", "", "IndexEffort"); 1134 1135 hd.startElement("", "", "IndexZipFiles", atts); 1136 1137 if (s.isIndexZIPFiles()) 1138 curTitle = "true"; 1139 else 1140 curTitle = "false"; 1141 1142 //Enable IndexZipFiles 1143 1144 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1145 1146 hd.endElement("", "", "IndexZipFiles"); 1147 1148 1149 1150 hd.startElement("", "", "GZipStorage", atts); 1151 1152 if (s.isGzipStorage()) 1153 curTitle = "true"; 1154 else 1155 curTitle = "false"; 1156 1157 //Enable IndexZipFiles 1158 1159 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1160 1161 hd.endElement("", "", "GZipStorage"); 1162 1163 1164 1165 1166 1167 hd.startElement("", "", "IndexAnonymous", atts); 1168 1169 if (s.isIndexAnonymous()) 1170 curTitle = "true"; 1171 else 1172 curTitle = "false"; 1173 1174 //Enable IndexZipFiles 1175 1176 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1177 1178 hd.endElement("", "", "IndexAnonymous"); 1179 1180 hd.startElement("", "", "MonitorWatcher", atts); 1181 if (s.isMonitorWatcher()) 1182 curTitle = "true"; 1183 else 1184 curTitle = "false"; 1185 1186 //Enable IndexZipFiles 1187 1188 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1189 1190 hd.endElement("", "", "MonitorWatcher"); 1191 1192 1193 1194 hd.startElement("", "", "EncryptUsersFile", atts); 1195 if (s.isEncryptUsersFile()) 1196 curTitle = "true"; 1197 else 1198 curTitle = "false"; 1199 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1200 hd.endElement("", "", "EncryptUsersFile"); 1201 1202 if (s.isWANModeEnabled()) 1203 curTitle = "true"; 1204 else 1205 curTitle = "false"; 1206 hd.startElement("", "", "WANModeEnabled", atts); 1207 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1208 hd.endElement("", "", "WANModeEnabled"); 1209 1210 hd.startElement("", "", "P2P", atts); 1211 1212 hd.startElement("", "", "AutoConnect", atts); 1213 1214/* if (s.isP2P()) 1215 curTitle = "true"; 1216 else 1217 curTitle = "false";*/ 1218 1219 //Enable P2P 1220 1221 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1222 1223 hd.endElement("", "", "AutoConnect"); 1224 1225 hd.startElement("", "", "MaxMsg", atts); 1226 curTitle = String.valueOf(s.getMaxMessages()); 1227 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1228 1229 hd.endElement("", "", "MaxMsg"); 1230 1231 hd.startElement("", "", "Node", atts); 1232 1233 hd.startElement("", "", "name", atts); 1234 hd.characters(s.getNodeName().toCharArray(), 0, s.getNodeName().length()); 1235 hd.endElement("", "", "name"); 1236 1237 if (s.isNodeNameDefined()) 1238 curTitle = "true"; 1239 else 1240 curTitle = "false"; 1241 hd.startElement("", "", "defined", atts); 1242 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1243 hd.endElement("", "", "defined"); 1244 1245 1246 hd.endElement("", "", "Node"); 1247 1248 1249 hd.endElement("", "", "P2P"); 1250 1251 if (s.isStorage()) 1252 curTitle = "true"; 1253 else 1254 curTitle = "false"; 1255 1256 //Enable P2P 1257 hd.startElement("", "", "Storage", atts); 1258 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1259 hd.endElement("", "", "Storage"); 1260 1261 curTitle = s.getDicoogleDir(); 1262 //Diccogle Scan Dir 1263 hd.startElement("", "", "DicoogleDir", atts); 1264 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1265 hd.endElement("", "", "DicoogleDir"); 1266 1267 1268 curTitle = Boolean.toString(s.getFullContentIndex()); 1269 // FullContentIndex 1270 hd.startElement("", "", "fullContentIndex", atts); 1271 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1272 hd.endElement("", "", "fullContentIndex"); 1273 1274 curTitle = Boolean.toString(s.getSaveThumbnails()); 1275 // saveThumbnails 1276 hd.startElement("", "", "SaveThumbnails", atts); 1277 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1278 hd.endElement("", "", "SaveThumbnails"); 1279 1280 curTitle = s.getThumbnailsMatrix(); 1281 // saveThumbnails 1282 hd.startElement("", "", "ThumbnailsMatrix", atts); 1283 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1284 hd.endElement("", "", "ThumbnailsMatrix"); 1285 1286 curTitle = s.getAE(); 1287 //AET 1288 hd.startElement("", "", "AETitle", atts); 1289 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1290 hd.endElement("", "", "AETitle"); 1291 1292 1293 if (s.getPermitAllAETitles()) 1294 curTitle = "true"; 1295 else 1296 curTitle = "false"; 1297 1298 //Enable P2P 1299 hd.startElement("", "", "PermitAllAETitles", atts); 1300 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1301 hd.endElement("", "", "PermitAllAETitles"); 1302 1303 //Permited Client AETitles 1304 String [] CAET = s.getCAET(); 1305 if(CAET!= null) 1306 { 1307 for(int i=0; i<CAET.length; i++) 1308 { 1309 curTitle = CAET[i]; 1310 hd.startElement("", "", "CAETitle", atts); 1311 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1312 hd.endElement("", "", "CAETitle"); 1313 } 1314 } 1315 1316 1317 List l = list.getKeys(); 1318 boolean [] TS; 1319 int i = l.size()-1; 1320 for(i = l.size()-1; i >= 0; i--) 1321 { 1322 1323 LocalTS = list.getTS(l.get(i).toString()); 1324 if(LocalTS.getAccepted()) 1325 { 1326 atts.addAttribute("", "", "UID", "", l.get(i).toString()); 1327 hd.startElement("", "", "Service", atts); 1328 atts.clear(); 1329 TS = LocalTS.getTS(); 1330 if(TS[0]) 1331 { 1332 hd.startElement("", "", "TS",atts); 1333 hd.characters(UID.ImplicitVRLittleEndian.toCharArray(), 0, UID.ImplicitVRLittleEndian.length()); 1334 hd.endElement("", "", "TS"); 1335 } 1336 if(TS[1]) 1337 { 1338 hd.startElement("", "", "TS",atts); 1339 hd.characters(UID.ExplicitVRLittleEndian.toCharArray(), 0, UID.ExplicitVRLittleEndian.length()); 1340 hd.endElement("", "", "TS"); 1341 } 1342 if(TS[2]) 1343 { 1344 hd.startElement("", "", "TS",atts); 1345 hd.characters(UID.DeflatedExplicitVRLittleEndian.toCharArray(), 0, UID.DeflatedExplicitVRLittleEndian.length()); 1346 hd.endElement("", "", "TS"); 1347 } 1348 if(TS[3]) 1349 { 1350 hd.startElement("", "", "TS",atts); 1351 hd.characters(UID.ExplicitVRBigEndian.toCharArray(), 0, UID.ExplicitVRBigEndian.length()); 1352 hd.endElement("", "", "TS"); 1353 } 1354 if(TS[4]) 1355 { 1356 hd.startElement("", "", "TS",atts); 1357 hd.characters(UID.JPEGLossless.toCharArray(), 0, UID.JPEGLossless.length()); 1358 hd.endElement("", "", "TS"); 1359 } 1360 if(TS[5]) 1361 { 1362 hd.startElement("", "", "TS",atts); 1363 hd.characters(UID.JPEGLSLossless.toCharArray(), 0, UID.JPEGLSLossless.length()); 1364 hd.endElement("", "", "TS"); 1365 } 1366 if(TS[6]) 1367 { 1368 hd.startElement("", "", "TS",atts); 1369 hd.characters(UID.JPEGLosslessNonHierarchical14.toCharArray(), 0, UID.JPEGLosslessNonHierarchical14.length()); 1370 hd.endElement("", "", "TS"); 1371 } 1372 if(TS[7]) 1373 { 1374 hd.startElement("", "", "TS",atts); 1375 hd.characters(UID.JPEG2000LosslessOnly.toCharArray(), 0, UID.JPEG2000LosslessOnly.length()); 1376 hd.endElement("", "", "TS"); 1377 } 1378 if(TS[8]) 1379 { 1380 hd.startElement("", "", "TS",atts); 1381 hd.characters(UID.JPEGBaseline1.toCharArray(), 0, UID.JPEGBaseline1.length()); 1382 hd.endElement("", "", "TS"); 1383 } 1384 if(TS[9]) 1385 { 1386 hd.startElement("", "", "TS",atts); 1387 hd.characters(UID.JPEGExtended24.toCharArray(), 0, UID.JPEGExtended24.length()); 1388 hd.endElement("", "", "TS"); 1389 } 1390 if(TS[10]) 1391 { 1392 hd.startElement("", "", "TS",atts); 1393 hd.characters(UID.JPEGLSLossyNearLossless.toCharArray(), 0, UID.JPEGLSLossyNearLossless.length()); 1394 hd.endElement("", "", "TS"); 1395 } 1396 if(TS[11]) 1397 { 1398 hd.startElement("", "", "TS",atts); 1399 hd.characters(UID.JPEG2000.toCharArray(), 0, UID.JPEG2000.length()); 1400 hd.endElement("", "", "TS"); 1401 } 1402 if(TS[12]) 1403 { 1404 hd.startElement("", "", "TS",atts); 1405 hd.characters(UID.RLELossless.toCharArray(), 0, UID.RLELossless.length()); 1406 hd.endElement("", "", "TS"); 1407 } 1408 if(TS[13]) 1409 { 1410 hd.startElement("", "", "TS",atts); 1411 hd.characters(UID.MPEG2.toCharArray(), 0, UID.MPEG2.length()); 1412 hd.endElement("", "", "TS"); 1413 } 1414 hd.endElement("", "", "Service"); 1415 1416 1417 } 1418 } 1419 1420 1421 // LocalAETName 1422 curTitle = s.getLocalAETName(); 1423 hd.startElement("", "", "LocalAETName", atts); 1424 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1425 hd.endElement("", "", "LocalAETName"); 1426 1427 1428 1429 /** 1430 * Query Retrieve stuff 1431 */ 1432 1433 //Query Retrieve 1434 hd.startElement("", "", "QueryRetrieve", atts); 1435 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1436 1437 curTitle = s.getDeviceDescription(); 1438 // Device Description 1439 curTitle = s.getDeviceDescription(); 1440 hd.startElement("", "", "DeviceDescription", atts); 1441 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1442 hd.endElement("", "", "DeviceDescription"); 1443 1444 if (s.isQueryRetrive()) 1445 curTitle = "true"; 1446 else 1447 curTitle = "false"; 1448 1449 //Enable QueryRetrieve by default 1450 hd.startElement("", "", "QREnable", atts); 1451 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1452 hd.endElement("", "", "QREnable"); 1453 1454 // Port 1455 curTitle = Integer.toString(s.getWlsPort()); 1456 hd.startElement("", "", "Port", atts); 1457 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1458 hd.endElement("", "", "Port"); 1459 1460 // Permited Local Interfaces 1461 curTitle = s.getPermitedLocalInterfaces(); 1462 hd.startElement("", "", "PermitedLocalInterfaces", atts); 1463 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1464 hd.endElement("", "", "PermitedLocalInterfaces"); 1465 1466 curTitle = s.getPermitedRemoteHostnames(); 1467 hd.startElement("", "", "PermitedHostnames", atts); 1468 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1469 hd.endElement("", "", "PermitedHostnames"); 1470 1471 curTitle = Integer.toString(s.getRspDelay()); 1472 hd.startElement("", "", "RspDelay", atts); 1473 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1474 hd.endElement("", "", "RspDelay"); 1475 1476 curTitle = Integer.toString(s.getDIMSERspTimeout()); 1477 hd.startElement("", "", "DIMSERspTimeout", atts); 1478 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1479 hd.endElement("", "", "DIMSERspTimeout"); 1480 1481 curTitle = Integer.toString(s.getIdleTimeout()); 1482 hd.startElement("", "", "IdleTimeout", atts); 1483 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1484 hd.endElement("", "", "IdleTimeout"); 1485 1486 curTitle = Integer.toString(s.getAcceptTimeout()); 1487 hd.startElement("", "", "AcceptTimeout", atts); 1488 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1489 hd.endElement("", "", "AcceptTimeout"); 1490 1491 curTitle = Integer.toString(s.getConnectionTimeout()); 1492 hd.startElement("", "", "ConnectionTimeout", atts); 1493 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1494 hd.endElement("", "", "ConnectionTimeout"); 1495 1496 curTitle = s.getTransfCap(); 1497 hd.startElement("", "", "TRANSF_CAP", atts); 1498 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1499 hd.endElement("", "", "TRANSF_CAP"); 1500 1501 curTitle = s.getSOPClass() ; 1502 hd.startElement("", "", "SOP_CLASS", atts); 1503 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1504 hd.endElement("", "", "SOP_CLASS"); 1505 1506 curTitle = Integer.toString(s.getMaxClientAssoc()); 1507 hd.startElement("", "", "MAX_CLIENT_ASSOCS", atts); 1508 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1509 hd.endElement("", "", "MAX_CLIENT_ASSOCS"); 1510 1511 curTitle = Integer.toString(s.getMaxPDULengthReceive()); 1512 hd.startElement("", "", "MAX_PDU_LENGTH_RECEIVE", atts); 1513 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1514 hd.endElement("", "", "MAX_PDU_LENGTH_RECEIVE"); 1515 1516 curTitle = Integer.toString(s.getMaxPDULenghtSend()); 1517 hd.startElement("", "", "MAX_PDU_LENGTH_SEND", atts); 1518 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1519 hd.endElement("", "", "MAX_PDU_LENGTH_SEND"); 1520 1521 1522 hd.startElement("", "", "Retrieve", atts); 1523 1524 curTitle = s.getSOPClass(); 1525 hd.startElement("", "", "SOPClass", atts); 1526 hd.characters(curTitle.toCharArray(), 0, curTitle.length()); 1527 hd.endElement("", "", "SOPClass"); 1528 1529 1530 hd.endElement("", "", "Retrieve"); 1531 1532 1533 //root element 1534 hd.startElement("", "", "options", atts); 1535 1536 //modality 1537 hd.startElement("", "", "modality", atts); 1538 1539 1540 1541 // cfind 1542 hd.startElement("", "", "cfind", atts); 1543 1544 HashMap<String, String> map = s.getModalityFind(); 1545 for (String sop : map.keySet()) 1546 { 1547 atts.addAttribute("", "", "sop", "", sop); 1548 hd.startElement("", "", "find", atts); 1549 atts.clear(); 1550 String tmp = map.get(sop); 1551 hd.characters(tmp.toCharArray(), 0, tmp.length()); 1552 hd.endElement("", "", "find"); 1553 } 1554 hd.endElement("", "", "cfind"); 1555 1556 1557 hd.endElement("", "", "modality"); 1558 1559 1560 // destinations 1561 1562 hd.startElement("", "", "destinations", atts); 1563 1564 1565 ArrayList<MoveDestination> moves = s.getMoves(); 1566 for (MoveDestination m : moves) 1567 { 1568 1569 atts.clear(); 1570 atts.addAttribute("", "", "ae", "", m.getAETitle()); 1571 atts.addAttribute("", "", "ip", "", m.getIpAddrs()); 1572 atts.addAttribute("", "", "description", "", m.getDescription()); 1573 atts.addAttribute("", "", "public", "",Boolean.toString(m.isIsPublic())); 1574 1575 atts.addAttribute("", "", "port", "", String.valueOf(m.getPort())); 1576 1577 hd.startElement("", "", "dest", atts); 1578 1579 hd.endElement("", "", "dest"); 1580 atts.clear(); 1581 } 1582 1583 1584 hd.endElement("", "", "destinations"); 1585 1586 1587 // CSTOREPriorities 1588 1589 hd.startElement("", "", "CSTOREPriorities", atts); 1590 1591 for (String aet : ServerSettings.getInstance().getPriorityAETitles()) 1592 { 1593 atts.clear(); 1594 hd.startElement("", "", "aetitle", atts); 1595 hd.characters(aet.toCharArray(), 0, aet.length()); 1596 hd.endElement("", "", "aetitle"); 1597 } 1598 1599 hd.endElement("", "", "CSTOREPriorities"); 1600 1601 1602 1603 1604 hd.endElement("", "", "options"); 1605 1606 hd.endElement("", "", "QueryRetrieve"); 1607 1608 1609 /** 1610 * Web (including web server, webservices, etc) 1611 */ 1612 1613 hd.startElement("", "", "web", atts); 1614 1615 1616 ServerSettings.Web web = ServerSettings.getInstance().getWeb() ; 1617 1618 // WebServer 1619 1620 String tmp = "false"; 1621 if (web.isWebServer()) 1622 tmp = "true"; 1623 1624 atts.clear(); 1625 atts.addAttribute("", "", "enable", "", tmp); 1626 atts.addAttribute("", "", "port", "", String.valueOf(web.getServerPort())); 1627 atts.addAttribute("", "", "allowedOrigins", "", web.getAllowedOrigins()); 1628 1629 hd.startElement("", "", "server", atts); 1630 1631 hd.endElement("", "", "server"); 1632 1633 1634 1635 // WebServices 1636 1637 tmp = "false"; 1638 if (web.isWebServices()) 1639 tmp = "true"; 1640 1641 atts.clear(); 1642 atts.addAttribute("", "", "enable", "", tmp); 1643 atts.addAttribute("", "", "port", "", String.valueOf(web.getServicePort())); 1644 1645 hd.startElement("", "", "services", atts); 1646 1647 hd.endElement("", "", "services"); 1648 1649 1650 hd.endElement("", "", "web"); 1651 1652 1653 1654 hd.endElement("", "", "Config"); 1655 1656 hd.endDocument(); 1657 1658 } catch (TransformerConfigurationException ex) { 1659 1660 } catch (SAXException ex) { 1661 1662 } catch (FileNotFoundException ex) { 1663 1664 } finally { 1665 try { 1666 out.close(); 1667 } catch (IOException ex) { 1668 1669 } 1670 } 1671 } 1672}