MAJ 1.0.7
This commit is contained in:
parent
dedda3faf0
commit
a636b33596
10
.classpath
10
.classpath
@ -20,5 +20,15 @@
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/apache.tika with dependances/commons-io-2.11.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/juniversalchardet-2.4.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/xml-apis-1.4.01.wso2v1.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/eclipse-workspace/API Google/google-api-client-2.6.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/eclipse-workspace/API Google/google-api-services-drive-v3-rev20240521-2.0.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/eclipse-workspace/API Google/google-http-client-jackson2-1.44.2.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/eclipse-workspace/API Google/google-oauth-client-1.36.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/eclipse-workspace/API Google/google-oauth-client-jetty-1.36.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/eclipse-workspace/API Google/google-http-client-1.44.2.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/eclipse-workspace/API Google/google-oauth-client-java6-1.36.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/eclipse-workspace/API Google/google-http-client-gson-1.44.2.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/eclipse-workspace/API Google/gson-2.11.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/eclipse-workspace/API Google/guava-33.2.1-jre.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
13
august-edge-427718-m0-6298e03aba4c.json
Normal file
13
august-edge-427718-m0-6298e03aba4c.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"type": "service_account",
|
||||
"project_id": "august-edge-427718-m0",
|
||||
"private_key_id": "6298e03aba4c16bea70a320892385d4df2c7464d",
|
||||
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDJiMz6mdSjEKNS\nj7gAqwTezhq4ZWTlgKIYIR47246FjVOYpxIfqVv/eDvDub5zgLh1u/6m0RP13AGU\nthqnr21i1ozCKa5eOnh5XMMQwUX4m793q3bVGAKks3rUZh9DJerLNWOZnVPMyblw\n0kJsRS2DcGuysXgrfaV0BW7P2+S9Vg0BKPEY6FGTZh4BkbhaWMSFLBBzTcn6Qgqr\nqVgDmOZHMDRvANPKCGk3aHRd495RHJx7N7DL17JbF6zlHLZFT3j/n5qDfhVtmokd\n+pDqDfepJinnKUKmh5TS+kJbZ69GPLCMxuPeghXu98Av10b8+5hAfu+r6Y2+00kF\n9DpNYbBrAgMBAAECggEAP44cMlVryMbY8pLvMIq+PPNbWtZi9LtVou1ixvas4fIZ\nMFVTsldq80w78LP1WyB3S22vV3Us6cZpWzf4fPQmN1q4xgx1+DJRRtiZjYGd6tJX\nFcqlbXsmbkFJlYzlA/yDqHTcRZfnUvg0ul8cYl+IhGBiHla4MmLr2ARUl0ldv9VB\nP7rphqGhsOQn78Qwj3330wjf+zcqKF8JVL+V5NrSdflfXuiVeVNJWjlrXDUBrwVv\n9VX9TjSD/MenCa5xXpMzoMlCzrguYPfx7H26B3YJEh6TQrQhhsUBXk8ZA7xznJvm\nkND0uA2BMR3nkLadsBXjwgsTvIUjLWBS8AZoRZ61MQKBgQDw0PFW60FVdiDo4Ny7\nklO2iyYqqZEQ93bdZN8L5HKPnk5PuaKxUp6XY5fDXNTqMTdUkIR9UQQWIq0chRDm\n63uDpfMgQCZLF4KnVP/Qy0oW5uxNMtjLrMfOdQSK/6/fvek/lGvmHCXFiP1sDa9w\n7pLkY9+OFshKWffXYc4S5uaXOwKBgQDWPc2k5fzYP6hNbM8FHxdKOZtvQnLv84Mr\nyvTM2aItAY9jYGPYp+XAZKRiLjJjBxPcaP6QyrQrsM/wKaznOdBdIBb+tpNZoPjy\nobMhg3+T72LAdAkQx/xOdGYIrafgkDdPJVZL2bThosnlEUn8ux7coH5vgP2q/TZb\njspPT0GYkQKBgFIfHr4CWfRX5V8lF4ELpGqSx0AzNRoxGaLkPD/k9sBNPu1nI7kO\nsLB1sRJZPO5kPDclVVka4KbfymL4acwlr6g0VlXAKo7fBJolnVtJiAmJVDn7Rf0m\n/bhFJXh1Oze0nq8k4SrGnIbhcXKAtDxxzzv9ZwYgdMsOJTuYydqeTTJzAoGAJ/KG\nMcUgjEHyY91yDIZrlU+AiBJf1BYX00aYtsmtz66GygTjGTbVRDZ/4D607noXXfXF\n4cGqLqtdWm6q6sKA85xULVJlz0SQps031Xvrge4U/8WjGxnvFcHmdJ/MubaqWXug\nx6vkal4sPyYmIZXSf1j9ulTW99cXF6NcXcVtecECgYEAgHpXlGGDWfk6DDggxcl9\nLRosvqmxYRiJTO6KBS2SeOuhhdgiXeh5Ddk2WuojVb+TOX72EwJ7fPvu3+OtFiW7\nQ/OSKqWQDjGrJeNhdGv8T1/O87TgsHKsvhPyypkl4+6KY0Hv8WDmUTRjR9V12Oti\nGGcpq5MG80nNJYIupaDGoH0=\n-----END PRIVATE KEY-----\n",
|
||||
"client_email": "drivebaseegass@august-edge-427718-m0.iam.gserviceaccount.com",
|
||||
"client_id": "108257985217466952219",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/drivebaseegass%40august-edge-427718-m0.iam.gserviceaccount.com",
|
||||
"universe_domain": "googleapis.com"
|
||||
}
|
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,9 +1,10 @@
|
||||
package Windows;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
public class Window_Help_download_and_install extends JFrame{
|
||||
|
@ -1,9 +1,10 @@
|
||||
package Windows;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
public class Window_Help_maj_data extends JFrame{
|
||||
|
@ -55,7 +55,7 @@ public class Window_demarre extends JFrame {
|
||||
JButton btnGestionnaire = new JButton("");
|
||||
JButton btnLicence = new JButton("Licence GNU GPL 3.0");
|
||||
JButton btnimporterDesInscriptionsdepuisClasseur = new JButton("<html>Importer des inscriptions<br>depuis un classeur Ms Excel</html>");
|
||||
static JLabel lblAuteurVersion = new JLabel("<html>Pablo Rodriguez - 2023<br>Version "+ commandes.version+"</html>");
|
||||
static JLabel lblAuteurVersion = new JLabel("<html>Pablo Rodriguez - 2024<br>Version "+ commandes.version+"</html>");
|
||||
static JLabel lblFondImage = new JLabel();
|
||||
|
||||
|
||||
@ -113,7 +113,7 @@ public class Window_demarre extends JFrame {
|
||||
}
|
||||
};
|
||||
|
||||
// Planification de la tâche de sauvegarde automatique à exécuter toutes les 2 minutes 2 * 60 * 1000
|
||||
// Planification de la tâche de sauvegarde automatique à exécuter toutes les 5 minutes : 5 * 60 * 1000
|
||||
timer.schedule(autoSaveTask, 0, commandes.nombreMinuteEntreDeuxSauvegarde * 60 * 1000);
|
||||
|
||||
// Affichage des messages de version ou d'information
|
||||
@ -556,6 +556,7 @@ public class Window_demarre extends JFrame {
|
||||
private static void affichageImageDeFond() {
|
||||
Random random = new Random();
|
||||
int randomNumber = random.nextInt(commandes.nombreImage) + 1;
|
||||
// randomNumber=42;
|
||||
ImageIcon imageIcon = new ImageIcon(Window_demarre.class.getResource("/resources/Sans titre_"+ String.valueOf(randomNumber) +".jpg"));
|
||||
Image image = imageIcon.getImage();
|
||||
|
||||
@ -572,7 +573,7 @@ public class Window_demarre extends JFrame {
|
||||
|| randomNumber==10 || randomNumber==11 || randomNumber==12
|
||||
|| randomNumber==14 || randomNumber==18 || randomNumber==21
|
||||
|| randomNumber==22 || randomNumber==23 || randomNumber==25
|
||||
|| randomNumber==27 || randomNumber==28
|
||||
|| randomNumber==27 || randomNumber==28 || randomNumber ==42
|
||||
) {
|
||||
lblAuteurVersion.setForeground(new Color(0, 0, 0));
|
||||
}else {
|
||||
|
@ -11,6 +11,7 @@ import java.util.Random;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
@ -20,7 +21,6 @@ import javax.swing.border.EmptyBorder;
|
||||
|
||||
import base.NomDeColonneInscriptionTable;
|
||||
import outils.commandes;
|
||||
import javax.swing.JCheckBox;
|
||||
|
||||
/**
|
||||
* Fenêtre permettant de changer les paramètres (nom de la feuille, noms des colonnes).
|
||||
|
@ -29,6 +29,8 @@ public class recupeBases {
|
||||
nBase = lectureXML.lectureStringToNoeud(xmlString);
|
||||
|
||||
} else {
|
||||
// création d'une nouvelle base
|
||||
nBase = base.createBase();
|
||||
|
||||
JFrame frame = new JFrame();
|
||||
JLabel texte = new JLabel("<html><p>La base de données ne se trouve pas dans le même dossier que celui de l'application.</p><br>"
|
||||
@ -38,8 +40,6 @@ public class recupeBases {
|
||||
+ "<p>Vous allez devoir saisir l'année universitaire pour débuter et créer la base.</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
|
||||
// création d'une nouvelle base
|
||||
nBase = base.createBase();
|
||||
}
|
||||
|
||||
return nBase;
|
||||
|
97
src/google/GoogleDriveService.java
Normal file
97
src/google/GoogleDriveService.java
Normal file
@ -0,0 +1,97 @@
|
||||
package google;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.api.client.auth.oauth2.Credential;
|
||||
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
|
||||
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
|
||||
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;
|
||||
import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;
|
||||
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
|
||||
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||
import com.google.api.client.json.JsonFactory;
|
||||
import com.google.api.client.json.gson.GsonFactory;
|
||||
import com.google.api.client.util.store.FileDataStoreFactory;
|
||||
import com.google.api.services.drive.Drive;
|
||||
import com.google.api.services.drive.DriveScopes;
|
||||
|
||||
|
||||
public class GoogleDriveService {
|
||||
private static final String APPLICATION_NAME = "My Project 89246";
|
||||
private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
|
||||
private static final String TOKENS_DIRECTORY_PATH = "C:/Users/pabr6/eclipse-workspace/baseStudentUFRHG/tokens"; // Répertoire pour stocker les jetons
|
||||
|
||||
private static final List<String> SCOPES = Collections.singletonList(DriveScopes.DRIVE);
|
||||
private static final String CREDENTIALS_FILE_PATH = "/resources/august-edge-427718-m0-6298e03aba4c.json"; // Chemin relatif au répertoire resources
|
||||
|
||||
public static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) throws Exception {
|
||||
InputStream in = GoogleDriveService.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
|
||||
if (in == null) {
|
||||
throw new FileNotFoundException("Resource not found: " + CREDENTIALS_FILE_PATH);
|
||||
}
|
||||
|
||||
// Debug: Afficher le contenu du fichier credentials.json
|
||||
InputStreamReader reader = new InputStreamReader(in);
|
||||
StringBuilder jsonContent = new StringBuilder();
|
||||
int data;
|
||||
while ((data = reader.read()) != -1) {
|
||||
jsonContent.append((char) data);
|
||||
}
|
||||
System.out.println("Credentials JSON content: " + jsonContent.toString());
|
||||
|
||||
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(new ByteArrayInputStream(jsonContent.toString().getBytes(StandardCharsets.UTF_8))));
|
||||
|
||||
File fileTokens = new java.io.File(TOKENS_DIRECTORY_PATH);
|
||||
|
||||
try {
|
||||
// Vérifie si le répertoire des tokens existe
|
||||
if (!fileTokens.exists()) {
|
||||
// Tentative de création du répertoire
|
||||
if (!fileTokens.mkdirs()) {
|
||||
throw new IOException("Impossible de créer le répertoire des tokens : " + TOKENS_DIRECTORY_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
// Vérifie de nouveau l'existence du répertoire après tentative de création
|
||||
if (fileTokens.exists()) {
|
||||
// Affiche les informations sur le répertoire des tokens
|
||||
System.out.println("Répertoire des tokens : " + fileTokens.getAbsolutePath());
|
||||
|
||||
// Construit le flux d'autorisation Google
|
||||
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
|
||||
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
|
||||
.setDataStoreFactory(new FileDataStoreFactory(fileTokens))
|
||||
.setAccessType("offline")
|
||||
.build();
|
||||
|
||||
// Crée le récepteur local pour la réception du code d'autorisation
|
||||
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build();
|
||||
|
||||
// Autorise l'application à accéder aux services Google au nom de l'utilisateur
|
||||
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");
|
||||
} else {
|
||||
throw new IOException("Répertoire des tokens inexistant : " + TOKENS_DIRECTORY_PATH);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println("Erreur lors de la gestion du répertoire des tokens : " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Drive getDriveService() throws Exception {
|
||||
final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
|
||||
return new Drive.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT))
|
||||
.setApplicationName(APPLICATION_NAME)
|
||||
.build();
|
||||
}
|
||||
}
|
46
src/google/GoogleDriveXmlManager.java
Normal file
46
src/google/GoogleDriveXmlManager.java
Normal file
@ -0,0 +1,46 @@
|
||||
package google;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import com.google.api.services.drive.Drive;
|
||||
import com.google.api.services.drive.model.File;
|
||||
|
||||
|
||||
public class GoogleDriveXmlManager {
|
||||
|
||||
private static final String FILE_ID = "1lX56oXzQQk9nZu7DAlU0eqcVLqqSo-ab";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Drive service = GoogleDriveService.getDriveService();
|
||||
|
||||
// Step 1: Download the file
|
||||
Path tempFile = downloadFile(service, FILE_ID);
|
||||
|
||||
// Step 2: Parse and modify the XML file
|
||||
|
||||
|
||||
|
||||
|
||||
// Step 4: Upload the modified file back to Google Drive
|
||||
uploadFile(service, FILE_ID, tempFile);
|
||||
}
|
||||
|
||||
private static Path downloadFile(Drive service, String fileId) throws IOException {
|
||||
Path tempFile = Files.createTempFile("base", ".xml");
|
||||
try (OutputStream outputStream = Files.newOutputStream(tempFile)) {
|
||||
service.files().get(fileId).executeMediaAndDownloadTo(outputStream);
|
||||
}
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
|
||||
private static void uploadFile(Drive service, String fileId, Path filePath) throws IOException {
|
||||
File fileMetadata = new File();
|
||||
java.io.File file = filePath.toFile();
|
||||
com.google.api.client.http.FileContent mediaContent = new com.google.api.client.http.FileContent("application/xml", file);
|
||||
service.files().update(fileId, fileMetadata, mediaContent).execute();
|
||||
}
|
||||
}
|
@ -11,8 +11,8 @@ import java.util.List;
|
||||
public class commandes {
|
||||
|
||||
public static noeud nBase = null; // La base de données sous forme de noeud.
|
||||
public static String version = "1.0.6"; // La version actuelle
|
||||
public static String dateversion = "2 aout 2023"; // La version actuelle
|
||||
public static String version = "1.0.7"; // La version actuelle
|
||||
public static String dateversion = "29 aout 2024"; // La version actuelle
|
||||
|
||||
// Les colonnes obligatoires dû à l'inscription des étudaints.
|
||||
// nom des colonnes après traitement des caractères (Accès à la base XML)
|
||||
@ -44,7 +44,7 @@ public class commandes {
|
||||
|
||||
// Version vérification
|
||||
public static Boolean newVersion = false; //Permet de vérifier l'existance d'un nouvelle version.
|
||||
public static String nameNewVersion = "V0.0.0"; //Le nom de la nouvelle version qui s'affiche dans le bouton de la version disponible.
|
||||
public static String nameNewVersion = "V1.0.7"; //Le nom de la nouvelle version qui s'affiche dans le bouton de la version disponible.
|
||||
|
||||
// Messages et sécurité
|
||||
public static Boolean helpme1 = false; //M'aider à compléter mon service annuel.
|
||||
@ -71,13 +71,13 @@ public class commandes {
|
||||
public static boolean enabled_Colonne_Option_5 = true;
|
||||
|
||||
// Nombre d'image d'acceuil
|
||||
public static int nombreImage = 41;
|
||||
public static int nombreImage = 42;
|
||||
|
||||
// Nombre maximal de fichier dans l'archive
|
||||
public static int nombreMaxSauvegardeArchive = 300;
|
||||
|
||||
// Nombre de minute entre deux sauvegardes dans l'archive
|
||||
public static int nombreMinuteEntreDeuxSauvegarde = 2 ;
|
||||
public static int nombreMinuteEntreDeuxSauvegarde = 5 ;
|
||||
|
||||
|
||||
}
|
||||
|
@ -1172,7 +1172,12 @@ public class noeud implements Cloneable{
|
||||
}
|
||||
|
||||
int e = attributes.hashCode();
|
||||
int f = content.hashCode();
|
||||
|
||||
int f = 0;
|
||||
if(content!=null) {
|
||||
f = content.hashCode();
|
||||
}
|
||||
|
||||
int g = 0;
|
||||
String hashG = "";
|
||||
for(noeud child : children) {
|
||||
|
1
src/resources/.gitignore
vendored
Normal file
1
src/resources/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/august-edge-427718-m0-6298e03aba4c.json
|
BIN
src/resources/Sans titre_42.jpg
Normal file
BIN
src/resources/Sans titre_42.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 238 KiB |
Loading…
x
Reference in New Issue
Block a user