[FIX] SpotBug finding some errors

This commit is contained in:
Edouard DUPIN 2024-06-01 16:48:59 +02:00
parent c94f488747
commit 6af6f91166
8 changed files with 28 additions and 20 deletions

View File

@ -300,9 +300,10 @@ public class DataResource {
// logger.info("===================================================");
final Data value = getSmall(uuid);
if (value == null) {
Response.status(404).entity("media NOT FOUND: " + uuid).type("text/plain").build();
return Response.status(404).entity("media NOT FOUND: " + uuid).type("text/plain").build();
}
return buildStream(getFileData(uuid), range, value.mimeType);
return buildStream(getFileData(uuid), range,
value.mimeType == null ? "application/octet-stream" : value.mimeType);
}
@GET
@ -389,9 +390,10 @@ public class DataResource {
// logger.info("===================================================");
final Data value = getSmall(uuid);
if (value == null) {
Response.status(404).entity("media NOT FOUND: " + uuid).type("text/plain").build();
return Response.status(404).entity("media NOT FOUND: " + uuid).type("text/plain").build();
}
return buildStream(getFileData(uuid), range, value.mimeType);
return buildStream(getFileData(uuid), range,
value.mimeType == null ? "application/octet-stream" : value.mimeType);
}
/** Adapted from http://stackoverflow.com/questions/12768812/video-streaming-to-ipad-does-not-work-with-tapestry5/12829541#12829541

View File

@ -1115,10 +1115,13 @@ public class DataAccess {
return updateWhere(data, options);
}
public static <T> int updateWhere(final T data, final QueryOptions options) throws Exception {
public static <T> int updateWhere(final T data, QueryOptions options) throws Exception {
final Class<?> clazz = data.getClass();
if (options == null) {
options = new QueryOptions();
}
final Condition condition = conditionFusionOrEmpty(options, true);
final List<FilterValue> filters = options.get(FilterValue.class);
final List<FilterValue> filters = options != null ? options.get(FilterValue.class) : new ArrayList<>();
if (filters.size() != 1) {
throw new DataAccessException("request a gets without/or with more 1 filter of values");
}
@ -1365,6 +1368,9 @@ public class DataAccess {
public static Condition conditionFusionOrEmpty(final QueryOptions options, final boolean throwIfEmpty)
throws DataAccessException {
if (options == null) {
return new Condition();
}
final List<Condition> conditions = options.get(Condition.class);
if (conditions.size() == 0) {
if (throwIfEmpty) {

View File

@ -6,7 +6,6 @@ import org.kar.archidata.annotation.DataJson;
import org.kar.archidata.model.GenericDataSoftDelete;
import jakarta.persistence.Column;
import jakarta.persistence.Id;
public class TableCoversLongLong extends GenericDataSoftDelete {
public TableCoversLongLong() {
@ -18,9 +17,6 @@ public class TableCoversLongLong extends GenericDataSoftDelete {
this.covers = covers;
}
@Column(nullable = false)
@Id
public Long id;
@DataJson()
@Column(nullable = false)
public List<Long> covers;

View File

@ -7,7 +7,6 @@ import org.kar.archidata.annotation.DataJson;
import org.kar.archidata.model.GenericDataSoftDelete;
import jakarta.persistence.Column;
import jakarta.persistence.Id;
public class TableCoversLongUUID extends GenericDataSoftDelete {
public TableCoversLongUUID() {
@ -19,9 +18,6 @@ public class TableCoversLongUUID extends GenericDataSoftDelete {
this.covers = covers;
}
@Column(nullable = false)
@Id
public Long id;
@DataJson()
@Column(nullable = false)
public List<UUID> covers;

View File

@ -36,6 +36,9 @@ public class DBInterfaceOption extends QueryOption {
}
public static DBEntry getAutoEntry(final QueryOptions options) throws IOException {
if (options == null) {
return DBEntry.createInterface(GlobalConfiguration.dbConfig, false);
}
final List<DBInterfaceOption> dbOption = options.get(DBInterfaceOption.class);
if (dbOption.size() == 0) {
final List<DBInterfaceRoot> isRoot = options.get(DBInterfaceRoot.class);

View File

@ -318,12 +318,12 @@ public class MigrationEngine {
boolean find = false;
for (int iii = this.datas.size() - 1; iii >= 0; iii--) {
if (!find) {
if (this.datas.get(iii).getName() == currentVersion.name) {
if (this.datas.get(iii).getName().equals(currentVersion.name)) {
find = true;
}
continue;
}
if (this.datas.get(iii).getName() == currentVersion.name) {
if (this.datas.get(iii).getName().equals(currentVersion.name)) {
break;
}
toApply.add(this.datas.get(iii));

View File

@ -22,7 +22,7 @@ public class UserByToken {
final Object data = this.right.get(key);
if (data instanceof final Boolean elem) {
if (value instanceof final Boolean castVal) {
if (elem == castVal) {
if (elem.equals(castVal)) {
return true;
}
}
@ -38,7 +38,7 @@ public class UserByToken {
}
if (data instanceof final Long elem) {
if (value instanceof final Long castVal) {
if (elem == castVal) {
if (elem.equals(castVal)) {
return true;
}
}
@ -46,7 +46,7 @@ public class UserByToken {
}
if (data instanceof final Double elem) {
if (value instanceof final Double castVal) {
if (elem == castVal) {
if (elem.equals(castVal)) {
return true;
}
}

View File

@ -5,6 +5,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.util.Date;
import java.util.Map;
@ -219,6 +220,10 @@ public class JWTWrapper {
try {
// On the consumer side, parse the JWS and verify its RSA signature
final SignedJWT signedJWT = SignedJWT.parse(signedToken);
if (signedJWT == null) {
LOGGER.error("FAIL to parse signing");
return null;
}
if (ConfigBaseVariable.getTestMode() && signedToken.endsWith(TestSigner.test_signature)) {
LOGGER.warn("Someone use a test token: {}", signedToken);
} else if (rsaPublicJWK == null) {
@ -226,7 +231,7 @@ public class JWTWrapper {
if (!ConfigBaseVariable.getTestMode()) {
return null;
}
final String rawSignature = signedJWT.getSigningInput().toString();
final String rawSignature = new String(signedJWT.getSigningInput(), StandardCharsets.UTF_8);
if (rawSignature.equals(TestSigner.test_signature)) {
// Test token : .application..
} else {