[FIX] socme checks

This commit is contained in:
Edouard DUPIN 2024-06-01 19:49:36 +02:00
parent 6af6f91166
commit c43e283b57
6 changed files with 44 additions and 25 deletions

View File

@ -25,7 +25,7 @@
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>

View File

@ -15,10 +15,16 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature>
</natures> </natures>
<filteredResources> <filteredResources>
<filter> <filter>

45
pom.xml
View File

@ -5,7 +5,7 @@
<artifactId>archidata</artifactId> <artifactId>archidata</artifactId>
<version>0.10.3</version> <version>0.10.3</version>
<properties> <properties>
<java.version>21</java.version> <java.version>21</java.version>
<maven.compiler.version>3.1</maven.compiler.version> <maven.compiler.version>3.1</maven.compiler.version>
<maven.compiler.source>21</maven.compiler.source> <maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target> <maven.compiler.target>21</maven.compiler.target>
@ -120,7 +120,6 @@
<artifactId>jackson-datatype-jsr310</artifactId> <artifactId>jackson-datatype-jsr310</artifactId>
<version>2.17.1</version> <version>2.17.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>jakarta.servlet</groupId> <groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId> <artifactId>jakarta.servlet-api</artifactId>
@ -170,20 +169,19 @@
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId> <artifactId>junit-jupiter-engine</artifactId>
<version>5.11.0-M2</version> <version>5.11.0-M2</version>
<scope>test</scope> <scope>test</scope>
</dependency>
<dependency>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.23.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven.plugins</groupId> <groupId>net.revelc.code.formatter</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>formatter-maven-plugin</artifactId>
<version>3.3.1</version> <version>2.23.0</version>
</dependency> </dependency>
</dependencies> <dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.3.1</version>
</dependency>
</dependencies>
<build> <build>
<sourceDirectory>src</sourceDirectory> <sourceDirectory>src</sourceDirectory>
<resources> <resources>
@ -269,7 +267,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<version>3.3.1</version> <version>3.3.1</version>
<configuration> <configuration>
<configLocation>CheckStyle.xml</configLocation> <configLocation>CheckStyle.xml</configLocation>
<consoleOutput>true</consoleOutput> <consoleOutput>true</consoleOutput>
@ -281,7 +279,7 @@
<plugin> <plugin>
<groupId>net.revelc.code.formatter</groupId> <groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId> <artifactId>formatter-maven-plugin</artifactId>
<version>2.23.0</version> <version>2.23.0</version>
<configuration> <configuration>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
<lineEnding>LF</lineEnding> <lineEnding>LF</lineEnding>
@ -305,6 +303,23 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.8.5.0</version>
<configuration>
<includeFilterFile>spotbugs-security-include.xml</includeFilterFile>
<excludeFilterFile>spotbugs-security-exclude.xml</excludeFilterFile>
<!--<plugins>
<plugin>
<groupId>com.h3xstream.findsecbugs</groupId>
<artifactId>findsecbugs-plugin</artifactId>
<version>1.12.0</version>
</plugin>
</plugins>
-->
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
<!-- Generate Java-docs As Part Of Project Reports --> <!-- Generate Java-docs As Part Of Project Reports -->

View File

@ -4,7 +4,7 @@ import org.kar.archidata.db.DBConfig;
import org.kar.archidata.tools.ConfigBaseVariable; import org.kar.archidata.tools.ConfigBaseVariable;
public class GlobalConfiguration { public class GlobalConfiguration {
public static DBConfig dbConfig = null; public static final DBConfig dbConfig;
static { static {
dbConfig = new DBConfig(ConfigBaseVariable.getDBType(), ConfigBaseVariable.getDBHost(), dbConfig = new DBConfig(ConfigBaseVariable.getDBType(), ConfigBaseVariable.getDBHost(),

View File

@ -969,13 +969,12 @@ public class DataAccess {
// uniqueSQLUUID = generatedKeys.getObject(1, UUID.class); // uniqueSQLUUID = generatedKeys.getObject(1, UUID.class);
/* final Object obj = generatedKeys.getObject(1); final BigInteger bigint = (BigInteger) generatedKeys.getObject(1); uniqueSQLUUID = UuidUtils.asUuid(bigint); final UUID /* final Object obj = generatedKeys.getObject(1); final BigInteger bigint = (BigInteger) generatedKeys.getObject(1); uniqueSQLUUID = UuidUtils.asUuid(bigint); final UUID
* generatedUUID = (UUID) generatedKeys.getObject(1); System.out.println("UUID généré: " + generatedUUID); */ * generatedUUID = (UUID) generatedKeys.getObject(1); System.out.println("UUID généré: " + generatedUUID); */
final Object obj = generatedKeys.getObject(1); //final Object obj = generatedKeys.getObject(1);
final byte[] tmpid = generatedKeys.getBytes(1); final byte[] tmpid = generatedKeys.getBytes(1);
uniqueSQLUUID = UuidUtils.asUuid(tmpid); uniqueSQLUUID = UuidUtils.asUuid(tmpid);
} else { } else {
uniqueSQLID = generatedKeys.getLong(1); uniqueSQLID = generatedKeys.getLong(1);
} }
} else { } else {
throw new SQLException("Creating node failed, no ID obtained (1)."); throw new SQLException("Creating node failed, no ID obtained (1).");
} }
@ -985,6 +984,7 @@ public class DataAccess {
throw new SQLException("Creating node failed, no ID obtained (2)."); throw new SQLException("Creating node failed, no ID obtained (2).");
} }
} }
ps.close();
if (primaryKeyField != null) { if (primaryKeyField != null) {
if (primaryKeyField.getType() == Long.class) { if (primaryKeyField.getType() == Long.class) {
primaryKeyField.set(data, uniqueSQLID); primaryKeyField.set(data, uniqueSQLID);
@ -1228,7 +1228,9 @@ public class DataAccess {
} }
} }
condition.injectQuery(ps, iii); condition.injectQuery(ps, iii);
return ps.executeUpdate(); final int out = ps.executeUpdate();
ps.close();
return out;
} }
} catch (final SQLException ex) { } catch (final SQLException ex) {
ex.printStackTrace(); ex.printStackTrace();
@ -1574,10 +1576,6 @@ public class DataAccess {
return getsWhere(clazz, option); return getsWhere(clazz, option);
} }
public static <ID_TYPE> int delete(final Class<?> clazz, final ID_TYPE id) throws Exception {
return delete(clazz, id, null);
}
/** Delete items with the specific Id (cf @Id) and some options. If the Entity is manage as a softDeleted model, then it is flag as removed (if not already done before). /** Delete items with the specific Id (cf @Id) and some options. If the Entity is manage as a softDeleted model, then it is flag as removed (if not already done before).
* @param <ID_TYPE> Type of the reference @Id * @param <ID_TYPE> Type of the reference @Id
* @param clazz Data model that might remove element * @param clazz Data model that might remove element

View File

@ -47,7 +47,7 @@ public class UuidUtils {
this.base = startingUUID.until(Instant.now(), ChronoUnit.SECONDS); this.base = startingUUID.until(Instant.now(), ChronoUnit.SECONDS);
final String serveurBaseUUID = System.getenv("UUID_SERVER_ID"); final String serveurBaseUUID = System.getenv("UUID_SERVER_ID");
if (serveurBaseUUID != null) { if (serveurBaseUUID != null) {
long serverId = Long.valueOf(serveurBaseUUID); long serverId = Long.parseLong(serveurBaseUUID);
serverId %= 0xFFFF; serverId %= 0xFFFF;
this.base += (serverId << (64 - 16)); this.base += (serverId << (64 - 16));
} else { } else {