[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>

19
pom.xml
View File

@ -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>
@ -183,7 +182,6 @@
<version>3.3.1</version> <version>3.3.1</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<sourceDirectory>src</sourceDirectory> <sourceDirectory>src</sourceDirectory>
<resources> <resources>
@ -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 {