[FIX] SpotBug finding some errors
This commit is contained in:
parent
c94f488747
commit
6af6f91166
@ -300,9 +300,10 @@ public class DataResource {
|
|||||||
// logger.info("===================================================");
|
// logger.info("===================================================");
|
||||||
final Data value = getSmall(uuid);
|
final Data value = getSmall(uuid);
|
||||||
if (value == null) {
|
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
|
@GET
|
||||||
@ -389,9 +390,10 @@ public class DataResource {
|
|||||||
// logger.info("===================================================");
|
// logger.info("===================================================");
|
||||||
final Data value = getSmall(uuid);
|
final Data value = getSmall(uuid);
|
||||||
if (value == null) {
|
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
|
/** Adapted from http://stackoverflow.com/questions/12768812/video-streaming-to-ipad-does-not-work-with-tapestry5/12829541#12829541
|
||||||
|
@ -1115,10 +1115,13 @@ public class DataAccess {
|
|||||||
return updateWhere(data, options);
|
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();
|
final Class<?> clazz = data.getClass();
|
||||||
|
if (options == null) {
|
||||||
|
options = new QueryOptions();
|
||||||
|
}
|
||||||
final Condition condition = conditionFusionOrEmpty(options, true);
|
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) {
|
if (filters.size() != 1) {
|
||||||
throw new DataAccessException("request a gets without/or with more 1 filter of values");
|
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)
|
public static Condition conditionFusionOrEmpty(final QueryOptions options, final boolean throwIfEmpty)
|
||||||
throws DataAccessException {
|
throws DataAccessException {
|
||||||
|
if (options == null) {
|
||||||
|
return new Condition();
|
||||||
|
}
|
||||||
final List<Condition> conditions = options.get(Condition.class);
|
final List<Condition> conditions = options.get(Condition.class);
|
||||||
if (conditions.size() == 0) {
|
if (conditions.size() == 0) {
|
||||||
if (throwIfEmpty) {
|
if (throwIfEmpty) {
|
||||||
|
@ -6,7 +6,6 @@ import org.kar.archidata.annotation.DataJson;
|
|||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Id;
|
|
||||||
|
|
||||||
public class TableCoversLongLong extends GenericDataSoftDelete {
|
public class TableCoversLongLong extends GenericDataSoftDelete {
|
||||||
public TableCoversLongLong() {
|
public TableCoversLongLong() {
|
||||||
@ -18,9 +17,6 @@ public class TableCoversLongLong extends GenericDataSoftDelete {
|
|||||||
this.covers = covers;
|
this.covers = covers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
@Id
|
|
||||||
public Long id;
|
|
||||||
@DataJson()
|
@DataJson()
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public List<Long> covers;
|
public List<Long> covers;
|
||||||
|
@ -7,7 +7,6 @@ import org.kar.archidata.annotation.DataJson;
|
|||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Id;
|
|
||||||
|
|
||||||
public class TableCoversLongUUID extends GenericDataSoftDelete {
|
public class TableCoversLongUUID extends GenericDataSoftDelete {
|
||||||
public TableCoversLongUUID() {
|
public TableCoversLongUUID() {
|
||||||
@ -19,9 +18,6 @@ public class TableCoversLongUUID extends GenericDataSoftDelete {
|
|||||||
this.covers = covers;
|
this.covers = covers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
@Id
|
|
||||||
public Long id;
|
|
||||||
@DataJson()
|
@DataJson()
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public List<UUID> covers;
|
public List<UUID> covers;
|
||||||
|
@ -36,6 +36,9 @@ public class DBInterfaceOption extends QueryOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static DBEntry getAutoEntry(final QueryOptions options) throws IOException {
|
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);
|
final List<DBInterfaceOption> dbOption = options.get(DBInterfaceOption.class);
|
||||||
if (dbOption.size() == 0) {
|
if (dbOption.size() == 0) {
|
||||||
final List<DBInterfaceRoot> isRoot = options.get(DBInterfaceRoot.class);
|
final List<DBInterfaceRoot> isRoot = options.get(DBInterfaceRoot.class);
|
||||||
|
@ -318,12 +318,12 @@ public class MigrationEngine {
|
|||||||
boolean find = false;
|
boolean find = false;
|
||||||
for (int iii = this.datas.size() - 1; iii >= 0; iii--) {
|
for (int iii = this.datas.size() - 1; iii >= 0; iii--) {
|
||||||
if (!find) {
|
if (!find) {
|
||||||
if (this.datas.get(iii).getName() == currentVersion.name) {
|
if (this.datas.get(iii).getName().equals(currentVersion.name)) {
|
||||||
find = true;
|
find = true;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (this.datas.get(iii).getName() == currentVersion.name) {
|
if (this.datas.get(iii).getName().equals(currentVersion.name)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
toApply.add(this.datas.get(iii));
|
toApply.add(this.datas.get(iii));
|
||||||
|
@ -22,7 +22,7 @@ public class UserByToken {
|
|||||||
final Object data = this.right.get(key);
|
final Object data = this.right.get(key);
|
||||||
if (data instanceof final Boolean elem) {
|
if (data instanceof final Boolean elem) {
|
||||||
if (value instanceof final Boolean castVal) {
|
if (value instanceof final Boolean castVal) {
|
||||||
if (elem == castVal) {
|
if (elem.equals(castVal)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ public class UserByToken {
|
|||||||
}
|
}
|
||||||
if (data instanceof final Long elem) {
|
if (data instanceof final Long elem) {
|
||||||
if (value instanceof final Long castVal) {
|
if (value instanceof final Long castVal) {
|
||||||
if (elem == castVal) {
|
if (elem.equals(castVal)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ public class UserByToken {
|
|||||||
}
|
}
|
||||||
if (data instanceof final Double elem) {
|
if (data instanceof final Double elem) {
|
||||||
if (value instanceof final Double castVal) {
|
if (value instanceof final Double castVal) {
|
||||||
if (elem == castVal) {
|
if (elem.equals(castVal)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -219,6 +220,10 @@ public class JWTWrapper {
|
|||||||
try {
|
try {
|
||||||
// On the consumer side, parse the JWS and verify its RSA signature
|
// On the consumer side, parse the JWS and verify its RSA signature
|
||||||
final SignedJWT signedJWT = SignedJWT.parse(signedToken);
|
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)) {
|
if (ConfigBaseVariable.getTestMode() && signedToken.endsWith(TestSigner.test_signature)) {
|
||||||
LOGGER.warn("Someone use a test token: {}", signedToken);
|
LOGGER.warn("Someone use a test token: {}", signedToken);
|
||||||
} else if (rsaPublicJWK == null) {
|
} else if (rsaPublicJWK == null) {
|
||||||
@ -226,7 +231,7 @@ public class JWTWrapper {
|
|||||||
if (!ConfigBaseVariable.getTestMode()) {
|
if (!ConfigBaseVariable.getTestMode()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final String rawSignature = signedJWT.getSigningInput().toString();
|
final String rawSignature = new String(signedJWT.getSigningInput(), StandardCharsets.UTF_8);
|
||||||
if (rawSignature.equals(TestSigner.test_signature)) {
|
if (rawSignature.equals(TestSigner.test_signature)) {
|
||||||
// Test token : .application..
|
// Test token : .application..
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user