diff --git a/README.md b/README.md index 4680e2c..ee25266 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,15 @@ EPPClient è un'applicazione desktop Java per l'interazione con i server EPP (Extensible Provisioning Protocol) del Registro .it, a supporto dei Registrar nella gestione di domini, contatti e messaggi EPP. Fornisce un'interfaccia grafica e strumenti idonei alle principali operazioni di registrazione e mantenimento. ## Cos'è e a cosa serve + - Gestione dei domini .it tramite EPP (creazione, aggiornamento, trasferimento, ecc.). - Gestione della rubrica contatti e della messaggistica EPP. - Funzionalità operative a supporto dell'attività quotidiana del Registrar. ## Origini del progetto + Il progetto nasce come rimodernizzazione del software originale sviluppato dall'associazione [AssoTLD](https://www.assotld.it/) per i propri soci. Il software è stato aggiornato e rilasciato come software libero, con l'aggiunta di varie funzionalità, tra cui il supporto a DNSSEC, la gestione dei domini .gov.it e .edu.it e l'esportazione del database in formato CSV, oltre all'aggiornamento di tutte le dipendenze obsolete. + ## Licenze - Le informazioni dettagliate sono disponibili nella cartella `LICENSES/` alla radice del progetto e nel file `REUSE.toml` (convenzioni [REUSE](https://reuse.software/)). @@ -31,16 +34,21 @@ Il nome esatto del JAR da utilizzare è indicato nel file `build.gradle` alla se Per la compilazione e l'esecuzione in ambiente di sviluppo si utilizza Gradle. ### Requisiti + - Java 21 ### Esecuzione in sviluppo + Per avviare l'applicazione direttamente tramite Gradle, eseguire: + ```bash ./gradlew run ``` ### Compilazione + Per compilare il progetto senza eseguirlo: + ```bash ./gradlew build ``` @@ -52,24 +60,62 @@ Per compilare il progetto senza eseguirlo: Il "fat jar" è un file JAR che include tutte le dipendenze necessarie per eseguire l'applicazione in modo autonomo. ### Generazione del Jar eseguibile + Per generare il fat jar, eseguire il comando: + ```bash ./gradlew shadowJar ``` + Al termine, il file generato sarà disponibile nella cartella: `build/libs/` Il nome del file sarà simile a: `eppclient--all.jar` -(Esempio: `eppclient-2.3.1-SNAPSHOT-all.jar`) +(Esempio: `eppclient-2.3.1-all.jar`) ### Esecuzione del Fat Jar + Per eseguire l'applicazione utilizzare il comando `java -jar`: + ```bash java -jar build/libs/eppclient--all.jar ``` -*(Verificare il nome del file generato presente nella cartella build/libs)* + +_(Verificare il nome del file generato presente nella cartella build/libs)_ + +--- + +## Opzioni di log e debug + +L'applicazione registra i messaggi sia su console che su file simultaneamente. Il livello di log predefinito è `INFO`. + +### Configurazione del livello di log + +Per cambiare il livello di log, utilizzare il flag `-Deppclient.logLevel`: + +```bash +java -Deppclient.logLevel=DEBUG -jar build/libs/eppclient--all.jar +``` + +### Logging su file (NDJSON) + +I log vengono salvati in formato NDJSON nel file `logs/eppclient.log` con rotazione giornaliera (mantenuti per un massimo di 30 giorni). +Questo formato strutturato include i campi: `timestamp`, `loglevel`, `logger`, `message`, `thread`, `stackTrace`. + +### Livelli di log disponibili + +- `ERROR` - Solo errori +- `WARN` - Warning e errori +- `INFO` - Info, warning e errori +- `DEBUG` - Messaggi di debug completi +- `TRACE` - Trace dettagliato +- `OFF` - Disabilita il logging + +### Visualizzatore log integrato + +Quando il debug logging è abilitato, appare automaticamente il pulsante "Apri Log" nella schermata principale che apre il visualizzatore dei log con filtro per livello. --- @@ -98,18 +144,23 @@ Il progetto Derby è stato abbandonato nel 2025. Per il momento si è deciso di ## Software Bill of Materials (SBOM) Componenti e versioni principali attualmente in uso (si veda `build.gradle`): -- org.apache.xmlbeans:xmlbeans:3.1.0 -- org.apache.httpcomponents:httpclient:4.5.14 -- org.apache.httpcomponents:httpcore:4.4.16 -- epp-client-cmd-line:1.19.1 (Fornito dal Registro .it, JAR locale da collocare in `libs/`) + +- ch.qos.logback:logback-classic:1.5.32 +- ch.qos.logback:logback-core:1.5.32 +- com.google.code.gson:gson:2.13.2 +- com.mysql:mysql-connector-j:9.6.0 - org.apache.derby:derby:10.17.1.0 - org.apache.derby:derbytools:10.17.1.0 +- org.apache.httpcomponents:httpclient:4.5.14 +- org.apache.httpcomponents:httpcore:4.4.16 +- org.apache.xmlbeans:xmlbeans:3.1.0 +- net.logstash.logback:logstash-logback-encoder:9.0 - org.slf4j:slf4j-api:2.0.17 -- org.slf4j:slf4j-simple:2.0.17 -- com.google.code.gson:gson:2.13.2 +- epp-client-cmd-line:1.19.1 (Fornito dal Registro .it, JAR locale da collocare in `libs/`) - test: org.junit:junit-bom:5.10.0; org.junit.jupiter:junit-jupiter Runtime/Build: + - Java 21 --- diff --git a/build.gradle b/build.gradle index b2274e3..8769c4d 100644 --- a/build.gradle +++ b/build.gradle @@ -19,16 +19,18 @@ repositories { } dependencies { - implementation('org.apache.xmlbeans:xmlbeans:3.1.0') - implementation('org.apache.httpcomponents:httpclient:4.5.14') - implementation('org.apache.httpcomponents:httpcore:4.4.16') - implementation(files('libs/epp-client-cmd-line-1.19.1.jar')) + implementation('ch.qos.logback:logback-classic:1.5.32') + implementation('ch.qos.logback:logback-core:1.5.32') + implementation('com.google.code.gson:gson:2.13.2') + implementation('org.mariadb.jdbc:mariadb-java-client:3.5.7') implementation('org.apache.derby:derby:10.17.1.0') implementation('org.apache.derby:derbytools:10.17.1.0') + implementation('org.apache.httpcomponents:httpclient:4.5.14') + implementation('org.apache.httpcomponents:httpcore:4.4.16') + implementation('org.apache.xmlbeans:xmlbeans:3.1.0') + implementation('net.logstash.logback:logstash-logback-encoder:9.0') implementation('org.slf4j:slf4j-api:2.0.17') - implementation('org.slf4j:slf4j-simple:2.0.17') - implementation('com.google.code.gson:gson:2.13.2') - implementation('org.mariadb.jdbc:mariadb-java-client:3.5.7') + implementation(files('libs/epp-client-cmd-line-1.19.1.jar')) testImplementation platform('org.junit:junit-bom:5.10.0') testImplementation 'org.junit.jupiter:junit-jupiter' @@ -99,4 +101,4 @@ jar { manifest { attributes('Main-Class': application.mainClass) } -} \ No newline at end of file +} diff --git a/src/main/java/EPPClient/ErrorHandler.java b/src/main/java/EPPClient/ErrorHandler.java new file mode 100644 index 0000000..07223d1 --- /dev/null +++ b/src/main/java/EPPClient/ErrorHandler.java @@ -0,0 +1,93 @@ +/* + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + * This file is part of EPPClient. + * + * EPPClient 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. + * + * EPPClient 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 EPPClient. If not, see . + */ + +package EPPClient; + +import java.awt.Component; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import org.slf4j.Logger; + +/** + * Centralized error handling utility class. + * Provides dialog display for errors - logging is done directly via SLF4J. + */ +public class ErrorHandler +{ + + /** + * Default message shown to users when an error occurs. + */ + public static final String DEFAULT_USER_MESSAGE = "Si è verificato un errore durante l'operazione.\n\n" + "Consultare i log per maggiori dettagli."; + + /** + * Logs an error and shows a dialog to the user. + * The exception is logged at ERROR level with full stack trace. + * + * @param logger The SLF4J logger instance + * @param exception The exception that occurred + * @param userTitle The title for the error dialog + * @param parent The parent frame for the dialog + */ + public static void error(Logger logger, Exception exception, String userTitle, JFrame parent) + { + logger.error("Error occurred: {}", exception.getMessage(), exception); + showErrorDialog(parent, userTitle); + } + + /** + * Logs an error without showing a dialog. + * + * @param logger The SLF4J logger instance + * @param exception The exception that occurred + */ + public static void logError(Logger logger, Exception exception) + { + logger.error("Error occurred: {}", exception.getMessage(), exception); + } + + /** + * Shows an error dialog to the user + * + * @param parent The parent component for the dialog + * @param title The title of the dialog + */ + public static void showErrorDialog(Component parent, String title, String message) { + JOptionPane optionPane = new JOptionPane( + message, + JOptionPane.ERROR_MESSAGE, + JOptionPane.DEFAULT_OPTION, + null, + new Object[]{"OK"}, + "OK" + ); + + JDialog dialog = optionPane.createDialog(parent, title); + dialog.setResizable(false); + dialog.setVisible(true); + dialog.dispose(); + } + + /** + * Shows an error dialog to the user with the default message. + * Delegates to {@link #showErrorDialog(Component, String, String)}. + * + * @param parent The parent component for the dialog + * @param title The title of the dialog + */ + public static void showErrorDialog(Component parent, String title) + { + showErrorDialog(parent, title, DEFAULT_USER_MESSAGE); + } +} diff --git a/src/main/java/EPPClient/UpdateChecker.java b/src/main/java/EPPClient/UpdateChecker.java index 7589cc6..a4ddb55 100644 --- a/src/main/java/EPPClient/UpdateChecker.java +++ b/src/main/java/EPPClient/UpdateChecker.java @@ -27,9 +27,13 @@ import java.net.URL; import java.util.ArrayList; import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class UpdateChecker { + private static final Logger log = LoggerFactory.getLogger(UpdateChecker.class); + private static final String GITHUB_API_URL = "https://api.github.com/repos/CodeToTime/EPPClient/releases"; public static void checkForUpdates(Component parent, String currentVersion) { @@ -46,7 +50,7 @@ public static void checkForUpdates(Component parent, String currentVersion) { } } catch (Exception e) { // Silenziosamente ignora errori di rete - System.err.println("Errore durante il controllo aggiornamenti: " + e.getMessage()); + log.warn("Errore durante il controllo aggiornamenti: {}", e.getMessage()); } }).start(); } diff --git a/src/main/java/EPPClient/config/EPPparams.java b/src/main/java/EPPClient/config/EPPparams.java index a76ac31..7f00566 100644 --- a/src/main/java/EPPClient/config/EPPparams.java +++ b/src/main/java/EPPClient/config/EPPparams.java @@ -18,9 +18,12 @@ import java.util.MissingResourceException; import java.util.ResourceBundle; import java.util.prefs.Preferences; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EPPparams { + private static final Logger log = LoggerFactory.getLogger(EPPparams.class); private static final String BUNDLE_NAME = "EPPClient.config.EPPparams"; private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); @@ -37,7 +40,7 @@ public class EPPparams } catch (ClassNotFoundException e) { - e.printStackTrace(); + log.error("Class not found", e); } } @@ -50,7 +53,8 @@ public static void setPrefix(String INparamPrefix) public static String getParameter(String key) { - + String parameterValue = ""; + try { try @@ -59,59 +63,67 @@ public static String getParameter(String key) } catch (java.util.prefs.BackingStoreException ex) { - ex.printStackTrace(); + log.error("BackingStoreException in getParameter", ex); } - String parameterValue = new String(prefs.getByteArray(paramPrefix + key, new byte[0])); - try + String storedValue = new String(prefs.getByteArray(paramPrefix + key, new byte[0])); + + if (storedValue.length() > 0) { - if (parameterValue.length() > 0) - { - parameterValue = CryptoUtils.decrypt(parameterValue); - } - else + try { - try + String decryptedValue = CryptoUtils.decrypt(storedValue); + if (decryptedValue != null && !decryptedValue.isEmpty()) { - parameterValue = RESOURCE_BUNDLE.getString(key); + parameterValue = decryptedValue; + log.debug("Successfully decrypted parameter: {}", key); } - catch (MissingResourceException e) + else { - parameterValue = ""; - } - setParameter(key, parameterValue); - try - { - prefs.sync(); - } - catch (java.util.prefs.BackingStoreException ex) - { - ex.printStackTrace(); + log.warn("Decrypted value is empty for key {}, falling back to resource bundle", key); + throw new Exception("Decrypted value is empty"); } } + catch (Exception decryptEx) + { + log.warn("Decryption failed for key {}, falling back to resource bundle: {}", key, decryptEx.getMessage()); + // Fall through to load from resource bundle + } } - catch (Exception e) + + // Final check: if parameterValue is still empty, use resource bundle + if (parameterValue.isEmpty()) { - e.printStackTrace(); + log.debug("Parameter value is empty for key {}, loading from resource bundle", key); + try + { + parameterValue = RESOURCE_BUNDLE.getString(key); + log.debug("Loaded parameter from resource bundle: {}", key); + // Save the fallback value to preferences + setParameter(key, parameterValue); + } + catch (MissingResourceException e) + { + log.error("Missing parameter in resource bundle: {}", key); + parameterValue = ""; + } } - - return parameterValue; } - catch (MissingResourceException e) + catch (Exception e) { - e.printStackTrace(); - setParameter(paramPrefix + key, RESOURCE_BUNDLE.getString(key)); - //prefs.put (key, RESOURCE_BUNDLE.getString(key)); + log.error("Error in getParameter for key {}: {}", key, e.getMessage(), e); + // Final fallback attempt try { - prefs.sync(); + parameterValue = RESOURCE_BUNDLE.getString(key); } - catch (java.util.prefs.BackingStoreException ex) + catch (MissingResourceException ex) { - ex.printStackTrace(); + parameterValue = ""; } - return RESOURCE_BUNDLE.getString(key); } + + return parameterValue; } public static void setParameter(String key, String value) @@ -127,15 +139,16 @@ public static void setParameter(String key, String value) } catch (java.util.prefs.BackingStoreException ex) { - ex.printStackTrace(); + log.error("BackingStoreException in setParameter", ex); } } catch (MissingResourceException e) { + log.error("MissingResourceException in setParameter", e); } catch (Exception e) { - e.printStackTrace(); + log.error("Error in setParameter", e); } } diff --git a/src/main/java/EPPClient/config/manageParameters.java b/src/main/java/EPPClient/config/manageParameters.java index 9cad8c3..ece4fd4 100644 --- a/src/main/java/EPPClient/config/manageParameters.java +++ b/src/main/java/EPPClient/config/manageParameters.java @@ -16,24 +16,39 @@ package EPPClient.config; import EPPClient.CustomLogin; +import EPPClient.ErrorHandler; import EPPClient.main; -import it.nic.epp.client.commands.session.Login; import it.nic.epp.client.commands.session.Logout; import it.nic.epp.client.httpClient.Client; import it.nic.epp.client.responses.HttpBaseResponse; -import java.net.URI; -import java.net.URISyntaxException; -import org.apache.xmlbeans.XmlException; - -import javax.swing.*; -import javax.swing.border.EtchedBorder; -import java.awt.*; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JTextField; +import javax.swing.WindowConstants; +import javax.swing.border.EtchedBorder; +import org.apache.xmlbeans.XmlException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class manageParameters extends JFrame implements WindowListener { + private static final Logger log = LoggerFactory.getLogger(manageParameters.class); main mainFrame; private boolean isKillRequired; @@ -401,16 +416,15 @@ else if (EPPparams.getParameter("EppClient.defaultPassword").equals(newPassword) login.setNewPW(newPassword); // send the login command - //System.out.println("CLIENT: "+ login.toString() + "\n"); - System.out.println("CLIENT: *LOGIN w/CHANGE PWD COMMAND OMITTED*\n"); + log.info("CLIENT: *LOGIN w/CHANGE PWD COMMAND OMITTED*"); HttpBaseResponse response = client.sendCommand(login); - System.out.println("SERVER: " + response.toString()); + log.info("SERVER: {}", response.toString()); // send the logout command with verbose interaction Logout logout = new Logout(); - System.out.println("CLIENT: " + logout.toString() + "\n"); + log.info("CLIENT: {}", logout.toString()); response = client.sendCommand(logout); - System.out.println("SERVER: " + response.toString()); + log.info("SERVER logout: {}", response.toString()); defaultPassword.setText(newPassword); EPPparams.setParameter("EppClient.defaultPassword", defaultPassword.getText()); @@ -420,15 +434,19 @@ else if (EPPparams.getParameter("EppClient.defaultPassword").equals(newPassword) } catch (NullPointerException v) { + ErrorHandler.error(log, v, "Error changing password", this); } catch (URISyntaxException v) { + ErrorHandler.error(log, v, "Error changing password", this); } catch (XmlException v) { + ErrorHandler.error(log, v, "Error changing password", this); } catch (IOException v) { + ErrorHandler.error(log, v, "Error changing password", this); } } } @@ -516,29 +534,33 @@ private void saveParameters() EPPparams.setParameter("EppClient.proxyHost", proxyHost.getText()); + // Handle proxyPort - save as string, validate if numeric + String proxyPortValue = proxyPort.getText().trim(); try { - EPPparams.setParameter("EppClient.proxyPort", Integer.toString(Integer.parseInt(proxyPort.getText()))); + Integer.parseInt(proxyPortValue); } - catch (Exception ex) + catch (NumberFormatException ex) { - //do nothing... don't save this parameter! - proxyPort.setText(EPPparams.getParameter("EppClient.proxyPort")); + proxyPortValue = ""; // Treat invalid numeric values as empty string } + EPPparams.setParameter("EppClient.proxyPort", proxyPortValue); EPPparams.setParameter("EppClient.contactPrefix", contactPrefix.getText()); EPPparams.setParameter("EppClient.defaultTech", defaultTech.getText()); EPPparams.setParameter("EppClient.defaultNS", defaultNS.getText()); + // Handle refreshInterval - save as string, validate if numeric + String refreshValue = refreshInterval.getText().trim(); try { - EPPparams.setParameter("EppClient.refreshInterval", Integer.toString(Integer.parseInt(refreshInterval.getText()))); + Integer.parseInt(refreshValue); } - catch (Exception ex) + catch (NumberFormatException ex) { - //do nothing... don't save this parameter! - refreshInterval.setText(EPPparams.getParameter("EppClient.refreshInterval")); + refreshValue = ""; // Treat invalid numeric values as empty string } + EPPparams.setParameter("EppClient.refreshInterval", refreshValue); EPPparams.setParameter("EppClient.dbengine", Integer.toString(dbengine.getSelectedIndex())); EPPparams.setParameter("EppClient.dbname", dbname.getText()); diff --git a/src/main/java/EPPClient/contacts/ContactsManagement.java b/src/main/java/EPPClient/contacts/ContactsManagement.java index d38f2e9..115aa4e 100644 --- a/src/main/java/EPPClient/contacts/ContactsManagement.java +++ b/src/main/java/EPPClient/contacts/ContactsManagement.java @@ -15,10 +15,9 @@ package EPPClient.contacts; +import EPPClient.main; import EPPClient.db.contactsDao; import EPPClient.importer.ImportContact; -import EPPClient.logger; -import EPPClient.main; import EPPClient.uplink.EPPuplink; import it.nic.epp.client.commands.query.ContactCheck; import it.nic.epp.client.commands.query.ContactInfo; @@ -29,18 +28,23 @@ import it.nic.epp.client.responses.ext.ContactInfoResponseExt; import it.nic.epp.client.responses.resData.ContactCheckResponseResData; import it.nic.epp.client.responses.resData.ContactInfoResponseResData; -import org.apache.xmlbeans.XmlException; - -import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import java.awt.*; +import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.IOException; import java.util.List; +import javax.swing.GroupLayout; +import javax.swing.JFrame; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.LayoutStyle; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import org.apache.xmlbeans.XmlException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ContactsManagement extends JFrame implements ActionListener, ListSelectionListener { @@ -67,7 +71,7 @@ public ContactsManagement(main mainFrame) refreshContactList(); - logger = new logger("CONTACT"); + log = LoggerFactory.getLogger(ContactsManagement.class); } /** @@ -184,9 +188,9 @@ private void deleteAddress() */ ContactDelete contactDelete = new ContactDelete(); contactDelete.setId(contactId); - logger.logmessage("CLIENT: " + contactDelete.toString() + "\n"); + log.debug("CLIENT: {}", contactDelete); HttpBaseResponse response = EPPuplink.sendCommand(contactDelete); - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.debug("SERVER: {}", response); if (response.isSuccessfully()) { @@ -274,7 +278,7 @@ private void saveAddress() try { HttpBaseResponse response = EPPuplink.sendCommand(contactCheck); - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.debug("SERVER: {}", response); if (response.isSuccessfully()) { ContactCheckResponseResData resData = (ContactCheckResponseResData) response.getResponseResData(); @@ -317,9 +321,9 @@ private void saveAddress() contactCreate.setExtRegistrant(address.getNationalityCode(), address.getEntityType(), address.getRegCode()); } - logger.logmessage("CLIENT: " + contactCreate.toString() + "\n"); + log.debug("CLIENT: {}", contactCreate); HttpBaseResponse response = EPPuplink.sendCommand(contactCreate); - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.debug("SERVER: {}", response); if (response.isSuccessfully()) { @@ -366,7 +370,7 @@ private void saveAddress() ContactInfo contactInfo = new ContactInfo(); contactInfo.setId(address.getContactId()); HttpBaseResponse response = EPPuplink.sendCommand(contactInfo); - logger.logmessage("ContactInfo PRIMA: " + response.toString() + "\n"); + log.debug("ContactInfo PRIMA: {}", response); ContactInfoResponseResData contactInfoResData = (ContactInfoResponseResData) response.getResponseResData(); ContactInfoResponseExt contactInfoExt = (ContactInfoResponseExt) response.getResponseExtension(); @@ -434,9 +438,9 @@ private void saveAddress() if (updateMigrated) { - logger.logmessage("CLIENT: " + contactUpdate.toString() + "\n"); + log.debug("CLIENT: {}", contactUpdate); response = EPPuplink.sendCommand(contactUpdate); - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.debug("SERVER: {}", response); if (!response.isSuccessfully()) { @@ -476,9 +480,9 @@ else if (address.getEntityType() != 1) contactUpdate.setExtConsForPub(address.getConsentForPublishing()); - logger.logmessage("CLIENT: " + contactUpdate.toString() + "\n"); + log.debug("CLIENT: {}", contactUpdate); response = EPPuplink.sendCommand(contactUpdate); - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.debug("SERVER: {}", response); if (response.isSuccessfully()) @@ -503,16 +507,16 @@ else if (address.getEntityType() != 1) } catch (NullPointerException v) { - v.printStackTrace(); + log.error("NullPointerException in saveAddress", v); } catch (XmlException v) { - v.printStackTrace(); + log.error("XmlException in saveAddress", v); } catch (IOException v) { JOptionPane.showMessageDialog(this, v.getCause().toString()); - v.printStackTrace(); + log.error("IOException in saveAddress", v); } } } @@ -529,9 +533,9 @@ private void checkContact() contactCheck.addId(contactId); } - logger.logmessage("CLIENT: " + contactCheck.toString() + "\n"); + log.debug("CLIENT: {}", contactCheck); HttpBaseResponse response = EPPuplink.sendCommand(contactCheck); - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.debug("SERVER: {}", response); if (response.isSuccessfully()) { @@ -584,9 +588,9 @@ private void infoContact() try { ContactInfo contactInfo = new ContactInfo(contactId); - logger.logmessage("CLIENT: " + contactInfo.toString() + "\n"); + log.debug("CLIENT: {}", contactInfo); HttpBaseResponse response = EPPuplink.sendCommand(contactInfo); - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.debug("SERVER: {}", response); if (response.isSuccessfully()) { @@ -686,7 +690,7 @@ private void parseContactResult(HttpBaseResponse response) } catch (Exception e) { - e.printStackTrace(); + log.error("Error in parseContactResult", e); } } @@ -791,6 +795,6 @@ public void windowClosing(WindowEvent e) private AddressPanel addressPanel; private AddressListPanel addressListPanel; // End of variables declaration//GEN-END:variables - private logger logger; + private Logger log; private EPPuplink EPPuplink; } diff --git a/src/main/java/EPPClient/db/contactsDao.java b/src/main/java/EPPClient/db/contactsDao.java index 223a517..ca893ee 100644 --- a/src/main/java/EPPClient/db/contactsDao.java +++ b/src/main/java/EPPClient/db/contactsDao.java @@ -18,15 +18,26 @@ import EPPClient.config.EPPparams; import EPPClient.contacts.Address; import EPPClient.contacts.ListEntry; - import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.sql.*; -import java.util.*; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; +import java.util.MissingResourceException; +import java.util.Properties; +import java.util.ResourceBundle; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class contactsDao { + private static final Logger log = LoggerFactory.getLogger(contactsDao.class); private static final String BUNDLE_NAME = "EPPClient.db.contacts"; @@ -148,7 +159,7 @@ public contactsDao(String addressBookName) } else { - // Aggiorna lo schema: aggiunge le colonne mancanti se non esistono + // Update schema: add missing columns if they don't exist String tableName = dbProperties.getProperty("db.table"); String fullTableName = dbProperties.getProperty("db.schema") + "." + tableName; @@ -160,14 +171,14 @@ public contactsDao(String addressBookName) } /** - * Verifica se una colonna esiste nella tabella specificata. - * Gestisce le differenze di case-sensitivity tra Derby (maiuscolo) e MySQL/MariaDB (minuscolo). + * Checks if a column exists in the specified table. + * Handles case-sensitivity differences between Derby (uppercase) and MySQL (lowercase). */ private boolean columnExists(Connection conn, String tableName, String columnName) { try { - // Prova prima con il nome tabella originale (funziona per MySQL/MariaDB con nomi minuscoli) + // Try first with original table name (works for MySQL with lowercase names) ResultSet columns = conn.getMetaData().getColumns(null, null, tableName, null); while (columns.next()) { @@ -179,7 +190,7 @@ private boolean columnExists(Connection conn, String tableName, String columnNam } columns.close(); - // Prova con il nome tabella in maiuscolo (funziona per Derby) + // Try with uppercase table name (works for Derby) columns = conn.getMetaData().getColumns(null, null, tableName.toUpperCase(), null); while (columns.next()) { @@ -193,19 +204,19 @@ private boolean columnExists(Connection conn, String tableName, String columnNam } catch (SQLException ex) { - ex.printStackTrace(); + log.error("Error checking column existence", ex); } return false; } /** - * Aggiunge una colonna alla tabella se non esiste già. + * Adds a column to the table if it doesn't already exist. */ private void addColumnIfNotExists(Connection conn, String tableName, String columnName, String columnType) { if (columnExists(conn, tableName, columnName)) { - return; // La colonna esiste già, niente da fare + return; // Column already exists, nothing to do } String fullTableName = dbProperties.getProperty("db.schema") + "." + tableName; @@ -214,12 +225,12 @@ private void addColumnIfNotExists(Connection conn, String tableName, String colu { statement = conn.createStatement(); statement.execute("ALTER TABLE " + fullTableName + " ADD COLUMN " + columnName + " " + columnType); - System.out.println("Aggiunta colonna " + columnName + " alla tabella " + fullTableName); + log.debug("Added column {} to table {}", columnName, fullTableName); } catch (SQLException ex) { - // La colonna potrebbe già esistere (race condition) o altro errore - ex.printStackTrace(); + // Column may already exist (race condition) or other error + log.error("Error adding column to table", ex); } finally { @@ -246,11 +257,11 @@ private boolean tableExists(Connection dbConnection, String tableName) } catch (SQLException ex) { - ex.printStackTrace(); + log.error("Error checking table existence", ex); } catch (Exception ex) { - ex.printStackTrace(); + log.error("Error checking table existence", ex); } return tableExists; @@ -296,12 +307,12 @@ private void loadDatabaseDriver(String driverName) } catch (ClassNotFoundException e) { - ex.printStackTrace(); + log.error("Database driver not found: {}", e.getMessage(), e); } } else { - ex.printStackTrace(); + log.error("Database driver not found", ex); } } @@ -333,7 +344,7 @@ private Properties loadDBProperties() } catch (IOException ex) { - ex.printStackTrace(); + log.error("Error loading database properties", ex); } return dbProperties; } @@ -352,7 +363,7 @@ private boolean createTables(Connection dbConnection) } catch (SQLException ex) { - ex.printStackTrace(); + log.error("Error creating tables", ex); } disconnect(); return bCreatedTables; @@ -369,7 +380,7 @@ public boolean dropTables() } catch (SQLException ex) { - ex.printStackTrace(); + log.error("Error dropping tables", ex); } return bDroppedTables; } @@ -413,8 +424,7 @@ public boolean connect() catch (SQLException ex) { isConnected = false; - System.out.println("errore!!"); - ex.printStackTrace(); + log.error("Failed to connect to database: {}", ex.getMessage(), ex); } return isConnected; } @@ -491,7 +501,7 @@ public String saveRecord(Address record) } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error saving contact record", sqle); } return record.getContactId(); } @@ -543,7 +553,7 @@ public boolean editRecord(Address record) } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error editing contact record", sqle); } return bEdited; @@ -561,7 +571,7 @@ public boolean deleteRecord(String contactID) } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error deleting contact record", sqle); } return bDeleted; @@ -605,7 +615,7 @@ public List getSelectiveEntries(String preparedStatement) } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error getting contact list entries", sqle); } @@ -673,7 +683,7 @@ public Address getAddress(String contactId) } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error getting address", sqle); } return address; diff --git a/src/main/java/EPPClient/db/domainsDao.java b/src/main/java/EPPClient/db/domainsDao.java index 3a1800a..0ecd33f 100644 --- a/src/main/java/EPPClient/db/domainsDao.java +++ b/src/main/java/EPPClient/db/domainsDao.java @@ -18,15 +18,27 @@ import EPPClient.config.EPPparams; import EPPClient.domains.Domain; import EPPClient.domains.ListEntry; - import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.sql.*; -import java.util.*; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; +import java.util.MissingResourceException; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.Vector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class domainsDao { + private static final Logger log = LoggerFactory.getLogger(domainsDao.class); private static final String BUNDLE_NAME = "EPPClient.db.domains"; @@ -129,7 +141,7 @@ public domainsDao(String addressBookName) } else { - // Aggiorna lo schema: aggiunge le colonne mancanti se non esistono + // Update schema: add missing columns if they don't exist String tableName = dbProperties.getProperty("db.table"); addColumnIfNotExists(dbConnection, tableName, "EXPIRE", "DATE"); @@ -144,14 +156,14 @@ public domainsDao(String addressBookName) } /** - * Verifica se una colonna esiste nella tabella specificata. - * Gestisce le differenze di case-sensitivity tra Derby (maiuscolo) e MySQL/MariaDB (minuscolo). + * Checks if a column exists in the specified table. + * Handles case-sensitivity differences between Derby (uppercase) and MySQL (lowercase). */ private boolean columnExists(Connection conn, String tableName, String columnName) { try { - // Prova prima con il nome tabella originale (funziona per MySQL/MariaDB con nomi minuscoli) + // Try first with original table name (works for MySQL with lowercase names) ResultSet columns = conn.getMetaData().getColumns(null, null, tableName, null); while (columns.next()) { @@ -163,7 +175,7 @@ private boolean columnExists(Connection conn, String tableName, String columnNam } columns.close(); - // Prova con il nome tabella in maiuscolo (funziona per Derby) + // Try with uppercase table name (works for Derby) columns = conn.getMetaData().getColumns(null, null, tableName.toUpperCase(), null); while (columns.next()) { @@ -177,19 +189,19 @@ private boolean columnExists(Connection conn, String tableName, String columnNam } catch (SQLException ex) { - ex.printStackTrace(); + log.error("Error checking column existence", ex); } return false; } /** - * Aggiunge una colonna alla tabella se non esiste già. + * Adds a column to the table if it doesn't already exist. */ private void addColumnIfNotExists(Connection conn, String tableName, String columnName, String columnType) { if (columnExists(conn, tableName, columnName)) { - return; // La colonna esiste già, niente da fare + return; // Column already exists, nothing to do } String fullTableName = dbProperties.getProperty("db.schema") + "." + tableName; @@ -198,12 +210,12 @@ private void addColumnIfNotExists(Connection conn, String tableName, String colu { statement = conn.createStatement(); statement.execute("ALTER TABLE " + fullTableName + " ADD COLUMN " + columnName + " " + columnType); - System.out.println("Aggiunta colonna " + columnName + " alla tabella " + fullTableName); + log.debug("Added column {} to table {}", columnName, fullTableName); } catch (SQLException ex) { - // La colonna potrebbe già esistere (race condition) o altro errore - ex.printStackTrace(); + // Column may already exist (race condition) or other error + log.error("Error adding column to table", ex); } finally { @@ -230,11 +242,11 @@ private boolean tableExists(Connection dbConnection, String tableName) } catch (SQLException ex) { - ex.printStackTrace(); + log.error("Error checking table existence", ex); } catch (Exception ex) { - ex.printStackTrace(); + log.error("Error checking table existence", ex); } return tableExists; @@ -280,12 +292,12 @@ private void loadDatabaseDriver(String driverName) } catch (ClassNotFoundException e) { - ex.printStackTrace(); + log.error("Database driver not found: {}", e.getMessage(), e); } } else { - ex.printStackTrace(); + log.error("Database driver not found", ex); } } @@ -317,7 +329,7 @@ private Properties loadDBProperties() } catch (IOException ex) { - ex.printStackTrace(); + log.error("Error loading database properties", ex); } return dbProperties; } @@ -336,7 +348,7 @@ private boolean createTables(Connection dbConnection) } catch (SQLException ex) { - ex.printStackTrace(); + log.error("Error creating tables", ex); } return bCreatedTables; @@ -353,7 +365,7 @@ public boolean dropTables() } catch (SQLException ex) { - ex.printStackTrace(); + log.error("Error dropping tables", ex); } return bDroppedTables; } @@ -395,8 +407,7 @@ public boolean connect() catch (SQLException ex) { isConnected = false; - System.out.println("errore!!"); - ex.printStackTrace(); + log.error("Failed to connect to database: {}", ex.getMessage(), ex); } return isConnected; } @@ -527,7 +538,7 @@ public String saveRecord(Domain record) } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error saving domain record", sqle); } return record.getDomainName(); } @@ -619,7 +630,7 @@ public boolean editRecord(Domain record) } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error editing domain record", sqle); } return bEdited; @@ -637,7 +648,7 @@ public boolean deleteRecord(String domainName) } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error deleting domain record", sqle); } return bDeleted; @@ -671,7 +682,7 @@ public List getListEntries() } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error getting domain list entries", sqle); } @@ -802,7 +813,7 @@ public Domain getDomain(String domainName) } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error getting domain", sqle); } return address; diff --git a/src/main/java/EPPClient/db/messagesDao.java b/src/main/java/EPPClient/db/messagesDao.java index a939009..a602fa9 100644 --- a/src/main/java/EPPClient/db/messagesDao.java +++ b/src/main/java/EPPClient/db/messagesDao.java @@ -17,18 +17,25 @@ import EPPClient.config.EPPparams; import EPPClient.messages.Message; - import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.sql.*; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; import java.util.MissingResourceException; import java.util.Properties; import java.util.ResourceBundle; import java.util.Vector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class messagesDao { + private static final Logger log = LoggerFactory.getLogger(messagesDao.class); private static final String BUNDLE_NAME = "EPPClient.db.messages"; @@ -142,11 +149,11 @@ private boolean tableExists(Connection dbConnection, String tableName) } catch (SQLException ex) { - ex.printStackTrace(); + log.error("Error checking table existence", ex); } catch (Exception ex) { - ex.printStackTrace(); + log.error("Error checking table existence", ex); } return tableExists; @@ -192,12 +199,12 @@ private void loadDatabaseDriver(String driverName) } catch (ClassNotFoundException e) { - ex.printStackTrace(); + log.error("Database driver not found: {}", e.getMessage(), e); } } else { - ex.printStackTrace(); + log.error("Database driver not found", ex); } } @@ -215,6 +222,7 @@ private Properties loadDBProperties() dbProperties.put("derby.locks.deadlockTrace", "true"); dbProperties.put("derby.language.logStatementText", "true"); String dbUrl = EPPparams.getParameter("EppClient.dburl"); + log.debug("Loaded dbUrl from EPPparams: [{}]", dbUrl); if (dbUrl.contains("mariadb")) { dbProperties.put("derby.driver", "org.mariadb.jdbc.Driver"); @@ -224,14 +232,20 @@ private Properties loadDBProperties() dbProperties.put("derby.driver", "org.apache.derby.jdbc.EmbeddedDriver"); } dbProperties.put("derby.url", dbUrl); - dbProperties.put("db.schema", EPPparams.getParameter("EppClient.dbname")); - dbProperties.put("user", EPPparams.getParameter("EppClient.dbuid")); - dbProperties.put("password", EPPparams.getParameter("EppClient.dbpwd")); + String dbSchema = EPPparams.getParameter("EppClient.dbname"); + String dbUser = EPPparams.getParameter("EppClient.dbuid"); + String dbPwd = EPPparams.getParameter("EppClient.dbpwd"); + log.debug("Loaded dbSchema: [{}]", dbSchema); + log.debug("Loaded dbUser: [{}]", dbUser); + log.debug("Loaded dbPwd: [{}]", dbPwd); + dbProperties.put("db.schema", dbSchema); + dbProperties.put("user", dbUser); + dbProperties.put("password", dbPwd); } catch (IOException ex) { - ex.printStackTrace(); + log.error("Error loading database properties", ex); } return dbProperties; } @@ -239,7 +253,7 @@ private Properties loadDBProperties() private boolean createTables(Connection dbConnection) { - System.out.println("Creazione tabelle in corso..."); + log.info("Creazione tabelle in corso..."); boolean bCreatedTables = false; Statement statement = null; try @@ -260,12 +274,12 @@ private boolean createTables(Connection dbConnection) } catch (InterruptedException e) { - e.printStackTrace(); + log.error("Thread interrupted during table creation", e); } } catch (SQLException ex) { - ex.printStackTrace(); + log.error("Error creating tables", ex); } return bCreatedTables; } @@ -281,7 +295,7 @@ public boolean dropTables() } catch (SQLException ex) { - ex.printStackTrace(); + log.error("Error dropping tables", ex); } return bDroppedTables; } @@ -300,7 +314,7 @@ private boolean createDatabase() } catch (SQLException ex) { - ex.printStackTrace(); + log.error("Error creating database", ex); } dbProperties.remove("create"); return bCreated; @@ -326,8 +340,10 @@ public boolean connect() catch (SQLException ex) { isConnected = false; - System.out.println("errore!!"); - ex.printStackTrace(); + log.error("Failed to connect to database: {}", ex.getMessage(), ex); + log.error("DB URL: [{}]", dbUrl); + log.error("DB Schema: [{}]", dbProperties.getProperty("db.schema")); + log.error("DB User: [{}]", dbProperties.getProperty("user")); } return isConnected; } @@ -387,7 +403,7 @@ public String saveRecord(Message record) } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error saving message record", sqle); } return record.getMsgId(); } @@ -410,7 +426,7 @@ public boolean editRecord(Message record) } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error editing message record", sqle); } return bEdited; } @@ -427,7 +443,7 @@ public boolean deleteRecord(String msgId) } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error deleting message record", sqle); } return bDeleted; @@ -465,7 +481,7 @@ public Vector getSelectiveEntries(String preparedStatement) } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error getting message list entries", sqle); } @@ -494,7 +510,7 @@ public Message getMessage(String msgId) } catch (SQLException sqle) { - sqle.printStackTrace(); + log.error("Error getting message", sqle); } return message; diff --git a/src/main/java/EPPClient/domains/DomainFrame.java b/src/main/java/EPPClient/domains/DomainFrame.java index 725bf84..1532647 100644 --- a/src/main/java/EPPClient/domains/DomainFrame.java +++ b/src/main/java/EPPClient/domains/DomainFrame.java @@ -16,22 +16,26 @@ package EPPClient.domains; import EPPClient.db.domainsDao; - -import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.net.URL; import java.util.List; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JList; +import javax.swing.WindowConstants; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -public class DomainFrame - extends JFrame - implements ActionListener, ListSelectionListener +public class DomainFrame extends JFrame implements ActionListener, ListSelectionListener { + private static final Logger log = LoggerFactory.getLogger(DomainFrame.class); /** * Creates new form AddressFrame @@ -187,7 +191,7 @@ private void saveAddress() public void actionPerformed(ActionEvent e) { String actionCommand = e.getActionCommand(); - System.out.println("ActionEvent: " + actionCommand); + log.debug("ActionEvent: {}", actionCommand); if (actionCommand.equalsIgnoreCase("CANCEL_ADDRESS")) { cancelAddress(); diff --git a/src/main/java/EPPClient/domains/DomainsManagement.java b/src/main/java/EPPClient/domains/DomainsManagement.java index dae63fa..77d540a 100644 --- a/src/main/java/EPPClient/domains/DomainsManagement.java +++ b/src/main/java/EPPClient/domains/DomainsManagement.java @@ -15,11 +15,10 @@ package EPPClient.domains; +import EPPClient.main; import EPPClient.db.domainsDao; import EPPClient.domains.transfer.TransferManagement; import EPPClient.importer.ImportDomain; -import EPPClient.logger; -import EPPClient.main; import EPPClient.uplink.EPPuplink; import it.nic.epp.client.commands.converters.AbstractHostsConverter.Host; import it.nic.epp.client.commands.query.DomainCheck; @@ -33,13 +32,8 @@ import it.nic.epp.client.responses.resData.DomainCheckResponseResData; import it.nic.epp.client.responses.resData.DomainCreateResponseResData; import it.nic.epp.client.responses.resData.DomainInfoResponseResData; -import org.apache.xmlbeans.XmlException; - -import javax.swing.*; -import javax.swing.border.LineBorder; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import java.awt.*; +import java.awt.Container; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; @@ -47,6 +41,17 @@ import java.io.IOException; import java.util.List; import java.util.Vector; +import javax.swing.GroupLayout; +import javax.swing.JFrame; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.LayoutStyle; +import javax.swing.border.LineBorder; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import org.apache.xmlbeans.XmlException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class DomainsManagement extends JFrame implements ActionListener, ListSelectionListener { @@ -74,7 +79,7 @@ public DomainsManagement(main mainFrame) refreshDomainList(); - logger = new logger("DOMAIN"); + log = LoggerFactory.getLogger(DomainsManagement.class); } @@ -197,9 +202,9 @@ private void deleteDomain() try { DomainDelete domainDelete = new DomainDelete(domainName); - logger.logmessage("CLIENT: " + domainDelete.toString()); + log.debug("CLIENT: {}", domainDelete); HttpBaseResponse response = EPPuplink.sendCommand(domainDelete); - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.debug("SERVER: {}", response); if (response.isSuccessfully()) { @@ -303,7 +308,7 @@ private void saveAddress() } catch (Exception e) { - System.err.println("Invalid IP Address"); + log.warn("Invalid IP Address: {}", e.getMessage()); } } else @@ -319,9 +324,9 @@ private void saveAddress() if(domain.isDNSSec()) { domainCreate.addDsData(Integer.parseInt(domain.getKeyTag()), (short) domain.getAlg(), (short) domain.getDigestType(), parseHex(domain.getDigest())); } - logger.logmessage("CLIENT: " + domainCreate.toString() + "\n"); + log.debug("CLIENT: {}", domainCreate); HttpBaseResponse response = EPPuplink.sendCommand(domainCreate); - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.debug("SERVER: {}", response); if (response.isSuccessfully()) { @@ -347,15 +352,15 @@ private void saveAddress() } catch (NullPointerException v) { - v.printStackTrace(); + log.error("NullPointerException in deleteDomain", v); } catch (XmlException v) { - v.printStackTrace(); + log.error("XmlException in deleteDomain", v); } catch (IOException v) { - v.printStackTrace(); + log.error("IOException in deleteDomain", v); } @@ -371,7 +376,7 @@ private void saveAddress() HttpBaseResponse response = EPPuplink.sendCommand(domainInfo); if (response.isSuccessfully()) { - logger.logmessage("DomainInfo PRIMA: " + response.toString() + "\n"); + log.debug("DomainInfo PRIMA: {}", response); DomainInfoResponseResData domainInfoResData = (DomainInfoResponseResData) response.getResponseResData(); DomainUpdate domainUpdate = new DomainUpdate(domain.getDomainName()); @@ -438,9 +443,9 @@ private void saveAddress() //if changing Registrant make a custom update request domainUpdate.setRegistrant(domain.getRegistrant()); - logger.logmessage("CLIENT: " + domainUpdate.toString() + "\n"); + log.debug("CLIENT: {}", domainUpdate); response = EPPuplink.sendCommand(domainUpdate); - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.debug("SERVER: {}", response); domainUpdate = new DomainUpdate(domain.getDomainName()); } @@ -663,7 +668,7 @@ else if (oldStatus.equals("clientUpdateProhibited")) } catch (Exception e) { - System.err.println("Invalid IP Address"); + log.warn("Invalid IP Address: {}", e.getMessage()); } } else @@ -740,15 +745,15 @@ else if (oldStatus.equals("clientUpdateProhibited")) } } - logger.logmessage("CLIENT: " + domainUpdate.toString() + "\n"); + log.debug("CLIENT: {}", domainUpdate); response = EPPuplink.sendCommand(domainUpdate); - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.debug("SERVER: {}", response); if (response.isSuccessfully() || (response.getResultCode() == 2003 && response.getReasonCode() == 9019)) { response = EPPuplink.sendCommand(domainInfo); - logger.logmessage("DomainInfo DOPO: " + response.toString() + "\n"); + log.debug("DomainInfo DOPO: {}", response); domainInfoResData = (DomainInfoResponseResData) response.getResponseResData(); domain.setExpire(domainInfoResData.getExDate().getTime()); @@ -794,19 +799,19 @@ else if (oldStatus.equals("clientUpdateProhibited")) } catch (EppSchemaException v) { - v.printStackTrace(); + log.error("EppSchemaException in saveAddress", v); } catch (NullPointerException v) { - v.printStackTrace(); + log.error("NullPointerException in saveAddress", v); } catch (XmlException v) { - v.printStackTrace(); + log.error("XmlException in saveAddress", v); } catch (IOException v) { - v.printStackTrace(); + log.error("IOException in saveAddress", v); } @@ -855,9 +860,9 @@ private void infoDomain() try { DomainInfo domainInfo = new DomainInfo(domainName); - logger.logmessage("CLIENT: " + domainInfo.toString()); + log.debug("CLIENT: {}", domainInfo); HttpBaseResponse response = EPPuplink.sendCommand(domainInfo); - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.debug("SERVER: {}", response); if (response.isSuccessfully()) { @@ -1019,7 +1024,7 @@ private void checkDomain() } HttpBaseResponse response = EPPuplink.sendCommand(domainCheck); - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.debug("SERVER: {}", response); if (response.isSuccessfully()) { @@ -1077,9 +1082,9 @@ public void restoreDomain() try { - logger.logmessage("CLIENT: " + domainUpdate.toString() + "\n"); + log.debug("CLIENT: {}", domainUpdate); HttpBaseResponse response = EPPuplink.sendCommand(domainUpdate); - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.debug("SERVER: {}", response); if (response.isSuccessfully()) { ImportDomain syncDomain = new ImportDomain(mainFrame, true); @@ -1173,7 +1178,7 @@ private void parseDomainResult(HttpBaseResponse response) } catch (Exception e) { - e.printStackTrace(); + log.error("Error in parseDomainResult", e); } } @@ -1207,6 +1212,6 @@ public void windowClosing(WindowEvent e) private DomainListPanel addressListPanel; // End of variables declaration//GEN-END:variables - private logger logger; + private Logger log; private EPPuplink EPPuplink; } diff --git a/src/main/java/EPPClient/domains/transfer/TransferManagement.java b/src/main/java/EPPClient/domains/transfer/TransferManagement.java index 9c679b5..6100031 100644 --- a/src/main/java/EPPClient/domains/transfer/TransferManagement.java +++ b/src/main/java/EPPClient/domains/transfer/TransferManagement.java @@ -16,21 +16,26 @@ package EPPClient.domains.transfer; -import EPPClient.logger; import EPPClient.uplink.EPPuplink; import it.nic.epp.client.commands.transform.DomainTransfer; import it.nic.epp.client.exceptions.EppSchemaException; import it.nic.epp.client.responses.HttpBaseResponse; -import org.apache.xmlbeans.XmlException; - -import javax.swing.*; -import java.awt.*; +import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; +import javax.swing.GroupLayout; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JTabbedPane; +import javax.swing.LayoutStyle; +import org.apache.xmlbeans.XmlException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TransferManagement extends JFrame implements ActionListener { + private static final Logger log = LoggerFactory.getLogger(TransferManagement.class); /** * Creates new form DomainTransferFrame @@ -44,8 +49,6 @@ public TransferManagement(EPPuplink EPPuplink) transferActionPanel.addActionListener(this); domainTransferPanel.setEditable(true); - - logger = new logger("DOMAIN"); } /** @@ -136,7 +139,7 @@ private void requestTransfer() } } - logger.logmessage("CLIENT: " + domainTransfer.toString() + "\n"); + log.info("CLIENT transfer request: {}", domainTransfer.toString()); HttpBaseResponse response = EPPuplink.sendCommand(domainTransfer); if (response.isSuccessfully()) @@ -160,7 +163,7 @@ private void requestTransfer() canClose = false; } - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.info("SERVER transfer response: {}", response.toString()); } catch (NullPointerException v) @@ -199,7 +202,7 @@ private void requestTransfer() domainTransfer.setAuthInfo(bulkRequestEntries[1]); domainTransfer.setTransferRequest(); - logger.logmessage("CLIENT: " + domainTransfer.toString() + "\n"); + log.info("CLIENT bulk transfer request: {}", domainTransfer.toString()); HttpBaseResponse response = EPPuplink.sendCommand(domainTransfer); if (response.isSuccessfully()) @@ -213,7 +216,7 @@ private void requestTransfer() JOptionPane.showMessageDialog(this, response.toString()); } } - logger.logmessage("SERVER: " + response.toString() + "\n"); + log.info("SERVER bulk transfer response: {}", response.toString()); } catch (NullPointerException v) @@ -239,7 +242,7 @@ private void cancelTransfer() public void actionPerformed(ActionEvent e) { String actionCommand = e.getActionCommand(); - System.out.println("ActionEvent: " + actionCommand); + log.debug("ActionEvent: {}", actionCommand); if (actionCommand.equalsIgnoreCase("CANCEL_ADDRESS")) { cancelTransfer(); @@ -250,7 +253,6 @@ else if (actionCommand.equalsIgnoreCase("SAVE_ADDRESS")) } } - private logger logger; private EPPuplink EPPuplink; } diff --git a/src/main/java/EPPClient/importer/ImportContact.java b/src/main/java/EPPClient/importer/ImportContact.java index 949f99e..06355d0 100644 --- a/src/main/java/EPPClient/importer/ImportContact.java +++ b/src/main/java/EPPClient/importer/ImportContact.java @@ -15,20 +15,23 @@ package EPPClient.importer; +import EPPClient.main; import EPPClient.contacts.Address; import EPPClient.db.contactsDao; -import EPPClient.main; import EPPClient.uplink.EPPuplink; import it.nic.epp.client.commands.query.ContactInfo; import it.nic.epp.client.responses.HttpBaseResponse; import it.nic.epp.client.responses.ext.ContactInfoResponseExt; import it.nic.epp.client.responses.resData.ContactInfoResponseResData; -import org.apache.xmlbeans.XmlException; - import java.io.IOException; +import org.apache.xmlbeans.XmlException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ImportContact { + private static final Logger log = LoggerFactory.getLogger(ImportContact.class); + public ImportContact(main mainFrame, String contactId) { this.EPPuplink = mainFrame.EPPuplink; @@ -231,11 +234,11 @@ public boolean execute() } catch (XmlException v) { - v.printStackTrace(); + log.error("XmlException in execute", v); } catch (IOException v) { - v.printStackTrace(); + log.error("IOException in execute", v); } return importStatus; diff --git a/src/main/java/EPPClient/importer/ImportDomain.java b/src/main/java/EPPClient/importer/ImportDomain.java index 30da2e9..9454740 100644 --- a/src/main/java/EPPClient/importer/ImportDomain.java +++ b/src/main/java/EPPClient/importer/ImportDomain.java @@ -16,18 +16,18 @@ package EPPClient.importer; +import EPPClient.main; import EPPClient.db.contactsDao; import EPPClient.db.domainsDao; import EPPClient.domains.Domain; -import EPPClient.logger; -import EPPClient.main; import EPPClient.uplink.EPPuplink; import it.nic.epp.client.commands.query.DomainInfo; import it.nic.epp.client.responses.HttpBaseResponse; import it.nic.epp.client.responses.resData.DomainInfoResponseResData; -import org.apache.xmlbeans.XmlException; - import java.io.IOException; +import org.apache.xmlbeans.XmlException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ImportDomain { @@ -40,7 +40,7 @@ public ImportDomain(main mainFrame, boolean recurseContacts) this.contactdb = mainFrame.contactsDao; this.recurseContacts = recurseContacts; - logger = new logger("DOMAIN"); + log = LoggerFactory.getLogger(ImportDomain.class); } public boolean execute(String domainName) @@ -53,9 +53,9 @@ public boolean execute(String domainName) try { - logger.logmessage("CLIENT: " + domainInfo.toString()); + log.debug("CLIENT: {}", domainInfo); HttpBaseResponse response = EPPuplink.sendCommand(domainInfo); - logger.logmessage("SERVER: " + response.toString()); + log.debug("SERVER: {}", response); if (response.isSuccessfully()) { @@ -104,11 +104,11 @@ public boolean execute(String domainName) } catch (XmlException v) { - v.printStackTrace(); + log.error("XmlException in execute", v); } catch (IOException v) { - v.printStackTrace(); + log.error("IOException in execute", v); } @@ -133,6 +133,6 @@ public Integer getReasonCode() //private String domainName; private boolean recurseContacts; private boolean closedb = false; - private logger logger; + private Logger log; private main mainFrame; } diff --git a/src/main/java/EPPClient/importer/TxtImport.java b/src/main/java/EPPClient/importer/TxtImport.java index 5b0bb9e..19f5784 100644 --- a/src/main/java/EPPClient/importer/TxtImport.java +++ b/src/main/java/EPPClient/importer/TxtImport.java @@ -17,13 +17,23 @@ import EPPClient.main; import EPPClient.uplink.EPPuplink; - -import javax.swing.*; -import java.awt.*; -import java.io.*; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.TextArea; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import javax.swing.GroupLayout; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TxtImport extends JFrame { + private static final Logger log = LoggerFactory.getLogger(TxtImport.class); private main mainFrame; @@ -122,7 +132,7 @@ private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) } else { - System.out.println("non è stato selezionato alcun file..."); + log.info("TxtImport: non è stato selezionato alcun file..."); } } else diff --git a/src/main/java/EPPClient/logger.java b/src/main/java/EPPClient/logger.java deleted file mode 100644 index ca8981b..0000000 --- a/src/main/java/EPPClient/logger.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2009-2025 AssoTLD - * SPDX-FileCopyrightText: 2026 Riccardo Bertelli - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - * This file is part of EPPClient. - * - * EPPClient 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. - * - * EPPClient 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 EPPClient. If not, see . - */ - -package EPPClient; - -import java.io.FileWriter; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Calendar; - -public class logger -{ - public logger(String source) - { - this.source = source; - try - { - fstream = new FileWriter("log-" + source + ".txt", true); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - - public void logmessage(String message) - { -// System.out.println("EPPClient - " + source + ": " + message); - try - { - fstream.write("\nEPPClient " + sdf.format(cal.getTime()) + " log source " + source + ":\n " + message); - fstream.flush(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - - private String source; - private FileWriter fstream; - - Calendar cal = Calendar.getInstance(); - private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); -} diff --git a/src/main/java/EPPClient/messages/MessageDetail.java b/src/main/java/EPPClient/messages/MessageDetail.java index 7cb3516..cb24205 100644 --- a/src/main/java/EPPClient/messages/MessageDetail.java +++ b/src/main/java/EPPClient/messages/MessageDetail.java @@ -15,31 +15,41 @@ package EPPClient.messages; +import EPPClient.main; import EPPClient.config.EPPparams; import EPPClient.db.messagesDao; -import EPPClient.logger; -import EPPClient.main; -import EPPClient.uplink.EPPuplink; import EPPClient.importer.ImportDomain; +import EPPClient.uplink.EPPuplink; import it.nic.epp.client.commands.query.Poll; import it.nic.epp.client.commands.transform.DomainTransfer; import it.nic.epp.client.exceptions.EppSchemaException; import it.nic.epp.client.responses.HttpBaseResponse; import it.nic.epp.client.responses.ext.PollingResponseExt; import it.nic.epp.client.responses.resData.PollingResponseResData; -import org.apache.xmlbeans.XmlException; - -import javax.swing.*; -import java.awt.*; +import java.awt.Container; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.IOException; +import javax.swing.GroupLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.LayoutStyle; +import org.apache.xmlbeans.XmlException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MessageDetail extends JFrame { private EPPuplink EPPuplink; - private logger logger; + private Logger log; private Message message; private messagesDao db; private MessageManagement parentFrame; @@ -62,7 +72,7 @@ public MessageDetail(main mainFrame, MessageManagement parentFrame, Message mess this.db = mainFrame.messagesDao; - logger = new logger("MESSAGE"); + log = LoggerFactory.getLogger(MessageDetail.class); java.text.SimpleDateFormat dateFormatter = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); this.message = messageIn; @@ -78,7 +88,7 @@ public MessageDetail(main mainFrame, MessageManagement parentFrame, Message mess } catch (XmlException e) { - e.printStackTrace(); + log.error("XmlException in constructor", e); } resData = (PollingResponseResData) response.getResponseResData(); @@ -470,20 +480,20 @@ private void btnTransferMouseReleased(MouseEvent evt) case 0: domainTransfer = new DomainTransfer(resData.getTranferMsgName()); domainTransfer.setTransferApprove(); - logger.logmessage(domainTransfer.toString()); + log.debug("Transfer approve: {}", domainTransfer); try { response = EPPuplink.sendCommand(domainTransfer); } catch (XmlException e) { - e.printStackTrace(); + log.error("XmlException in btnTransferMouseReleased", e); } catch (IOException e) { - e.printStackTrace(); + log.error("IOException in btnTransferMouseReleased", e); } - logger.logmessage(response.toString()); + log.debug("Transfer response: {}", response); if (response.isSuccessfully()) { txtTransfer.setText(txtTransfer.getText() + "\n============\nThe transfer has been successfully Acknowledged!"); @@ -509,20 +519,20 @@ private void btnTransferMouseReleased(MouseEvent evt) case 1: domainTransfer = new DomainTransfer(resData.getTranferMsgName()); domainTransfer.setTransferReject(); - logger.logmessage(domainTransfer.toString()); + log.debug("Transfer reject: {}", domainTransfer); try { response = EPPuplink.sendCommand(domainTransfer); } catch (XmlException e) { - e.printStackTrace(); + log.error("XmlException in btnTransferMouseReleased reject", e); } catch (IOException e) { - e.printStackTrace(); + log.error("IOException in btnTransferMouseReleased reject", e); } - logger.logmessage(response.toString()); + log.debug("Transfer reject response: {}", response); if (response.isSuccessfully()) { txtTransfer.setText(txtTransfer.getText() + "\n============\nThe transfer has been successfully Rejected!"); @@ -751,7 +761,7 @@ protected boolean ackMessage(String msgQid) { Poll pollCmd = new Poll(); pollCmd.setAck(msgQid); - logger.logmessage("ACK: " + pollCmd.toString()); + log.debug("ACK: {}", pollCmd); response = EPPuplink.sendCommand(pollCmd); if (response.isSuccessfully()) { @@ -772,15 +782,15 @@ protected boolean ackMessage(String msgQid) } catch (EppSchemaException v) { - v.printStackTrace(); + log.error("EppSchemaException in ackMessage", v); } catch (XmlException v) { - v.printStackTrace(); + log.error("XmlException in ackMessage", v); } catch (IOException v) { - v.printStackTrace(); + log.error("IOException in ackMessage", v); } return ackStatus; diff --git a/src/main/java/EPPClient/messages/MessageManagement.java b/src/main/java/EPPClient/messages/MessageManagement.java index 22af780..ef87965 100644 --- a/src/main/java/EPPClient/messages/MessageManagement.java +++ b/src/main/java/EPPClient/messages/MessageManagement.java @@ -15,19 +15,27 @@ package EPPClient.messages; -import EPPClient.db.messagesDao; import EPPClient.main; +import EPPClient.db.messagesDao; import EPPClient.uplink.EPPuplink; - -import javax.swing.*; -import javax.swing.table.DefaultTableModel; -import java.awt.*; +import java.awt.Container; import java.util.ListIterator; import java.util.Vector; +import javax.swing.GroupLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.LayoutStyle; +import javax.swing.table.DefaultTableModel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MessageManagement extends JFrame { + private static final Logger log = LoggerFactory.getLogger(MessageManagement.class); + java.text.SimpleDateFormat dateFormatter = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); Vector messageDetailWindows = new Vector(); private main mainFrame; @@ -176,7 +184,7 @@ private void ackAllMessages() } catch (Exception ex) { - ex.printStackTrace(); + log.error("Error in ackAllMessages", ex); } } @@ -248,4 +256,4 @@ public boolean isCellEditable(int column, int row) { return false; } -} \ No newline at end of file +} diff --git a/src/main/java/EPPClient/uplink/EPPthread.java b/src/main/java/EPPClient/uplink/EPPthread.java index 97ba250..a072c83 100644 --- a/src/main/java/EPPClient/uplink/EPPthread.java +++ b/src/main/java/EPPClient/uplink/EPPthread.java @@ -16,31 +16,32 @@ package EPPClient.uplink; import EPPClient.CustomLogin; -import EPPClient.config.EPPparams; -import EPPClient.logger; +import EPPClient.ErrorHandler; import EPPClient.main; +import EPPClient.config.EPPparams; import EPPClient.messages.Message; import it.nic.epp.client.commands.interfaces.IEppRequest; import it.nic.epp.client.commands.query.Poll; -import it.nic.epp.client.commands.session.Login; import it.nic.epp.client.commands.session.Logout; import it.nic.epp.client.exceptions.EppSchemaException; import it.nic.epp.client.httpClient.Client; import it.nic.epp.client.responses.HttpBaseResponse; import it.nic.epp.client.responses.ext.LoginResponseExt; +import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import javax.swing.JOptionPane; import org.apache.xmlbeans.XmlException; - -import javax.swing.*; -import java.io.IOException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; class EPPthread extends Thread { + private static final Logger log = LoggerFactory.getLogger(EPPthread.class); + public EPPthread(main mainFrame) { this.mainFrame = mainFrame; - logger = new logger("SESSION"); } @Override @@ -70,10 +71,9 @@ public void run() // logger.logmessage("HELLO: " + client.sendHello().toString()); - logger.logmessage("CLIENT login request:\n" + login.toString() + "\n"); - //logger.logmessage("CLIENT: *LOGIN COMMAND OMITTED*\n"); + log.info("CLIENT login request: *REQUEST*"); response = client.sendCommand(login); - logger.logmessage("SERVER login response:\n" + response.toString()); + log.info("SERVER login response: *RESPONSE*"); if (response.isSuccessfully()) { EPPclosable = false; @@ -138,15 +138,15 @@ else if (response.getResultCode() == 2502) } catch (IOException v) { - v.printStackTrace(); + ErrorHandler.error(log, v, "Errore di Connessione", mainFrame); } catch (URISyntaxException v) { - v.printStackTrace(); + ErrorHandler.error(log, v, "Errore di Configurazione", mainFrame); } catch (XmlException v) { - v.printStackTrace(); + ErrorHandler.error(log, v, "Errore XML", mainFrame); } finally { @@ -158,9 +158,9 @@ else if (response.getResultCode() == 2502) if (!EPPclosable) { Logout logout = new Logout(); - logger.logmessage("CLIENT: " + logout.toString() + "\n"); + log.info("CLIENT logout command: {}", logout.toString()); response = client.sendCommand(logout); - logger.logmessage("SERVER: " + response.toString()); + log.info("SERVER logout response: {}", response.toString()); if (response.isSuccessfully()) { EPPclosable = true; @@ -179,11 +179,11 @@ else if (response.getResultCode() == 2502) } catch (IOException v) { - v.printStackTrace(); + ErrorHandler.logError(log, v); } catch (XmlException v) { - v.printStackTrace(); + ErrorHandler.logError(log, v); } } } @@ -237,13 +237,17 @@ public Boolean doPoll(Boolean doAck) throws XmlException, IOException } catch (EppSchemaException ex) { - ex.printStackTrace(); + ErrorHandler.logError(log, ex); } HttpBaseResponse response = this.sendCommand(pollCmd); - logger.logmessage("CLIENT: " + pollCmd.toString()); - logger.logmessage("SERVER: " + response.toString()); - + if (response == null) + { + log.warn("Poll command returned null response - connection may have been interrupted"); + return false; + } + log.info("CLIENT poll: {}", pollCmd.toString()); + log.info("SERVER poll response: {}", response.toString()); if (response.isSuccessfully()) { mainFrame.setMSGQ(Integer.toString(response.getMsgQCount())); @@ -273,9 +277,8 @@ public Boolean doPoll(Boolean doAck) throws XmlException, IOException pollCmd.setAck(response.getMsgQId()); HttpBaseResponse ackResponse = this.sendCommand(pollCmd); - logger.logmessage("CLIENT: " + pollCmd.toString()); - logger.logmessage("SERVER: " + ackResponse.toString()); - + log.info("CLIENT poll ack: {}", pollCmd.toString()); + log.info("SERVER poll ack response: {}", ackResponse.toString()); if (ackResponse.isSuccessfully()) { Message message = mainFrame.messagesDao.getMessage(response.getMsgQId()); @@ -285,7 +288,7 @@ public Boolean doPoll(Boolean doAck) throws XmlException, IOException } catch (EppSchemaException ex) { - ex.printStackTrace(); + ErrorHandler.logError(log, ex); } } else @@ -343,7 +346,7 @@ public synchronized HttpBaseResponse sendCommand(IEppRequest command) throws org } catch (InterruptedException ex) { - System.out.println("Interrupted while waiting for EPP uplink availability."); + log.debug("Interrupted while waiting for EPP uplink availability."); } return response; @@ -359,6 +362,5 @@ protected boolean isActive() private boolean isClosing = false; private boolean isRunning = false; private boolean isWaitingEPPresponse = false; - private logger logger; private main mainFrame; -} \ No newline at end of file +} diff --git a/src/main/resources/EPPClient/config/EPPparams.properties b/src/main/resources/EPPClient/config/EPPparams.properties index ec74c8c..17474cd 100644 --- a/src/main/resources/EPPClient/config/EPPparams.properties +++ b/src/main/resources/EPPClient/config/EPPparams.properties @@ -1,5 +1,7 @@ EPPClient.lang=en EppClient.serverURI=https://epp.pubtest.nic.it +EppClient.proxyHost= +EppClient.proxyPort=3128 EppClient.defaultUser=REGISTRAR-REG EppClient.defaultPassword=password EppClient.dbengine=0 @@ -11,4 +13,6 @@ EppClient.dbpwd=clientepp EppClient.refreshInterval=30 EppClient.dblevel=0 EppClient.contactPrefix=AT- -EppClient.implement.DNSSEC=false \ No newline at end of file +EppClient.implement.DNSSEC=false +EppClient.defaultTech= +EppClient.defaultNS= diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000..a55fa6c --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + %d{HH:mm:ss} %highlight([%-5level]) %cyan(%-36logger{36}) - %msg%n + + + + + + logs/eppclient.log + + logs/eppclient-%d{yyyy-MM-dd}.log + 30 + true + + + + + timestamp + + + loglevel + + + logger + + + message + + + thread + + + stackTrace + + + + + + + + + + +