-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- move sdk.Utils.Platform class to core Dicoogle, rename imports accordingly - remove legacy constructs which have nothing to do with the current task system - remove `PluginController.addTask` - remove references to TaskQueue and TaskRequest - remove unused imports in PluginController
- Loading branch information
Showing
55 changed files
with
3,797 additions
and
6,645 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,184 +1,179 @@ | ||
/** | ||
* Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ | ||
* | ||
* This file is part of Dicoogle/dicoogle. | ||
* | ||
* Dicoogle/dicoogle is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Dicoogle/dicoogle is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package pt.ua.dicoogle; | ||
|
||
import org.dcm4che2.data.TransferSyntax; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.xml.sax.SAXException; | ||
import pt.ua.dicoogle.DicomLog.LogDICOM; | ||
import pt.ua.dicoogle.DicomLog.LogXML; | ||
import pt.ua.dicoogle.core.AsyncIndex; | ||
import pt.ua.dicoogle.core.TagsXML; | ||
import pt.ua.dicoogle.core.settings.ServerSettingsManager; | ||
import pt.ua.dicoogle.plugins.PluginController; | ||
import pt.ua.dicoogle.sdk.Utils.Platform; | ||
import pt.ua.dicoogle.sdk.settings.server.ServerSettings; | ||
import pt.ua.dicoogle.sdk.utils.TagsStruct; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.InetAddress; | ||
import java.net.URI; | ||
import java.net.UnknownHostException; | ||
|
||
/** | ||
* Main class for Dicoogle | ||
* @author Filipe Freitas | ||
* @author Luís A. Bastião Silva <[email protected]> | ||
* @author Samuel Campos <[email protected]> | ||
* @author Eduardo Pinho <[email protected]> | ||
*/ | ||
public class Main { | ||
private static final Logger logger = LoggerFactory.getLogger(Main.class); | ||
|
||
/** | ||
* Starts the graphical user interface for Dicoogle | ||
* @param args the command line arguments | ||
*/ | ||
public static void main(String[] args) { | ||
// System.setProperty("log4j.configurationFile", "log4j-2.xml"); | ||
// PropertyConfigurator.configure("log4j.properties"); | ||
if (Platform.getMode() == Platform.MODE.BUNDLE) { | ||
File homeDir = new File(Platform.homePath()); | ||
if (!homeDir.exists()) { | ||
homeDir.mkdir(); | ||
} | ||
} | ||
|
||
if (args.length == 0) { | ||
LaunchDicoogle(); | ||
LaunchWebApplication(); | ||
} else { | ||
|
||
if (args[0].equals("-v")) { | ||
LaunchDicoogle(); | ||
LaunchWebApplication(); | ||
} | ||
if (args[0].equals("-s")) { | ||
LaunchDicoogle(); | ||
} else if (args[0].equals("-w") || args[0].equals("--web") || args[0].equals("--webapp")) { | ||
// open browser | ||
LaunchDicoogle(); | ||
LaunchWebApplication(); | ||
} else if (args[0].equals("-h") || args[0].equals("--h") || args[0].equals("-help") | ||
|| args[0].equals("--help")) { | ||
System.out.println("Dicoogle PACS"); | ||
System.out.println(); | ||
System.out.println(" -s : Start the server"); | ||
System.out.println(" -w : Start the server and load web application in default browser (default)"); | ||
} else { | ||
System.out.println("Wrong arguments!"); | ||
System.out.println(); | ||
System.out.println("Dicoogle PACS"); | ||
System.out.println("-s : Start the server"); | ||
System.out.println("-w : Start the server and load web application in default browser (default)"); | ||
} | ||
} | ||
/** Register System Exceptions Hook */ | ||
ExceptionHandler.registerExceptionHandler(); | ||
} | ||
|
||
private static boolean LaunchWebApplication() { | ||
if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { | ||
logger.warn( | ||
"Desktop browsing is not supported in this machine! " + "Request to open web application ignored."); | ||
return false; | ||
} else { | ||
try { | ||
ServerSettings settings = ServerSettingsManager.getSettings(); | ||
URI uri = URI.create("http://localhost:" + settings.getWebServerSettings().getPort()); | ||
Desktop.getDesktop().browse(uri); | ||
return true; | ||
} catch (IOException ex) { | ||
logger.warn("Request to open web application ignored", ex); | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
private static void LaunchDicoogle() { | ||
logger.debug("Starting Dicoogle"); | ||
logger.debug("Loading configuration file: {}", Platform.homePath()); | ||
|
||
/* Load all Server Settings */ | ||
try { | ||
ServerSettingsManager.init(); | ||
} catch (IOException e) { | ||
logger.error("A critical error occurred: cannot initialize server settings.", e); | ||
System.exit(-1); | ||
} | ||
ServerSettings settings = ServerSettingsManager.getSettings(); | ||
|
||
try { | ||
TagsStruct _tags = new TagsXML().getXML(); | ||
|
||
// load DICOM Services Log | ||
LogDICOM ll = new LogXML().getXML(); | ||
|
||
} catch (SAXException | IOException ex) { | ||
logger.error(ex.getMessage(), ex); | ||
} | ||
|
||
/** Verify if it have a defined node */ | ||
if (settings.getArchiveSettings().getNodeName() == null) { | ||
String hostname = "Dicoogle"; | ||
|
||
try { | ||
InetAddress addr = InetAddress.getLocalHost(); | ||
|
||
// Get hostname | ||
hostname = addr.getHostName(); | ||
} catch (UnknownHostException e) {} | ||
|
||
if (Desktop.isDesktopSupported()) { | ||
String response = (String) JOptionPane.showInputDialog(null, "What is the name of the machine?", | ||
"Enter Node name", JOptionPane.QUESTION_MESSAGE, null, null, hostname); | ||
|
||
settings.getArchiveSettings().setNodeName(response); | ||
} | ||
|
||
// Save settings | ||
ServerSettingsManager.saveSettings(); | ||
} | ||
|
||
TransferSyntax.add(new TransferSyntax("1.2.826.0.1.3680043.2.682.1.40", false, false, false, true)); | ||
TransferSyntax.add(new TransferSyntax("1.2.840.10008.1.2.4.70", true, false, false, true)); | ||
TransferSyntax.add(new TransferSyntax("1.2.840.10008.1.2.5.50", false, false, false, true)); | ||
|
||
PluginController.getInstance(); | ||
|
||
// Start the initial Services of Dicoogle | ||
pt.ua.dicoogle.server.ControlServices.getInstance(); | ||
|
||
// Launch Async Index | ||
// It monitors a folder, and when a file is touched an event | ||
// triggers and index is updated. | ||
if (settings.getArchiveSettings().isDirectoryWatcherEnabled()) { | ||
AsyncIndex asyncIndex = new AsyncIndex(); | ||
} | ||
} | ||
|
||
private static void LaunchGUIClient() { | ||
logger.error("Remote GUI is no longer supported: please enter the Dicoogle web application"); | ||
System.exit(-1); | ||
} | ||
} | ||
/** | ||
* Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ | ||
* | ||
* This file is part of Dicoogle/dicoogle. | ||
* | ||
* Dicoogle/dicoogle is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Dicoogle/dicoogle is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package pt.ua.dicoogle; | ||
|
||
import org.dcm4che2.data.TransferSyntax; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.xml.sax.SAXException; | ||
import pt.ua.dicoogle.DicomLog.LogDICOM; | ||
import pt.ua.dicoogle.DicomLog.LogXML; | ||
import pt.ua.dicoogle.core.AsyncIndex; | ||
import pt.ua.dicoogle.core.TagsXML; | ||
import pt.ua.dicoogle.core.settings.ServerSettingsManager; | ||
import pt.ua.dicoogle.plugins.PluginController; | ||
import pt.ua.dicoogle.utils.Platform; | ||
import pt.ua.dicoogle.sdk.settings.server.ServerSettings; | ||
import pt.ua.dicoogle.sdk.utils.TagsStruct; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.InetAddress; | ||
import java.net.URI; | ||
import java.net.UnknownHostException; | ||
|
||
/** | ||
* Main class for Dicoogle | ||
* @author Filipe Freitas | ||
* @author Luís A. Bastião Silva <[email protected]> | ||
* @author Samuel Campos <[email protected]> | ||
* @author Eduardo Pinho <[email protected]> | ||
*/ | ||
public class Main { | ||
private static final Logger logger = LoggerFactory.getLogger(Main.class); | ||
|
||
/** | ||
* Starts the graphical user interface for Dicoogle | ||
* @param args the command line arguments | ||
*/ | ||
public static void main(String[] args) { | ||
// System.setProperty("log4j.configurationFile", "log4j-2.xml"); | ||
// PropertyConfigurator.configure("log4j.properties"); | ||
if (Platform.getMode() == Platform.MODE.BUNDLE) { | ||
File homeDir = new File(Platform.homePath()); | ||
if (!homeDir.exists()) { | ||
homeDir.mkdir(); | ||
} | ||
} | ||
|
||
if (args.length == 0) { | ||
LaunchDicoogle(); | ||
LaunchWebApplication(); | ||
} else { | ||
|
||
if (args[0].equals("-v")) { | ||
LaunchDicoogle(); | ||
LaunchWebApplication(); | ||
} | ||
if (args[0].equals("-s")) { | ||
LaunchDicoogle(); | ||
} else if (args[0].equals("-w") || args[0].equals("--web") || args[0].equals("--webapp")) { | ||
// open browser | ||
LaunchDicoogle(); | ||
LaunchWebApplication(); | ||
} else if (args[0].equals("-h") || args[0].equals("--h") || args[0].equals("-help") | ||
|| args[0].equals("--help")) { | ||
System.out.println("Dicoogle PACS"); | ||
System.out.println(); | ||
System.out.println(" -s : Start the server"); | ||
System.out.println(" -w : Start the server and load web application in default browser (default)"); | ||
} else { | ||
System.out.println("Wrong arguments!"); | ||
System.out.println(); | ||
System.out.println("Dicoogle PACS"); | ||
System.out.println("-s : Start the server"); | ||
System.out.println("-w : Start the server and load web application in default browser (default)"); | ||
} | ||
} | ||
/** Register System Exceptions Hook */ | ||
ExceptionHandler.registerExceptionHandler(); | ||
} | ||
|
||
private static boolean LaunchWebApplication() { | ||
if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { | ||
logger.warn( | ||
"Desktop browsing is not supported in this machine! " + "Request to open web application ignored."); | ||
return false; | ||
} else { | ||
try { | ||
ServerSettings settings = ServerSettingsManager.getSettings(); | ||
URI uri = URI.create("http://localhost:" + settings.getWebServerSettings().getPort()); | ||
Desktop.getDesktop().browse(uri); | ||
return true; | ||
} catch (IOException ex) { | ||
logger.warn("Request to open web application ignored", ex); | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
private static void LaunchDicoogle() { | ||
logger.debug("Starting Dicoogle"); | ||
logger.debug("Loading configuration file: {}", Platform.homePath()); | ||
|
||
/* Load all Server Settings */ | ||
try { | ||
ServerSettingsManager.init(); | ||
} catch (IOException e) { | ||
logger.error("A critical error occurred: cannot initialize server settings.", e); | ||
System.exit(-1); | ||
} | ||
ServerSettings settings = ServerSettingsManager.getSettings(); | ||
|
||
try { | ||
TagsStruct _tags = new TagsXML().getXML(); | ||
|
||
// load DICOM Services Log | ||
LogDICOM ll = new LogXML().getXML(); | ||
|
||
} catch (SAXException | IOException ex) { | ||
logger.error(ex.getMessage(), ex); | ||
} | ||
|
||
/** Verify if it have a defined node */ | ||
if (settings.getArchiveSettings().getNodeName() == null) { | ||
String hostname = "Dicoogle"; | ||
|
||
try { | ||
InetAddress addr = InetAddress.getLocalHost(); | ||
|
||
// Get hostname | ||
hostname = addr.getHostName(); | ||
} catch (UnknownHostException e) {} | ||
|
||
if (Desktop.isDesktopSupported()) { | ||
String response = (String) JOptionPane.showInputDialog(null, "What is the name of the machine?", | ||
"Enter Node name", JOptionPane.QUESTION_MESSAGE, null, null, hostname); | ||
|
||
settings.getArchiveSettings().setNodeName(response); | ||
} | ||
|
||
// Save settings | ||
ServerSettingsManager.saveSettings(); | ||
} | ||
|
||
TransferSyntax.add(new TransferSyntax("1.2.826.0.1.3680043.2.682.1.40", false, false, false, true)); | ||
TransferSyntax.add(new TransferSyntax("1.2.840.10008.1.2.4.70", true, false, false, true)); | ||
TransferSyntax.add(new TransferSyntax("1.2.840.10008.1.2.5.50", false, false, false, true)); | ||
|
||
PluginController.getInstance(); | ||
|
||
// Start the initial Services of Dicoogle | ||
pt.ua.dicoogle.server.ControlServices.getInstance(); | ||
|
||
// Launch Async Index | ||
// It monitors a folder, and when a file is touched an event | ||
// triggers and index is updated. | ||
if (settings.getArchiveSettings().isDirectoryWatcherEnabled()) { | ||
AsyncIndex asyncIndex = new AsyncIndex(); | ||
} | ||
} | ||
} |
Oops, something went wrong.