[DEV] rework to finalize API
This commit is contained in:
parent
5fc45a23d3
commit
d9fcacc812
@ -15,6 +15,9 @@ import jakarta.persistence.GeneratedValue;
|
|||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import jakarta.validation.constraints.Pattern;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
|
||||||
public class AnnotationTools {
|
public class AnnotationTools {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(AnnotationTools.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(AnnotationTools.class);
|
||||||
@ -79,6 +82,28 @@ public class AnnotationTools {
|
|||||||
return length <= 0 ? null : length;
|
return length <= 0 ? null : length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Size getConstraintsSize(final Field element) throws Exception {
|
||||||
|
final Annotation[] annotation = element.getDeclaredAnnotationsByType(Size.class);
|
||||||
|
if (annotation.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (annotation.length > 1) {
|
||||||
|
throw new Exception("Must not have more than 1 element @Size on " + element.getClass().getCanonicalName());
|
||||||
|
}
|
||||||
|
return (Size) annotation[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getConstraintsPattern(final Field element) throws Exception {
|
||||||
|
final Annotation[] annotation = element.getDeclaredAnnotationsByType(Pattern.class);
|
||||||
|
if (annotation.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (annotation.length > 1) {
|
||||||
|
throw new Exception("Must not have more than 1 element @Pattern on " + element.getClass().getCanonicalName());
|
||||||
|
}
|
||||||
|
return ((Pattern) annotation[0]).regexp();
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isAnnotationGroup(final Field field, final Class<?> annotationType) {
|
public static boolean isAnnotationGroup(final Field field, final Class<?> annotationType) {
|
||||||
try {
|
try {
|
||||||
final Annotation[] anns = field.getAnnotations();
|
final Annotation[] anns = field.getAnnotations();
|
||||||
@ -117,7 +142,7 @@ public class AnnotationTools {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getNotNull(final Field element) throws Exception {
|
public static boolean getColumnNotNull(final Field element) throws Exception {
|
||||||
final Annotation[] annotation = element.getDeclaredAnnotationsByType(Column.class);
|
final Annotation[] annotation = element.getDeclaredAnnotationsByType(Column.class);
|
||||||
if (annotation.length == 0) {
|
if (annotation.length == 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -128,6 +153,17 @@ public class AnnotationTools {
|
|||||||
return !((Column) annotation[0]).nullable();
|
return !((Column) annotation[0]).nullable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean getConstraintsNotNull(final Field element) throws Exception {
|
||||||
|
final Annotation[] annotation = element.getDeclaredAnnotationsByType(NotNull.class);
|
||||||
|
if (annotation.length == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (annotation.length > 1) {
|
||||||
|
throw new Exception("Must not have more than 1 element @NotNull on " + element.getClass().getCanonicalName());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isPrimaryKey(final Field element) throws Exception {
|
public static boolean isPrimaryKey(final Field element) throws Exception {
|
||||||
final Annotation[] annotation = element.getDeclaredAnnotationsByType(Id.class);
|
final Annotation[] annotation = element.getDeclaredAnnotationsByType(Id.class);
|
||||||
if (annotation.length == 0) {
|
if (annotation.length == 0) {
|
||||||
@ -135,6 +171,7 @@ public class AnnotationTools {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUnique(final Field element) throws Exception {
|
public static boolean isUnique(final Field element) throws Exception {
|
||||||
final Annotation[] annotation = element.getDeclaredAnnotationsByType(Column.class);
|
final Annotation[] annotation = element.getDeclaredAnnotationsByType(Column.class);
|
||||||
if (annotation.length == 0) {
|
if (annotation.length == 0) {
|
||||||
|
@ -10,17 +10,17 @@ import jakarta.ws.rs.ext.ExceptionMapper;
|
|||||||
|
|
||||||
public class InputExceptionCatcher implements ExceptionMapper<InputException> {
|
public class InputExceptionCatcher implements ExceptionMapper<InputException> {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(InputExceptionCatcher.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(InputExceptionCatcher.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(final InputException exception) {
|
public Response toResponse(final InputException exception) {
|
||||||
final RestErrorResponse ret = build(exception);
|
final RestErrorResponse ret = build(exception);
|
||||||
LOGGER.error("Error UUID={} ==> '{}'=>'{}'", ret.uuid, exception.missingVariable, exception.getLocalizedMessage());
|
LOGGER.error("Error UUID={} ==> '{}'=>'{}'", ret.uuid, exception.missingVariable, exception.getLocalizedMessage());
|
||||||
//exception.printStackTrace();
|
// exception.printStackTrace();
|
||||||
return Response.status(exception.status).entity(ret).type(MediaType.APPLICATION_JSON).build();
|
return Response.status(exception.status).entity(ret).type(MediaType.APPLICATION_JSON).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private RestErrorResponse build(final InputException exception) {
|
private RestErrorResponse build(final InputException exception) {
|
||||||
return new RestErrorResponse(exception.status, "Error on input='" + exception.missingVariable + "'", exception.getMessage());
|
return new RestErrorResponse(exception.status, "Error on input='" + exception.missingVariable + "'", exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import org.kar.archidata.dataAccess.addOn.AddOnManyToOne;
|
|||||||
import org.kar.archidata.dataAccess.addOn.AddOnSQLTableExternalForeinKeyAsList;
|
import org.kar.archidata.dataAccess.addOn.AddOnSQLTableExternalForeinKeyAsList;
|
||||||
import org.kar.archidata.dataAccess.options.AccessDeletedItems;
|
import org.kar.archidata.dataAccess.options.AccessDeletedItems;
|
||||||
import org.kar.archidata.dataAccess.options.CheckFunction;
|
import org.kar.archidata.dataAccess.options.CheckFunction;
|
||||||
import org.kar.archidata.dataAccess.options.Limit;
|
import org.kar.archidata.dataAccess.options.Condition;
|
||||||
import org.kar.archidata.db.DBEntry;
|
import org.kar.archidata.db.DBEntry;
|
||||||
import org.kar.archidata.exception.DataAccessException;
|
import org.kar.archidata.exception.DataAccessException;
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||||
@ -544,6 +544,10 @@ public class DataAccess {
|
|||||||
query.append("?");
|
query.append("?");
|
||||||
}
|
}
|
||||||
query.append(")");
|
query.append(")");
|
||||||
|
final OrderBy orders = options.get(OrderBy.class);
|
||||||
|
if (orders != null) {
|
||||||
|
orders.generateQuerry(query, tableName);
|
||||||
|
}
|
||||||
LOGGER.warn("generate the query: '{}'", query.toString());
|
LOGGER.warn("generate the query: '{}'", query.toString());
|
||||||
// prepare the request:
|
// prepare the request:
|
||||||
final PreparedStatement ps = entry.connection.prepareStatement(query.toString(), Statement.RETURN_GENERATED_KEYS);
|
final PreparedStatement ps = entry.connection.prepareStatement(query.toString(), Statement.RETURN_GENERATED_KEYS);
|
||||||
@ -628,7 +632,6 @@ public class DataAccess {
|
|||||||
final ObjectMapper mapper = new ObjectMapper();
|
final ObjectMapper mapper = new ObjectMapper();
|
||||||
// parse the object to be sure the data are valid:
|
// parse the object to be sure the data are valid:
|
||||||
final T data = mapper.readValue(jsonData, clazz);
|
final T data = mapper.readValue(jsonData, clazz);
|
||||||
|
|
||||||
return insert(data);
|
return insert(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,6 +749,11 @@ public class DataAccess {
|
|||||||
query.append("` = ? ");
|
query.append("` = ? ");
|
||||||
}
|
}
|
||||||
query.append(" ");
|
query.append(" ");
|
||||||
|
final OrderBy orders = options.get(OrderBy.class);
|
||||||
|
if (orders != null) {
|
||||||
|
orders.generateQuerry(query, tableName);
|
||||||
|
}
|
||||||
|
query.append(" ");
|
||||||
final String deletedFieldName = AnnotationTools.getDeletedFieldName(clazz);
|
final String deletedFieldName = AnnotationTools.getDeletedFieldName(clazz);
|
||||||
whereAppendQuery(query, tableName, condition, null, deletedFieldName);
|
whereAppendQuery(query, tableName, condition, null, deletedFieldName);
|
||||||
firstField = true;
|
firstField = true;
|
||||||
@ -855,10 +863,13 @@ public class DataAccess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void whereInjectValue(final PreparedStatement ps, final QueryItem condition, final CountInOut iii) throws Exception {
|
public static void whereInjectValue(final PreparedStatement ps, final QueryOptions options, final CountInOut iii) throws Exception {
|
||||||
// Check if we have a condition to generate
|
// Check if we have a condition to generate
|
||||||
if (condition != null) {
|
if (options != null) {
|
||||||
condition.injectQuerry(ps, iii);
|
final Condition condition = options.get(Condition.class);
|
||||||
|
if (condition != null) {
|
||||||
|
condition.injectQuerry(ps, iii);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -882,16 +893,16 @@ public class DataAccess {
|
|||||||
return executeQuerry(query, false);
|
return executeQuerry(query, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T getWhere(final Class<T> clazz, final QueryItem condition) throws Exception {
|
public static <T> T getWhere(final Class<T> clazz, QueryOptions options) throws Exception {
|
||||||
return getWhere(clazz, condition, null);
|
return getWhere(clazz, options);
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T getWhere(final Class<T> clazz, final QueryItem condition, QueryOptions options) throws Exception {
|
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
options = new QueryOptions();
|
options = new QueryOptions();
|
||||||
}
|
}
|
||||||
options.add(new Limit(1));
|
final Limit limit = options.get(Limit.class);
|
||||||
final List<T> values = getsWhere(clazz, condition, options);
|
if (limit != null) {
|
||||||
|
options.add(new Limit(1));
|
||||||
|
}
|
||||||
|
final List<T> values = getsWhere(clazz, options);
|
||||||
if (values.size() == 0) {
|
if (values.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -899,11 +910,7 @@ public class DataAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> List<T> getsWhere(final Class<T> clazz, final QueryItem condition) throws Exception {
|
public static <T> List<T> getsWhere(final Class<T> clazz, final QueryItem condition) throws Exception {
|
||||||
return getsWhere(clazz, condition, null, null);
|
return getsWhere(clazz, condition, null);
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> List<T> getsWhere(final Class<T> clazz, final QueryItem condition, final QueryOptions options) throws Exception {
|
|
||||||
return getsWhere(clazz, condition, null, options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void generateSelectField(final StringBuilder querySelect, final StringBuilder query, final Class<?> clazz, final QueryOptions options, final CountInOut count) throws Exception {
|
public static void generateSelectField(final StringBuilder querySelect, final StringBuilder query, final Class<?> clazz, final QueryOptions options, final CountInOut count) throws Exception {
|
||||||
@ -943,7 +950,7 @@ public class DataAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> List<T> getsWhere(final Class<T> clazz, final QueryItem condition, final String orderBy, final QueryOptions options) throws Exception {
|
public static <T> List<T> getsWhere(final Class<T> clazz, final QueryItem condition, final QueryOptions options) throws Exception {
|
||||||
final List<LazyGetter> lazyCall = new ArrayList<>();
|
final List<LazyGetter> lazyCall = new ArrayList<>();
|
||||||
final String deletedFieldName = AnnotationTools.getDeletedFieldName(clazz);
|
final String deletedFieldName = AnnotationTools.getDeletedFieldName(clazz);
|
||||||
DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
|
DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
|
||||||
@ -963,22 +970,13 @@ public class DataAccess {
|
|||||||
querySelect.append(query.toString());
|
querySelect.append(query.toString());
|
||||||
query = querySelect;
|
query = querySelect;
|
||||||
whereAppendQuery(query, tableName, condition, options, deletedFieldName);
|
whereAppendQuery(query, tableName, condition, options, deletedFieldName);
|
||||||
if (orderBy != null && orderBy.length() >= 1) {
|
final OrderBy orders = options.get(OrderBy.class);
|
||||||
query.append(" ORDER BY ");
|
if (orders != null) {
|
||||||
query.append(orderBy);
|
orders.generateQuerry(query, tableName);
|
||||||
}
|
}
|
||||||
if (options != null) {
|
final Limit limit = options.get(Limit.class);
|
||||||
final Limit limit = options.get(Limit.class);
|
if (limit != null) {
|
||||||
if (limit != null) {
|
limit.generateQuerry(query, tableName);
|
||||||
if (limit.getLimit() >= 1) {
|
|
||||||
query.append(" LIMIT " + limit.getLimit());
|
|
||||||
} else {
|
|
||||||
LOGGER.warn("Limit is equal @ {}", limit.getLimit());
|
|
||||||
entry.close();
|
|
||||||
entry = null;
|
|
||||||
return outs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
LOGGER.warn("generate the query: '{}'", query.toString());
|
LOGGER.warn("generate the query: '{}'", query.toString());
|
||||||
// prepare the request:
|
// prepare the request:
|
||||||
|
@ -37,8 +37,8 @@ public interface DataAccessAddOn {
|
|||||||
// Element can be retrieve with the specific mode
|
// Element can be retrieve with the specific mode
|
||||||
boolean canRetrieve(final Field field);
|
boolean canRetrieve(final Field field);
|
||||||
|
|
||||||
void generateQuerry(@NotNull String tableName, @NotNull Field field, @NotNull final StringBuilder querrySelect, @NotNull final StringBuilder querry, @NotNull String name,
|
void generateQuerry(@NotNull String tableName, @NotNull Field field, @NotNull final StringBuilder querySelect, @NotNull final StringBuilder query, @NotNull String name, @NotNull CountInOut count,
|
||||||
@NotNull CountInOut count, QueryOptions options) throws Exception;
|
QueryOptions options) throws Exception;
|
||||||
|
|
||||||
// Return the number of colomn read
|
// Return the number of colomn read
|
||||||
void fillFromQuerry(ResultSet rs, Field field, Object data, CountInOut count, QueryOptions options, final List<LazyGetter> lazyCall)
|
void fillFromQuerry(ResultSet rs, Field field, Object data, CountInOut count, QueryOptions options, final List<LazyGetter> lazyCall)
|
||||||
|
@ -132,7 +132,7 @@ public class DataFactory {
|
|||||||
final boolean createIfNotExist, final boolean createDrop, final int fieldId, final Class<?> classModel) throws Exception {
|
final boolean createIfNotExist, final boolean createDrop, final int fieldId, final Class<?> classModel) throws Exception {
|
||||||
final String name = AnnotationTools.getFieldName(elem);
|
final String name = AnnotationTools.getFieldName(elem);
|
||||||
final Integer limitSize = AnnotationTools.getLimitSize(elem);
|
final Integer limitSize = AnnotationTools.getLimitSize(elem);
|
||||||
final boolean notNull = AnnotationTools.getNotNull(elem);
|
final boolean notNull = AnnotationTools.getColumnNotNull(elem);
|
||||||
|
|
||||||
final boolean primaryKey = AnnotationTools.isPrimaryKey(elem);
|
final boolean primaryKey = AnnotationTools.isPrimaryKey(elem);
|
||||||
final GenerationType strategy = AnnotationTools.getStrategy(elem);
|
final GenerationType strategy = AnnotationTools.getStrategy(elem);
|
||||||
|
20
src/org/kar/archidata/dataAccess/Limit.java
Normal file
20
src/org/kar/archidata/dataAccess/Limit.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package org.kar.archidata.dataAccess;
|
||||||
|
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
|
||||||
|
public class Limit extends QueryOption {
|
||||||
|
protected final long limit;
|
||||||
|
|
||||||
|
public Limit(final long limit) {
|
||||||
|
this.limit = limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateQuerry(final StringBuilder query, final String tableName) {
|
||||||
|
query.append(" LIMIT ? ");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void injectQuerry(final PreparedStatement ps, final CountInOut iii) throws Exception {
|
||||||
|
DataAccess.addElement(ps, this.limit, iii);
|
||||||
|
iii.inc();
|
||||||
|
}
|
||||||
|
}
|
41
src/org/kar/archidata/dataAccess/OrderBy.java
Normal file
41
src/org/kar/archidata/dataAccess/OrderBy.java
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package org.kar.archidata.dataAccess;
|
||||||
|
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class OrderBy extends QueryOption {
|
||||||
|
protected final List<OrderItem> childs;
|
||||||
|
|
||||||
|
public OrderBy(final List<OrderItem> childs) {
|
||||||
|
this.childs = childs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderBy(final OrderItem... childs) {
|
||||||
|
this.childs = List.of(childs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateQuerry(final StringBuilder query, final String tableName) {
|
||||||
|
if (this.childs.size() >= 1) {
|
||||||
|
query.append(" ORDER BY ");
|
||||||
|
}
|
||||||
|
boolean first = true;
|
||||||
|
for (final OrderItem elem : this.childs) {
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
query.append(", ");
|
||||||
|
}
|
||||||
|
query.append("`");
|
||||||
|
query.append(elem.value);
|
||||||
|
query.append("` ");
|
||||||
|
query.append(elem.order.toString());
|
||||||
|
}
|
||||||
|
if (this.childs.size() >= 1) {
|
||||||
|
query.append(")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void injectQuerry(final PreparedStatement ps, final CountInOut iii) throws Exception {
|
||||||
|
// nothing to add.
|
||||||
|
}
|
||||||
|
}
|
16
src/org/kar/archidata/dataAccess/OrderItem.java
Normal file
16
src/org/kar/archidata/dataAccess/OrderItem.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package org.kar.archidata.dataAccess;
|
||||||
|
|
||||||
|
public class OrderItem {
|
||||||
|
public enum Order {
|
||||||
|
ASC, DESC
|
||||||
|
};
|
||||||
|
|
||||||
|
public final String value;
|
||||||
|
public final Order order;
|
||||||
|
|
||||||
|
public OrderItem(final String value, final Order order) {
|
||||||
|
this.value = value;
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -18,21 +18,21 @@ public class QueryAnd implements QueryItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateQuerry(final StringBuilder querry, final String tableName) {
|
public void generateQuerry(final StringBuilder query, final String tableName) {
|
||||||
if (this.childs.size() >= 1) {
|
if (this.childs.size() >= 1) {
|
||||||
querry.append(" (");
|
query.append(" (");
|
||||||
}
|
}
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (final QueryItem elem : this.childs) {
|
for (final QueryItem elem : this.childs) {
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
querry.append(" AND ");
|
query.append(" AND ");
|
||||||
}
|
}
|
||||||
elem.generateQuerry(querry, tableName);
|
elem.generateQuerry(query, tableName);
|
||||||
}
|
}
|
||||||
if (this.childs.size() >= 1) {
|
if (this.childs.size() >= 1) {
|
||||||
querry.append(")");
|
query.append(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,14 +14,13 @@ public class QueryCondition implements QueryItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateQuerry(final StringBuilder querry, final String tableName) {
|
public void generateQuerry(final StringBuilder query, final String tableName) {
|
||||||
querry.append(tableName);
|
query.append(tableName);
|
||||||
querry.append(".");
|
query.append(".");
|
||||||
querry.append(this.key);
|
query.append(this.key);
|
||||||
querry.append(" ");
|
query.append(" ");
|
||||||
querry.append(this.comparator);
|
query.append(this.comparator);
|
||||||
querry.append(" ?");
|
query.append(" ?");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,22 +18,26 @@ public class QueryInList<T> implements QueryItem {
|
|||||||
this(key, "IN", value);
|
this(key, "IN", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QueryInList(final String key, final T... value) {
|
||||||
|
this(key, "IN", List.of(value));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateQuerry(final StringBuilder querry, final String tableName) {
|
public void generateQuerry(final StringBuilder query, final String tableName) {
|
||||||
querry.append(tableName);
|
query.append(tableName);
|
||||||
querry.append(".");
|
query.append(".");
|
||||||
querry.append(this.key);
|
query.append(this.key);
|
||||||
querry.append(" ");
|
query.append(" ");
|
||||||
querry.append(this.comparator);
|
query.append(this.comparator);
|
||||||
querry.append(" (");
|
query.append(" (");
|
||||||
for (int iii = 0; iii < this.value.size(); iii++) {
|
for (int iii = 0; iii < this.value.size(); iii++) {
|
||||||
if (iii != 0) {
|
if (iii != 0) {
|
||||||
querry.append(",?");
|
query.append(",?");
|
||||||
} else {
|
} else {
|
||||||
querry.append("?");
|
query.append("?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
querry.append(")");
|
query.append(")");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package org.kar.archidata.dataAccess;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
|
||||||
public interface QueryItem {
|
public interface QueryItem {
|
||||||
void generateQuerry(StringBuilder querry, String tableName);
|
void generateQuerry(StringBuilder query, String tableName);
|
||||||
|
|
||||||
void injectQuerry(PreparedStatement ps, CountInOut iii) throws Exception;
|
void injectQuerry(PreparedStatement ps, CountInOut iii) throws Exception;
|
||||||
}
|
}
|
||||||
|
@ -10,22 +10,26 @@ public class QueryOr implements QueryItem {
|
|||||||
this.childs = childs;
|
this.childs = childs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QueryOr(final QueryItem... childs) {
|
||||||
|
this.childs = List.of(childs);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateQuerry(final StringBuilder querry, final String tableName) {
|
public void generateQuerry(final StringBuilder query, final String tableName) {
|
||||||
if (this.childs.size() >= 1) {
|
if (this.childs.size() >= 1) {
|
||||||
querry.append(" (");
|
query.append(" (");
|
||||||
}
|
}
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (final QueryItem elem : this.childs) {
|
for (final QueryItem elem : this.childs) {
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
querry.append(" OR ");
|
query.append(" OR ");
|
||||||
}
|
}
|
||||||
elem.generateQuerry(querry, tableName);
|
elem.generateQuerry(query, tableName);
|
||||||
}
|
}
|
||||||
if (this.childs.size() >= 1) {
|
if (this.childs.size() >= 1) {
|
||||||
querry.append(")");
|
query.append(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.AnnotationTools;
|
import org.kar.archidata.annotation.AnnotationTools;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
@ -20,11 +21,13 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
|
||||||
public class CheckJPA<T> implements CheckFunctionInterface {
|
public class CheckJPA<T> implements CheckFunctionInterface {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(CheckJPA.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(CheckJPA.class);
|
||||||
private final Class<?> clazz;
|
private final Class<?> clazz;
|
||||||
|
|
||||||
/** By default some element are not read like createAt and UpdatedAt. This option permit to read it. */
|
/** By default some element are not read like createAt and UpdatedAt. This option permit to read it. */
|
||||||
public interface CheckInterface<K> {
|
public interface CheckInterface<K> {
|
||||||
/** This function implementation is design to check if the updated class is valid of not for insertion
|
/** This function implementation is design to check if the updated class is valid of not for insertion
|
||||||
@ -33,10 +36,10 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
* @throws Exception Exception is generate if the data are incorrect. */
|
* @throws Exception Exception is generate if the data are incorrect. */
|
||||||
void check(K data) throws Exception;
|
void check(K data) throws Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, List<CheckInterface<T>>> checking = null;
|
private Map<String, List<CheckInterface<T>>> checking = null;
|
||||||
|
|
||||||
protected void add(String field, CheckInterface<T> checkFunction) {
|
protected void add(final String field, final CheckInterface<T> checkFunction) {
|
||||||
List<CheckInterface<T>> actions = this.checking.get(field);
|
List<CheckInterface<T>> actions = this.checking.get(field);
|
||||||
if (actions == null) {
|
if (actions == null) {
|
||||||
actions = new ArrayList<>();
|
actions = new ArrayList<>();
|
||||||
@ -44,11 +47,11 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
}
|
}
|
||||||
actions.add(checkFunction);
|
actions.add(checkFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckJPA(Class<T> clazz) {
|
public CheckJPA(final Class<T> clazz) {
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
if (this.checking != null) {
|
if (this.checking != null) {
|
||||||
return;
|
return;
|
||||||
@ -58,101 +61,130 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
// create Table:
|
// create Table:
|
||||||
final List<String> primaryKeys = new ArrayList<>();
|
final List<String> primaryKeys = new ArrayList<>();
|
||||||
for (final Field field : this.clazz.getFields()) {
|
for (final Field field : this.clazz.getFields()) {
|
||||||
String fieldName = AnnotationTools.getFieldName(field);
|
final String fieldName = AnnotationTools.getFieldName(field);
|
||||||
if (AnnotationTools.isPrimaryKey(field)) {
|
if (AnnotationTools.isPrimaryKey(field)) {
|
||||||
add(fieldName, (T data) -> {
|
add(fieldName, (final T data) -> {
|
||||||
throw new InputException(fieldName, "This is a '@Id' (primaryKey) ==> can not be change");
|
throw new InputException(fieldName, "This is a '@Id' (primaryKey) ==> can not be change");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (AnnotationTools.getNotNull(field)) {
|
if (AnnotationTools.getConstraintsNotNull(field)) {
|
||||||
add(fieldName, (T data) -> {
|
add(fieldName, (final T data) -> {
|
||||||
if (field.get(data) == null) {
|
if (field.get(data) == null) {
|
||||||
throw new InputException(fieldName, "Can not be null");
|
throw new InputException(fieldName, "Can not be null");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (AnnotationTools.isCreatedAtField(field) || AnnotationTools.isUpdateAtField(field)) {
|
if (AnnotationTools.isCreatedAtField(field) || AnnotationTools.isUpdateAtField(field)) {
|
||||||
add(fieldName, (T data) -> {
|
add(fieldName, (final T data) -> {
|
||||||
throw new InputException(fieldName, "It is forbidden to change this field");
|
throw new InputException(fieldName, "It is forbidden to change this field");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<?> type = field.getType();
|
final Class<?> type = field.getType();
|
||||||
if (type == Long.class || type == long.class) {
|
if (type == Long.class || type == long.class) {
|
||||||
|
|
||||||
} else if (type == Integer.class || type == int.class) {
|
} else if (type == Integer.class || type == int.class) {
|
||||||
|
|
||||||
} else if (type == Boolean.class || type == boolean.class) {
|
} else if (type == Boolean.class || type == boolean.class) {
|
||||||
|
|
||||||
} else if (type == Float.class || type == float.class) {
|
} else if (type == Float.class || type == float.class) {
|
||||||
|
|
||||||
} else if (type == Double.class || type == double.class) {
|
} else if (type == Double.class || type == double.class) {
|
||||||
|
|
||||||
} else if (type == Date.class || type == Timestamp.class) {
|
} else if (type == Date.class || type == Timestamp.class) {
|
||||||
|
|
||||||
} else if (type == LocalDate.class) {
|
} else if (type == LocalDate.class) {
|
||||||
|
|
||||||
} else if (type == LocalTime.class) {
|
} else if (type == LocalTime.class) {
|
||||||
|
|
||||||
} else if (type == String.class) {
|
} else if (type == String.class) {
|
||||||
int maxSizeString = AnnotationTools.getLimitSize(field);
|
final int maxSizeString = AnnotationTools.getLimitSize(field);
|
||||||
|
|
||||||
if (maxSizeString > 0) {
|
if (maxSizeString > 0) {
|
||||||
add(fieldName, (T data) -> {
|
add(fieldName, (final T data) -> {
|
||||||
Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String elemTyped = (String) elem;
|
final String elemTyped = (String) elem;
|
||||||
if (elemTyped.length() > maxSizeString) {
|
if (elemTyped.length() > maxSizeString) {
|
||||||
throw new InputException("name", "Too long size must be <= " + maxSizeString);
|
throw new InputException(fieldName, "Too long size must be <= " + maxSizeString);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
final Size limitSize = AnnotationTools.getConstraintsSize(field);
|
||||||
|
if (limitSize != null) {
|
||||||
|
add(fieldName, (final T data) -> {
|
||||||
|
final Object elem = field.get(data);
|
||||||
|
if (elem == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final String elemTyped = (String) elem;
|
||||||
|
if (elemTyped.length() > limitSize.max()) {
|
||||||
|
throw new InputException(fieldName, "Too long size (constraints) must be <= " + limitSize.max());
|
||||||
|
}
|
||||||
|
if (elemTyped.length() < limitSize.min()) {
|
||||||
|
throw new InputException(fieldName, "Too small size (constraints) must be >= " + limitSize.max());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
final String patternString = AnnotationTools.getConstraintsPattern(field);
|
||||||
|
if (patternString != null) {
|
||||||
|
final Pattern pattern = Pattern.compile(patternString);
|
||||||
|
add(fieldName, (final T data) -> {
|
||||||
|
final Object elem = field.get(data);
|
||||||
|
if (elem == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final String elemTyped = (String) elem;
|
||||||
|
if (!pattern.matcher(elemTyped).find()) {
|
||||||
|
throw new InputException(fieldName, "does not match the required pattern (constraints) must be '" + patternString + "'");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (type == JsonValue.class) {
|
} else if (type == JsonValue.class) {
|
||||||
|
|
||||||
} else if (type.isEnum()) {
|
} else if (type.isEnum()) {
|
||||||
// nothing to do.
|
// nothing to do.
|
||||||
}
|
}
|
||||||
// keep this is last ==> take more time...
|
// keep this is last ==> take more time...
|
||||||
if (AnnotationTools.isUnique(field)) {
|
if (AnnotationTools.isUnique(field)) {
|
||||||
// Create the request ...
|
// Create the request ...
|
||||||
add(fieldName, (T data) -> {
|
add(fieldName, (final T data) -> {
|
||||||
final Object other = DataAccess.getWhere(this.clazz, new QueryCondition(fieldName, "==", field.get(data)));
|
final Object other = DataAccess.getWhere(this.clazz, new QueryCondition(fieldName, "==", field.get(data)));
|
||||||
if (other != null) {
|
if (other != null) {
|
||||||
throw new InputException(fieldName, "Name already exist in the DB");
|
throw new InputException(fieldName, "Name already exist in the DB");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (final Exception ex) {
|
||||||
this.checking = null;
|
this.checking = null;
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void check(Object data, List<String> filterValue) throws Exception {
|
public void check(final Object data, final List<String> filterValue) throws Exception {
|
||||||
initialize();
|
initialize();
|
||||||
if (!(this.clazz.isAssignableFrom(data.getClass()))) {
|
if (!(this.clazz.isAssignableFrom(data.getClass()))) {
|
||||||
throw new DataAccessException("Incompatatyble type of Object" + data.getClass().getCanonicalName());
|
throw new DataAccessException("Incompatatyble type of Object" + data.getClass().getCanonicalName());
|
||||||
}
|
}
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
T dataCasted = (T) data;
|
final T dataCasted = (T) data;
|
||||||
for (String filter : filterValue) {
|
for (final String filter : filterValue) {
|
||||||
List<CheckInterface<T>> actions = this.checking.get(filter);
|
final List<CheckInterface<T>> actions = this.checking.get(filter);
|
||||||
if (actions == null) {
|
if (actions == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (CheckInterface<T> action : actions) {
|
for (final CheckInterface<T> action : actions) {
|
||||||
action.check(dataCasted);
|
action.check(dataCasted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkTyped(dataCasted, filterValue);
|
checkTyped(dataCasted, filterValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkTyped(T data, List<String> filterValue) throws Exception {
|
public void checkTyped(final T data, final List<String> filterValue) throws Exception {
|
||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
28
src/org/kar/archidata/dataAccess/options/Condition.java
Normal file
28
src/org/kar/archidata/dataAccess/options/Condition.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package org.kar.archidata.dataAccess.options;
|
||||||
|
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
|
||||||
|
import org.kar.archidata.dataAccess.CountInOut;
|
||||||
|
import org.kar.archidata.dataAccess.QueryItem;
|
||||||
|
import org.kar.archidata.dataAccess.QueryOption;
|
||||||
|
|
||||||
|
/** By default some element are not read like createAt and UpdatedAt. This option permit to read it. */
|
||||||
|
public class Condition extends QueryOption {
|
||||||
|
public final QueryItem condition;
|
||||||
|
|
||||||
|
public Condition(final QueryItem items) {
|
||||||
|
this.condition = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateQuerry(final StringBuilder query, final String tableName) {
|
||||||
|
if (this.condition != null) {
|
||||||
|
this.condition.generateQuerry(query, tableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void injectQuerry(final PreparedStatement ps, final CountInOut iii) throws Exception {
|
||||||
|
if (this.condition != null) {
|
||||||
|
this.condition.injectQuerry(ps, iii);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +0,0 @@
|
|||||||
package org.kar.archidata.dataAccess.options;
|
|
||||||
|
|
||||||
import org.kar.archidata.dataAccess.QueryOption;
|
|
||||||
|
|
||||||
/** Option that permit to access to a table structure with an other name that is define in the structure. Note: Internal use for link tables (see:
|
|
||||||
* org.kar.archidata.dataAccess.addOn.model.LinkTable). */
|
|
||||||
public class Limit extends QueryOption {
|
|
||||||
private final int limit;
|
|
||||||
|
|
||||||
public Limit(final int limit) {
|
|
||||||
this.limit = limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLimit() {
|
|
||||||
return this.limit;
|
|
||||||
}
|
|
||||||
}
|
|
@ -26,15 +26,15 @@ public class RESTApi {
|
|||||||
final String baseUrl;
|
final String baseUrl;
|
||||||
private String token = null;
|
private String token = null;
|
||||||
final ObjectMapper mapper = new ObjectMapper();
|
final ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
public RESTApi(final String baseUrl) {
|
public RESTApi(final String baseUrl) {
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setToken(final String token) {
|
public void setToken(final String token) {
|
||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> List<T> gets(final Class<T> clazz, final String urlOffset) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
public <T> List<T> gets(final Class<T> clazz, final String urlOffset) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
||||||
final HttpClient client = HttpClient.newHttpClient();
|
final HttpClient client = HttpClient.newHttpClient();
|
||||||
Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1).uri(URI.create(this.baseUrl + urlOffset));
|
Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1).uri(URI.create(this.baseUrl + urlOffset));
|
||||||
@ -49,7 +49,7 @@ public class RESTApi {
|
|||||||
}
|
}
|
||||||
return this.mapper.readValue(httpResponse.body(), new TypeReference<List<T>>() {});
|
return this.mapper.readValue(httpResponse.body(), new TypeReference<List<T>>() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T get(final Class<T> clazz, final String urlOffset) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
public <T> T get(final Class<T> clazz, final String urlOffset) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
||||||
final HttpClient client = HttpClient.newHttpClient();
|
final HttpClient client = HttpClient.newHttpClient();
|
||||||
Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1).uri(URI.create(this.baseUrl + urlOffset));
|
Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1).uri(URI.create(this.baseUrl + urlOffset));
|
||||||
@ -74,7 +74,7 @@ public class RESTApi {
|
|||||||
}
|
}
|
||||||
return this.mapper.readValue(httpResponse.body(), clazz);
|
return this.mapper.readValue(httpResponse.body(), clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T, U> T post(final Class<T> clazz, final String urlOffset, final U data) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
public <T, U> T post(final Class<T> clazz, final String urlOffset, final U data) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
||||||
final HttpClient client = HttpClient.newHttpClient();
|
final HttpClient client = HttpClient.newHttpClient();
|
||||||
final String body = this.mapper.writeValueAsString(data);
|
final String body = this.mapper.writeValueAsString(data);
|
||||||
@ -96,7 +96,7 @@ public class RESTApi {
|
|||||||
}
|
}
|
||||||
return this.mapper.readValue(httpResponse.body(), clazz);
|
return this.mapper.readValue(httpResponse.body(), clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T postMap(final Class<T> clazz, final String urlOffset, final Map<String, Object> data) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
public <T> T postMap(final Class<T> clazz, final String urlOffset, final Map<String, Object> data) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
||||||
final HttpClient client = HttpClient.newHttpClient();
|
final HttpClient client = HttpClient.newHttpClient();
|
||||||
final String body = this.mapper.writeValueAsString(data);
|
final String body = this.mapper.writeValueAsString(data);
|
||||||
@ -116,12 +116,12 @@ public class RESTApi {
|
|||||||
}
|
}
|
||||||
return this.mapper.readValue(httpResponse.body(), clazz);
|
return this.mapper.readValue(httpResponse.body(), clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T, U> T put(final Class<T> clazz, final String urlOffset, final U data) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
public <T, U> T put(final Class<T> clazz, final String urlOffset, final U data) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
||||||
final String body = this.mapper.writeValueAsString(data);
|
final String body = this.mapper.writeValueAsString(data);
|
||||||
return putJson(clazz, urlOffset, body);
|
return putJson(clazz, urlOffset, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T, U> T putJson(final Class<T> clazz, final String urlOffset, final String body) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
public <T, U> T putJson(final Class<T> clazz, final String urlOffset, final String body) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
||||||
final HttpClient client = HttpClient.newHttpClient();
|
final HttpClient client = HttpClient.newHttpClient();
|
||||||
Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1).uri(URI.create(this.baseUrl + urlOffset));
|
Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1).uri(URI.create(this.baseUrl + urlOffset));
|
||||||
@ -142,7 +142,7 @@ public class RESTApi {
|
|||||||
}
|
}
|
||||||
return this.mapper.readValue(httpResponse.body(), clazz);
|
return this.mapper.readValue(httpResponse.body(), clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T putMap(final Class<T> clazz, final String urlOffset, final Map<String, Object> data) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
public <T> T putMap(final Class<T> clazz, final String urlOffset, final Map<String, Object> data) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
||||||
final HttpClient client = HttpClient.newHttpClient();
|
final HttpClient client = HttpClient.newHttpClient();
|
||||||
final String body = this.mapper.writeValueAsString(data);
|
final String body = this.mapper.writeValueAsString(data);
|
||||||
@ -162,7 +162,7 @@ public class RESTApi {
|
|||||||
}
|
}
|
||||||
return this.mapper.readValue(httpResponse.body(), clazz);
|
return this.mapper.readValue(httpResponse.body(), clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T, U> T delete(final Class<T> clazz, final String urlOffset) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
public <T, U> T delete(final Class<T> clazz, final String urlOffset) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
||||||
final HttpClient client = HttpClient.newHttpClient();
|
final HttpClient client = HttpClient.newHttpClient();
|
||||||
Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1).uri(URI.create(this.baseUrl + urlOffset));
|
Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1).uri(URI.create(this.baseUrl + urlOffset));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user