Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 59 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)).
Expand All @@ -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
```
Expand All @@ -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-<versione>-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-<versione>-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-<versione>-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.

---

Expand Down Expand Up @@ -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

---
18 changes: 10 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Comment thread
matteotrubini marked this conversation as resolved.
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'
Expand Down Expand Up @@ -99,4 +101,4 @@ jar {
manifest {
attributes('Main-Class': application.mainClass)
}
}
}
129 changes: 129 additions & 0 deletions src/main/java/EPPClient/ErrorHandler.java
Comment thread
matteotrubini marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
*
* 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 <https://www.gnu.org/licenses/>.
*/

package EPPClient;

import java.awt.Component;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import org.slf4j.Logger;

/**
* Centralized error handling utility class.
* Provides dialog display for errors - logging is done directly via SLF4J.
*
* The user receives a generic error message and is invited to view the log file for detailed information.
*
* File logging is controlled by system property -Deppclient.logLevel
* Console output for errors can be enabled with -Deppclient.console=true
Comment thread
matteotrubini marked this conversation as resolved.
Outdated
*/
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" + "Clicca \"Visualizza log\" per aprire il visualizzatore dei log.\n\n" + "Consultare i file di 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 with the default message.
*
* @param parent The parent component for the dialog
* @param title The title of the dialog
*/
public static void showErrorDialog(java.awt.Component parent, String title)
{
showErrorDialogWithLogViewer(parent, title, DEFAULT_USER_MESSAGE);
}

/**
* Shows an error dialog with a "Show logs" button that opens the LogViewer.
*
* @param parent The parent component for the dialog
* @param title The title of the dialog
* @param message The message to display
*/
private static void showErrorDialogWithLogViewer(Component parent, String title, String message)
{
// Create buttons: OK and View Log
JButton viewLogButton = new JButton("Visualizza log");
viewLogButton.setFocusPainted(false);

// Create option pane with custom buttons
JOptionPane optionPane = new JOptionPane(message, JOptionPane.ERROR_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, new Object[]
{viewLogButton, "OK"}, "OK");

// Create and configure the dialog
JDialog dialog = optionPane.createDialog(parent, title);
dialog.setResizable(false);

// Handle button click
viewLogButton.addActionListener(e -> {
dialog.dispose();
openLogViewer(parent);
});

// Show dialog
dialog.setVisible(true);
}

/**
* Opens the log viewer dialog.
*
* @param parent The parent component for the log viewer
*/
private static void openLogViewer(Component parent)
{
// Get the parent frame for the log viewer
JFrame frame = null;
if (parent instanceof JFrame)
{
frame = (JFrame) parent;
}
else if (parent != null)
{
frame = (JFrame) SwingUtilities.getWindowAncestor(parent);
}

LogViewer.showLogViewer(frame);
}
}
Loading