Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| abf1ddcf24 | |||
| 3bbbea87fa | |||
| 25a163d4fa | |||
| c9b9d38efe | |||
| cd3a6a1d8b | |||
|
|
5c1b7cd193 | ||
|
|
9ed09d4fed | ||
|
|
33665d47b8 | ||
|
|
b907d2212a | ||
| a0f4680271 | |||
| d9e118afaa | |||
| 9f43ebc782 | |||
| 8b831522dc | |||
| 4f5d55bb01 | |||
| 9cbeee66c9 | |||
| d25be53b77 | |||
| d36f9c005a |
2
pom.xml
2
pom.xml
@@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>kangaroo-and-rabbit</groupId>
|
<groupId>kangaroo-and-rabbit</groupId>
|
||||||
<artifactId>archidata</artifactId>
|
<artifactId>archidata</artifactId>
|
||||||
<version>0.13.1-SNAPSHOT</version>
|
<version>0.17.0</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>
|
||||||
|
|||||||
19
src/org/kar/archidata/annotation/ARCHIVE.java
Normal file
19
src/org/kar/archidata/annotation/ARCHIVE.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package org.kar.archidata.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import jakarta.ws.rs.HttpMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates that the annotated method responds to HTTP ARCHIVE requests.
|
||||||
|
*
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @see HttpMethod
|
||||||
|
*/
|
||||||
|
@Target({ ElementType.METHOD })
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@HttpMethod("ARCHIVE")
|
||||||
|
public @interface ARCHIVE {}
|
||||||
19
src/org/kar/archidata/annotation/RESTORE.java
Normal file
19
src/org/kar/archidata/annotation/RESTORE.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package org.kar.archidata.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import jakarta.ws.rs.HttpMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates that the annotated method responds to HTTP RESTORE requests.
|
||||||
|
*
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @see HttpMethod
|
||||||
|
*/
|
||||||
|
@Target({ ElementType.METHOD })
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@HttpMethod("RESTORE")
|
||||||
|
public @interface RESTORE {}
|
||||||
@@ -304,9 +304,11 @@ public class DataResource {
|
|||||||
// logger.info("===================================================");
|
// logger.info("===================================================");
|
||||||
final Data value = getSmall(uuid);
|
final Data value = getSmall(uuid);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
LOGGER.warn("Request data that does not exist : {}", uuid);
|
||||||
return 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();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
LOGGER.warn("Generate stream : {}", uuid);
|
||||||
return buildStream(getFileData(uuid), range,
|
return buildStream(getFileData(uuid), range,
|
||||||
value.mimeType == null ? "application/octet-stream" : value.mimeType);
|
value.mimeType == null ? "application/octet-stream" : value.mimeType);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
@@ -478,8 +480,9 @@ public class DataResource {
|
|||||||
to = file.length() - 1;
|
to = file.length() - 1;
|
||||||
}
|
}
|
||||||
final String responseRange = String.format("bytes %d-%d/%d", from, to, file.length());
|
final String responseRange = String.format("bytes %d-%d/%d", from, to, file.length());
|
||||||
// logger.info("responseRange: {}", responseRange);
|
// LOGGER.info("responseRange: {}", responseRange);
|
||||||
try (final RandomAccessFile raf = new RandomAccessFile(file, "r")) {
|
try {
|
||||||
|
final RandomAccessFile raf = new RandomAccessFile(file, "r");
|
||||||
raf.seek(from);
|
raf.seek(from);
|
||||||
|
|
||||||
final long len = to - from + 1;
|
final long len = to - from + 1;
|
||||||
|
|||||||
@@ -58,5 +58,4 @@ public class MediaStreamer implements StreamingOutput {
|
|||||||
public long getLenth() {
|
public long getLenth() {
|
||||||
return this.length;
|
return this.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class WebApplicationExceptionCatcher implements ExceptionMapper<WebApplic
|
|||||||
}
|
}
|
||||||
|
|
||||||
private RestErrorResponse build(final WebApplicationException exception) {
|
private RestErrorResponse build(final WebApplicationException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
return new RestErrorResponse(exception.getResponse().getStatusInfo().toEnum(), "Catch system exception",
|
return new RestErrorResponse(exception.getResponse().getStatusInfo().toEnum(), "Catch system exception",
|
||||||
exception.getMessage());
|
exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,8 @@ public class AddOnManyToMany implements DataAccessAddOn {
|
|||||||
final String tmpVariable = "tmp_" + Integer.toString(count.value);
|
final String tmpVariable = "tmp_" + Integer.toString(count.value);
|
||||||
querySelect.append(" (SELECT GROUP_CONCAT(");
|
querySelect.append(" (SELECT GROUP_CONCAT(");
|
||||||
querySelect.append(tmpVariable);
|
querySelect.append(tmpVariable);
|
||||||
if (manyToMany.mappedBy() == null || manyToMany.mappedBy().length() == 0) {
|
final boolean mode = manyToMany.mappedBy() == null || manyToMany.mappedBy().length() == 0;
|
||||||
|
if (mode) {
|
||||||
querySelect.append(".object2Id ");
|
querySelect.append(".object2Id ");
|
||||||
} else {
|
} else {
|
||||||
querySelect.append(".object1Id ");
|
querySelect.append(".object1Id ");
|
||||||
@@ -128,6 +129,7 @@ public class AddOnManyToMany implements DataAccessAddOn {
|
|||||||
if ("sqlite".equals(ConfigBaseVariable.getDBType())) {
|
if ("sqlite".equals(ConfigBaseVariable.getDBType())) {
|
||||||
querySelect.append(", ");
|
querySelect.append(", ");
|
||||||
} else {
|
} else {
|
||||||
|
querySelect.append("ORDER BY uuid ASC ");
|
||||||
querySelect.append("SEPARATOR ");
|
querySelect.append("SEPARATOR ");
|
||||||
}
|
}
|
||||||
querySelect.append("'");
|
querySelect.append("'");
|
||||||
@@ -153,7 +155,7 @@ public class AddOnManyToMany implements DataAccessAddOn {
|
|||||||
querySelect.append(" = ");
|
querySelect.append(" = ");
|
||||||
querySelect.append(tmpVariable);
|
querySelect.append(tmpVariable);
|
||||||
querySelect.append(".");
|
querySelect.append(".");
|
||||||
if (manyToMany.mappedBy() == null || manyToMany.mappedBy().length() == 0) {
|
if (mode) {
|
||||||
querySelect.append("object1Id ");
|
querySelect.append("object1Id ");
|
||||||
} else {
|
} else {
|
||||||
querySelect.append("object2Id ");
|
querySelect.append("object2Id ");
|
||||||
@@ -161,7 +163,7 @@ public class AddOnManyToMany implements DataAccessAddOn {
|
|||||||
if (!"sqlite".equals(ConfigBaseVariable.getDBType())) {
|
if (!"sqlite".equals(ConfigBaseVariable.getDBType())) {
|
||||||
querySelect.append(" GROUP BY ");
|
querySelect.append(" GROUP BY ");
|
||||||
querySelect.append(tmpVariable);
|
querySelect.append(tmpVariable);
|
||||||
if (manyToMany.mappedBy() == null || manyToMany.mappedBy().length() == 0) {
|
if (mode) {
|
||||||
querySelect.append(".object1Id");
|
querySelect.append(".object1Id");
|
||||||
} else {
|
} else {
|
||||||
querySelect.append(".object2Id");
|
querySelect.append(".object2Id");
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ public interface CheckFunctionInterface {
|
|||||||
/** 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
|
||||||
* @param baseName NAme of the object to be precise with the use of what fail.
|
* @param baseName NAme of the object to be precise with the use of what fail.
|
||||||
* @param data The object that might be injected.
|
* @param data The object that might be injected.
|
||||||
* @param filterValue List of fields that might be check. If null, then all column must be checked.
|
* @param modifiedValue List of fields that might be check. If null, then all column must be checked.
|
||||||
* @throws Exception Exception is generate if the data are incorrect. */
|
* @throws Exception Exception is generate if the data are incorrect. */
|
||||||
void check(final String baseName, Object data, List<String> filterValue, final QueryOptions options)
|
void check(final String baseName, Object data, List<String> modifiedValue, final QueryOptions options)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
default void checkAll(final String baseName, final Object data, final QueryOptions options) throws Exception {
|
default void checkAll(final String baseName, final Object data, final QueryOptions options) throws Exception {
|
||||||
|
|||||||
@@ -35,10 +35,13 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
/** 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
|
||||||
|
* @param baseName Base of the name input that is displayed in exception generated.
|
||||||
* @param data The object that might be injected.
|
* @param data The object that might be injected.
|
||||||
* @param filterValue List of fields that might be check. If null, then all column must be checked.
|
* @param modifiedValue List of fields that modification is requested.
|
||||||
|
* @param options Some query option that the checker can need to generate basic check.
|
||||||
* @throws Exception Exception is generate if the data are incorrect. */
|
* @throws Exception Exception is generate if the data are incorrect. */
|
||||||
void check(final String baseName, final K data, final QueryOptions options) throws Exception;
|
void check(final String baseName, final K data, List<String> modifiedValue, final QueryOptions options)
|
||||||
|
throws Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, List<CheckInterface<T>>> checking = null;
|
protected Map<String, List<CheckInterface<T>>> checking = null;
|
||||||
@@ -67,20 +70,35 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
for (final Field field : this.clazz.getFields()) {
|
for (final Field field : this.clazz.getFields()) {
|
||||||
final String fieldName = field.getName(); // AnnotationTools.getFieldName(field);
|
final String fieldName = field.getName(); // AnnotationTools.getFieldName(field);
|
||||||
if (AnnotationTools.isPrimaryKey(field)) {
|
if (AnnotationTools.isPrimaryKey(field)) {
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
throw new InputException(baseName + fieldName,
|
throw new InputException(baseName + fieldName,
|
||||||
"This is a '@Id' (primaryKey) ==> can not be change");
|
"This is a '@Id' (primaryKey) ==> can not be change");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (AnnotationTools.getConstraintsNotNull(field)) {
|
if (AnnotationTools.getConstraintsNotNull(field)) {
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
if (field.get(data) == null) {
|
if (field.get(data) == null) {
|
||||||
throw new InputException(baseName + fieldName, "Can not be null");
|
throw new InputException(baseName + fieldName, "Can not be null");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (AnnotationTools.isCreatedAtField(field) || AnnotationTools.isUpdateAtField(field)) {
|
if (AnnotationTools.isCreatedAtField(field) || AnnotationTools.isUpdateAtField(field)) {
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
throw new InputException(baseName + fieldName, "It is forbidden to change this field");
|
throw new InputException(baseName + fieldName, "It is forbidden to change this field");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -89,33 +107,50 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
if (type == Long.class || type == long.class) {
|
if (type == Long.class || type == long.class) {
|
||||||
final Long maxValue = AnnotationTools.getConstraintsMax(field);
|
final Long maxValue = AnnotationTools.getConstraintsMax(field);
|
||||||
if (maxValue != null) {
|
if (maxValue != null) {
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Long elemTyped = (Long) elem;
|
final Long elemTyped = (Long) elem;
|
||||||
if (elemTyped > maxValue) {
|
if (elemTyped > maxValue) {
|
||||||
throw new InputException(baseName + fieldName, "Value too height max: " + maxValue);
|
throw new InputException(baseName + fieldName,
|
||||||
|
"Value too height max: " + maxValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
final Long minValue = AnnotationTools.getConstraintsMin(field);
|
final Long minValue = AnnotationTools.getConstraintsMin(field);
|
||||||
if (minValue != null) {
|
if (minValue != null) {
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Long elemTyped = (Long) elem;
|
final Long elemTyped = (Long) elem;
|
||||||
if (elemTyped < minValue) {
|
if (elemTyped < minValue) {
|
||||||
throw new InputException(baseName + fieldName, "Value too Low min: " + minValue);
|
throw new InputException(baseName + fieldName,
|
||||||
|
"Value too Low min: " + minValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
final ManyToOne annotationManyToOne = AnnotationTools.getManyToOne(field);
|
final ManyToOne annotationManyToOne = AnnotationTools.getManyToOne(field);
|
||||||
if (annotationManyToOne != null && annotationManyToOne.targetEntity() != null) {
|
if (annotationManyToOne != null && annotationManyToOne.targetEntity() != null) {
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
@@ -136,34 +171,51 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
final Long maxValueRoot = AnnotationTools.getConstraintsMax(field);
|
final Long maxValueRoot = AnnotationTools.getConstraintsMax(field);
|
||||||
if (maxValueRoot != null) {
|
if (maxValueRoot != null) {
|
||||||
final int maxValue = maxValueRoot.intValue();
|
final int maxValue = maxValueRoot.intValue();
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Integer elemTyped = (Integer) elem;
|
final Integer elemTyped = (Integer) elem;
|
||||||
if (elemTyped > maxValue) {
|
if (elemTyped > maxValue) {
|
||||||
throw new InputException(baseName + fieldName, "Value too height max: " + maxValue);
|
throw new InputException(baseName + fieldName,
|
||||||
|
"Value too height max: " + maxValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
final Long minValueRoot = AnnotationTools.getConstraintsMin(field);
|
final Long minValueRoot = AnnotationTools.getConstraintsMin(field);
|
||||||
if (minValueRoot != null) {
|
if (minValueRoot != null) {
|
||||||
final int minValue = minValueRoot.intValue();
|
final int minValue = minValueRoot.intValue();
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Integer elemTyped = (Integer) elem;
|
final Integer elemTyped = (Integer) elem;
|
||||||
if (elemTyped < minValue) {
|
if (elemTyped < minValue) {
|
||||||
throw new InputException(baseName + fieldName, "Value too Low min: " + minValue);
|
throw new InputException(baseName + fieldName,
|
||||||
|
"Value too Low min: " + minValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
final ManyToOne annotationManyToOne = AnnotationTools.getManyToOne(field);
|
final ManyToOne annotationManyToOne = AnnotationTools.getManyToOne(field);
|
||||||
if (annotationManyToOne != null && annotationManyToOne.targetEntity() != null) {
|
if (annotationManyToOne != null && annotationManyToOne.targetEntity() != null) {
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
@@ -178,7 +230,12 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
} else if (type == UUID.class) {
|
} else if (type == UUID.class) {
|
||||||
final ManyToOne annotationManyToOne = AnnotationTools.getManyToOne(field);
|
final ManyToOne annotationManyToOne = AnnotationTools.getManyToOne(field);
|
||||||
if (annotationManyToOne != null && annotationManyToOne.targetEntity() != null) {
|
if (annotationManyToOne != null && annotationManyToOne.targetEntity() != null) {
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
@@ -196,28 +253,40 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
final Long maxValueRoot = AnnotationTools.getConstraintsMax(field);
|
final Long maxValueRoot = AnnotationTools.getConstraintsMax(field);
|
||||||
if (maxValueRoot != null) {
|
if (maxValueRoot != null) {
|
||||||
final float maxValue = maxValueRoot.floatValue();
|
final float maxValue = maxValueRoot.floatValue();
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Float elemTyped = (Float) elem;
|
final Float elemTyped = (Float) elem;
|
||||||
if (elemTyped > maxValue) {
|
if (elemTyped > maxValue) {
|
||||||
throw new InputException(baseName + fieldName, "Value too height max: " + maxValue);
|
throw new InputException(baseName + fieldName,
|
||||||
|
"Value too height max: " + maxValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
final Long minValueRoot = AnnotationTools.getConstraintsMin(field);
|
final Long minValueRoot = AnnotationTools.getConstraintsMin(field);
|
||||||
if (minValueRoot != null) {
|
if (minValueRoot != null) {
|
||||||
final float minValue = minValueRoot.floatValue();
|
final float minValue = minValueRoot.floatValue();
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Float elemTyped = (Float) elem;
|
final Float elemTyped = (Float) elem;
|
||||||
if (elemTyped < minValue) {
|
if (elemTyped < minValue) {
|
||||||
throw new InputException(baseName + fieldName, "Value too Low min: " + minValue);
|
throw new InputException(baseName + fieldName,
|
||||||
|
"Value too Low min: " + minValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -225,28 +294,40 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
final Long maxValueRoot = AnnotationTools.getConstraintsMax(field);
|
final Long maxValueRoot = AnnotationTools.getConstraintsMax(field);
|
||||||
if (maxValueRoot != null) {
|
if (maxValueRoot != null) {
|
||||||
final double maxValue = maxValueRoot.doubleValue();
|
final double maxValue = maxValueRoot.doubleValue();
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Double elemTyped = (Double) elem;
|
final Double elemTyped = (Double) elem;
|
||||||
if (elemTyped > maxValue) {
|
if (elemTyped > maxValue) {
|
||||||
throw new InputException(baseName + fieldName, "Value too height max: " + maxValue);
|
throw new InputException(baseName + fieldName,
|
||||||
|
"Value too height max: " + maxValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
final Long minValueRoot = AnnotationTools.getConstraintsMin(field);
|
final Long minValueRoot = AnnotationTools.getConstraintsMin(field);
|
||||||
if (minValueRoot != null) {
|
if (minValueRoot != null) {
|
||||||
final double minValue = minValueRoot.doubleValue();
|
final double minValue = minValueRoot.doubleValue();
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Double elemTyped = (Double) elem;
|
final Double elemTyped = (Double) elem;
|
||||||
if (elemTyped < minValue) {
|
if (elemTyped < minValue) {
|
||||||
throw new InputException(baseName + fieldName, "Value too Low min: " + minValue);
|
throw new InputException(baseName + fieldName,
|
||||||
|
"Value too Low min: " + minValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -259,7 +340,12 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
} else if (type == String.class) {
|
} else if (type == String.class) {
|
||||||
final int maxSizeString = AnnotationTools.getLimitSize(field);
|
final int maxSizeString = AnnotationTools.getLimitSize(field);
|
||||||
if (maxSizeString > 0) {
|
if (maxSizeString > 0) {
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
@@ -273,7 +359,12 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
}
|
}
|
||||||
final Size limitSize = AnnotationTools.getConstraintsSize(field);
|
final Size limitSize = AnnotationTools.getConstraintsSize(field);
|
||||||
if (limitSize != null) {
|
if (limitSize != null) {
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
@@ -292,7 +383,12 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
final String patternString = AnnotationTools.getConstraintsPattern(field);
|
final String patternString = AnnotationTools.getConstraintsPattern(field);
|
||||||
if (patternString != null) {
|
if (patternString != null) {
|
||||||
final Pattern pattern = Pattern.compile(patternString);
|
final Pattern pattern = Pattern.compile(patternString);
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final Object elem = field.get(data);
|
final Object elem = field.get(data);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return;
|
return;
|
||||||
@@ -300,8 +396,8 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
final String elemTyped = (String) elem;
|
final String elemTyped = (String) elem;
|
||||||
if (!pattern.matcher(elemTyped).find()) {
|
if (!pattern.matcher(elemTyped).find()) {
|
||||||
throw new InputException(baseName + fieldName,
|
throw new InputException(baseName + fieldName,
|
||||||
"does not match the required pattern (constraints) must be '" + patternString
|
"does not match the required pattern (constraints) must be '"
|
||||||
+ "'");
|
+ patternString + "'");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -311,7 +407,12 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
// Here if we have an error it crash at start and no new instance after creation...
|
// Here if we have an error it crash at start and no new instance after creation...
|
||||||
final CheckFunctionInterface instance = jsonAnnotation.checker().getDeclaredConstructor()
|
final CheckFunctionInterface instance = jsonAnnotation.checker().getDeclaredConstructor()
|
||||||
.newInstance();
|
.newInstance();
|
||||||
add(fieldName, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
instance.checkAll(baseName + fieldName + ".", field.get(data), options);
|
instance.checkAll(baseName + fieldName + ".", field.get(data), options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -321,7 +422,12 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
// 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, (final String baseName, final T data, final QueryOptions options) -> {
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
final List<ConditionChecker> condCheckers = options.get(ConditionChecker.class);
|
final List<ConditionChecker> condCheckers = options.get(ConditionChecker.class);
|
||||||
Object other = null;
|
Object other = null;
|
||||||
if (condCheckers.isEmpty()) {
|
if (condCheckers.isEmpty()) {
|
||||||
@@ -349,7 +455,7 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
public void check(
|
public void check(
|
||||||
final String baseName,
|
final String baseName,
|
||||||
final Object data,
|
final Object data,
|
||||||
final List<String> filterValue,
|
final List<String> modifiedValue,
|
||||||
final QueryOptions options) throws Exception {
|
final QueryOptions options) throws Exception {
|
||||||
if (this.checking == null) {
|
if (this.checking == null) {
|
||||||
initialize();
|
initialize();
|
||||||
@@ -359,19 +465,20 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
}
|
}
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final T dataCasted = (T) data;
|
final T dataCasted = (T) data;
|
||||||
for (final String filter : filterValue) {
|
for (final String filter : modifiedValue) {
|
||||||
final 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 (final CheckInterface<T> action : actions) {
|
for (final CheckInterface<T> action : actions) {
|
||||||
action.check(baseName, dataCasted, options);
|
action.check(baseName, dataCasted, modifiedValue, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkTyped(dataCasted, filterValue, options);
|
checkTyped(dataCasted, modifiedValue, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkTyped(final T data, final List<String> filterValue, final QueryOptions options) throws Exception {
|
public void checkTyped(final T data, final List<String> modifiedValue, final QueryOptions options)
|
||||||
|
throws Exception {
|
||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import java.util.Set;
|
|||||||
import org.kar.archidata.externalRestApi.dot.DotClassElement.DefinedPosition;
|
import org.kar.archidata.externalRestApi.dot.DotClassElement.DefinedPosition;
|
||||||
import org.kar.archidata.externalRestApi.model.ApiGroupModel;
|
import org.kar.archidata.externalRestApi.model.ApiGroupModel;
|
||||||
import org.kar.archidata.externalRestApi.model.ApiModel;
|
import org.kar.archidata.externalRestApi.model.ApiModel;
|
||||||
|
import org.kar.archidata.externalRestApi.model.ApiModel.OptionalClassModel;
|
||||||
import org.kar.archidata.externalRestApi.model.ClassEnumModel;
|
import org.kar.archidata.externalRestApi.model.ClassEnumModel;
|
||||||
import org.kar.archidata.externalRestApi.model.ClassListModel;
|
import org.kar.archidata.externalRestApi.model.ClassListModel;
|
||||||
import org.kar.archidata.externalRestApi.model.ClassMapModel;
|
import org.kar.archidata.externalRestApi.model.ClassMapModel;
|
||||||
@@ -216,7 +217,7 @@ public class DotApiGeneration {
|
|||||||
hasParam = true;
|
hasParam = true;
|
||||||
boolean hasParam2 = false;
|
boolean hasParam2 = false;
|
||||||
data.append("data: {");
|
data.append("data: {");
|
||||||
for (final Entry<String, List<ClassModel>> pathEntry : interfaceElement.multiPartParameters
|
for (final Entry<String, OptionalClassModel> pathEntry : interfaceElement.multiPartParameters
|
||||||
.entrySet()) {
|
.entrySet()) {
|
||||||
if (hasParam2) {
|
if (hasParam2) {
|
||||||
data.append(", ");
|
data.append(", ");
|
||||||
@@ -224,7 +225,7 @@ public class DotApiGeneration {
|
|||||||
hasParam2 = true;
|
hasParam2 = true;
|
||||||
data.append(pathEntry.getKey());
|
data.append(pathEntry.getKey());
|
||||||
data.append(": ");
|
data.append(": ");
|
||||||
data.append(generateClassModelsTypescript(pathEntry.getValue(), dotGroup));
|
data.append(generateClassModelsTypescript(pathEntry.getValue().model(), dotGroup));
|
||||||
}
|
}
|
||||||
data.append("}");
|
data.append("}");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
|
import org.kar.archidata.annotation.ARCHIVE;
|
||||||
import org.kar.archidata.annotation.AsyncType;
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.annotation.FormDataOptional;
|
import org.kar.archidata.annotation.FormDataOptional;
|
||||||
|
import org.kar.archidata.annotation.RESTORE;
|
||||||
import org.kar.archidata.annotation.TypeScriptProgress;
|
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@@ -107,6 +109,12 @@ public class ApiTool {
|
|||||||
if (element.getDeclaredAnnotationsByType(DELETE.class).length == 1) {
|
if (element.getDeclaredAnnotationsByType(DELETE.class).length == 1) {
|
||||||
return "DELETE";
|
return "DELETE";
|
||||||
}
|
}
|
||||||
|
if (element.getDeclaredAnnotationsByType(RESTORE.class).length == 1) {
|
||||||
|
return "RESTORE";
|
||||||
|
}
|
||||||
|
if (element.getDeclaredAnnotationsByType(ARCHIVE.class).length == 1) {
|
||||||
|
return "ARCHIVE";
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,6 +134,12 @@ public class ApiTool {
|
|||||||
if (element.getDeclaredAnnotationsByType(DELETE.class).length == 1) {
|
if (element.getDeclaredAnnotationsByType(DELETE.class).length == 1) {
|
||||||
return RestTypeRequest.DELETE;
|
return RestTypeRequest.DELETE;
|
||||||
}
|
}
|
||||||
|
if (element.getDeclaredAnnotationsByType(RESTORE.class).length == 1) {
|
||||||
|
return RestTypeRequest.RESTORE;
|
||||||
|
}
|
||||||
|
if (element.getDeclaredAnnotationsByType(ARCHIVE.class).length == 1) {
|
||||||
|
return RestTypeRequest.ARCHIVE;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package org.kar.archidata.externalRestApi.model;
|
package org.kar.archidata.externalRestApi.model;
|
||||||
|
|
||||||
public enum RestTypeRequest {
|
public enum RestTypeRequest {
|
||||||
GET, POST, PUT, PATCH, DELETE
|
GET, POST, PUT, PATCH, DELETE, RESTORE, ARCHIVE
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,12 @@ public class CORSFilter implements ContainerResponseFilter {
|
|||||||
// System.err.println("filter cors ..." + request.toString());
|
// System.err.println("filter cors ..." + request.toString());
|
||||||
|
|
||||||
response.getHeaders().add("Access-Control-Allow-Origin", "*");
|
response.getHeaders().add("Access-Control-Allow-Origin", "*");
|
||||||
|
response.getHeaders().add("Access-Control-Allow-Range", "bytes");
|
||||||
|
response.getHeaders().add("access-control-expose-headers", "range");
|
||||||
response.getHeaders().add("Access-Control-Allow-Headers",
|
response.getHeaders().add("Access-Control-Allow-Headers",
|
||||||
"Origin, content-type, Content-type, Accept, Authorization, mime-type, filename");
|
"Origin, content-type, Content-type, Accept, Authorization, mime-type, filename, Range");
|
||||||
response.getHeaders().add("Access-Control-Allow-Credentials", "true");
|
response.getHeaders().add("Access-Control-Allow-Credentials", "true");
|
||||||
response.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD");
|
response.getHeaders().add("Access-Control-Allow-Methods",
|
||||||
|
"GET, POST, PUT, PATCH, DELETE, ARCHIVE, RESTORE, OPTIONS, HEAD");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,6 +259,9 @@ public class DataTools {
|
|||||||
if (data.contentEquals("null")) {
|
if (data.contentEquals("null")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (data.contentEquals("undefined")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -222,13 +222,66 @@ public class RESTApi {
|
|||||||
*/
|
*/
|
||||||
public <T> T delete(final Class<T> clazz, final String urlOffset)
|
public <T> T delete(final Class<T> clazz, final String urlOffset)
|
||||||
throws RESTErrorResponseExeption, IOException, InterruptedException {
|
throws RESTErrorResponseExeption, IOException, InterruptedException {
|
||||||
|
return simpleRequest("DELETE", clazz, urlOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call an ARCHIVE on a REST API
|
||||||
|
* @param urlOffset Offset to call the API
|
||||||
|
*/
|
||||||
|
public void archive(final String urlOffset) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
||||||
|
archive(Void.class, urlOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call a ARCHIVE on a REST API with retrieving some data
|
||||||
|
* @param <T> Type of data that might be received.
|
||||||
|
* @param clazz Class model of the data that might be parsed.
|
||||||
|
* @param urlOffset Offset to call the API
|
||||||
|
* @return The parsed object received.
|
||||||
|
*/
|
||||||
|
public <T> T archive(final Class<T> clazz, final String urlOffset)
|
||||||
|
throws RESTErrorResponseExeption, IOException, InterruptedException {
|
||||||
|
return simpleRequest("ARCHIVE", clazz, urlOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call an RESTORE on a REST API
|
||||||
|
* @param urlOffset Offset to call the API
|
||||||
|
*/
|
||||||
|
public void restore(final String urlOffset) throws RESTErrorResponseExeption, IOException, InterruptedException {
|
||||||
|
restore(Void.class, urlOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call a RESTORE on a REST API with retrieving some data
|
||||||
|
* @param <T> Type of data that might be received.
|
||||||
|
* @param clazz Class model of the data that might be parsed.
|
||||||
|
* @param urlOffset Offset to call the API
|
||||||
|
* @return The parsed object received.
|
||||||
|
*/
|
||||||
|
public <T> T restore(final Class<T> clazz, final String urlOffset)
|
||||||
|
throws RESTErrorResponseExeption, IOException, InterruptedException {
|
||||||
|
return simpleRequest("RESTORE", clazz, urlOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call a key on a REST API with retrieving some data
|
||||||
|
* @param <T> Type of data that might be received.
|
||||||
|
* @param model name of the key for the REST call
|
||||||
|
* @param clazz Class model of the data that might be parsed.
|
||||||
|
* @param urlOffset Offset to call the API
|
||||||
|
* @return The parsed object received.
|
||||||
|
*/
|
||||||
|
public <T> T simpleRequest(final String model, 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)
|
Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1)
|
||||||
.uri(URI.create(this.baseUrl + urlOffset));
|
.uri(URI.create(this.baseUrl + urlOffset));
|
||||||
if (this.token != null) {
|
if (this.token != null) {
|
||||||
requestBuilding = requestBuilding.header(HttpHeaders.AUTHORIZATION, "Bearer " + this.token);
|
requestBuilding = requestBuilding.header(HttpHeaders.AUTHORIZATION, "Bearer " + this.token);
|
||||||
}
|
}
|
||||||
final HttpRequest request = requestBuilding.DELETE().build();
|
final HttpRequest request = requestBuilding.method(model, BodyPublishers.ofString("")).build();
|
||||||
final HttpResponse<String> httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());
|
final HttpResponse<String> httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||||
if (httpResponse.statusCode() < 200 || httpResponse.statusCode() >= 300) {
|
if (httpResponse.statusCode() < 200 || httpResponse.statusCode() >= 300) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -7,11 +7,15 @@
|
|||||||
import { RestErrorResponse, isRestErrorResponse } from "./model";
|
import { RestErrorResponse, isRestErrorResponse } from "./model";
|
||||||
|
|
||||||
export enum HTTPRequestModel {
|
export enum HTTPRequestModel {
|
||||||
|
ARCHIVE = "ARCHIVE",
|
||||||
DELETE = "DELETE",
|
DELETE = "DELETE",
|
||||||
|
HEAD = "HEAD",
|
||||||
GET = "GET",
|
GET = "GET",
|
||||||
|
OPTION = "OPTION",
|
||||||
PATCH = "PATCH",
|
PATCH = "PATCH",
|
||||||
POST = "POST",
|
POST = "POST",
|
||||||
PUT = "PUT",
|
PUT = "PUT",
|
||||||
|
RESTORE = "RESTORE",
|
||||||
}
|
}
|
||||||
export enum HTTPMimeType {
|
export enum HTTPMimeType {
|
||||||
ALL = "*/*",
|
ALL = "*/*",
|
||||||
@@ -248,9 +252,14 @@ export function RESTRequest({
|
|||||||
if (restModel.accept !== undefined) {
|
if (restModel.accept !== undefined) {
|
||||||
headers["Accept"] = restModel.accept;
|
headers["Accept"] = restModel.accept;
|
||||||
}
|
}
|
||||||
if (restModel.requestType !== HTTPRequestModel.GET) {
|
if (restModel.requestType !== HTTPRequestModel.GET &&
|
||||||
|
restModel.requestType !== HTTPRequestModel.ARCHIVE &&
|
||||||
|
restModel.requestType !== HTTPRequestModel.RESTORE
|
||||||
|
) {
|
||||||
// if Get we have not a content type, the body is empty
|
// if Get we have not a content type, the body is empty
|
||||||
if (restModel.contentType !== HTTPMimeType.MULTIPART) {
|
if (restModel.contentType !== HTTPMimeType.MULTIPART &&
|
||||||
|
restModel.contentType !== undefined
|
||||||
|
) {
|
||||||
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
||||||
headers["Content-Type"] = restModel.contentType;
|
headers["Content-Type"] = restModel.contentType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
0.14.0
|
0.17.0
|
||||||
|
|||||||
Reference in New Issue
Block a user