Skip to content

Commit

Permalink
Remove sdk-ext (#493)
Browse files Browse the repository at this point in the history
- 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
Enet4 authored Aug 11, 2021
1 parent 79cbbac commit 641b857
Show file tree
Hide file tree
Showing 55 changed files with 3,797 additions and 6,645 deletions.
6 changes: 0 additions & 6 deletions dicoogle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,6 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>pt.ua.ieeta</groupId>
<artifactId>dicoogle-sdk-ext</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
Expand Down
363 changes: 179 additions & 184 deletions dicoogle/src/main/java/pt/ua/dicoogle/Main.java
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();
}
}
}
Loading

0 comments on commit 641b857

Please sign in to comment.