Compare commits
4 Commits
d77a5518ff
...
15688f93e5
Author | SHA1 | Date | |
---|---|---|---|
15688f93e5 | |||
906216f237 | |||
b479414bc2 | |||
2bc68321e3 |
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.12.1</version>
|
<version>0.12.3-SNAPSHOT</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>
|
||||||
|
@ -192,7 +192,7 @@ public class TsApiGeneration {
|
|||||||
data.append("\n\t\t\tdata,");
|
data.append("\n\t\t\tdata,");
|
||||||
}
|
}
|
||||||
if (needGenerateProgress) {
|
if (needGenerateProgress) {
|
||||||
data.append("\n\t\t\tcallback,");
|
data.append("\n\t\t\tcallbacks,");
|
||||||
}
|
}
|
||||||
data.append("\n\t\t}: {");
|
data.append("\n\t\t}: {");
|
||||||
data.append("\n\t\trestConfig: RESTConfig,");
|
data.append("\n\t\trestConfig: RESTConfig,");
|
||||||
@ -350,7 +350,7 @@ public class TsApiGeneration {
|
|||||||
data.append("\n\t\t\tdata,");
|
data.append("\n\t\t\tdata,");
|
||||||
}
|
}
|
||||||
if (needGenerateProgress) {
|
if (needGenerateProgress) {
|
||||||
data.append("\n\t\t\tcallback,");
|
data.append("\n\t\t\tcallbacks,");
|
||||||
}
|
}
|
||||||
data.append("\n\t\t}");
|
data.append("\n\t\t}");
|
||||||
if (returnComplexModel != null) {
|
if (returnComplexModel != null) {
|
||||||
|
@ -22,6 +22,8 @@ import org.kar.archidata.dataAccess.QueryCondition;
|
|||||||
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
import org.kar.archidata.dataAccess.options.Condition;
|
||||||
import org.kar.archidata.dataAccess.options.ReadAllColumn;
|
import org.kar.archidata.dataAccess.options.ReadAllColumn;
|
||||||
|
import org.kar.archidata.exception.FailException;
|
||||||
|
import org.kar.archidata.exception.InputException;
|
||||||
import org.kar.archidata.model.Data;
|
import org.kar.archidata.model.Data;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -214,73 +216,54 @@ public class DataTools {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <CLASS_TYPE, ID_TYPE> Response uploadCover(
|
public static <CLASS_TYPE, ID_TYPE> void uploadCover(
|
||||||
final Class<CLASS_TYPE> clazz,
|
final Class<CLASS_TYPE> clazz,
|
||||||
final ID_TYPE id,
|
final ID_TYPE id,
|
||||||
final InputStream fileInputStream,
|
final InputStream fileInputStream,
|
||||||
final FormDataContentDisposition fileMetaData) {
|
final FormDataContentDisposition fileMetaData) throws Exception {
|
||||||
return uploadCover(clazz, id, fileMetaData.getFileName(), fileInputStream, fileMetaData);
|
// public NodeSmall uploadFile(final FormDataMultiPart form) {
|
||||||
}
|
LOGGER.info("Upload media file: {}", fileMetaData);
|
||||||
|
LOGGER.info(" - id: {}", id);
|
||||||
@Deprecated
|
LOGGER.info(" - file_name: ", fileMetaData.getFileName());
|
||||||
public static <CLASS_TYPE, ID_TYPE> Response uploadCover(
|
LOGGER.info(" - fileInputStream: {}", fileInputStream);
|
||||||
final Class<CLASS_TYPE> clazz,
|
LOGGER.info(" - fileMetaData: {}", fileMetaData);
|
||||||
final ID_TYPE id,
|
final CLASS_TYPE media = DataAccess.get(clazz, id);
|
||||||
String fileName,
|
if (media == null) {
|
||||||
final InputStream fileInputStream,
|
throw new InputException(clazz.getCanonicalName(),
|
||||||
final FormDataContentDisposition fileMetaData) {
|
"[" + id.toString() + "] Id does not exist or removed...");
|
||||||
try {
|
}
|
||||||
// correct input string stream :
|
|
||||||
fileName = multipartCorrection(fileName);
|
final long tmpUID = getTmpDataId();
|
||||||
|
final String sha512 = saveTemporaryFile(fileInputStream, tmpUID);
|
||||||
// public NodeSmall uploadFile(final FormDataMultiPart form) {
|
Data data = getWithSha512(sha512);
|
||||||
LOGGER.info("Upload media file: {}", fileMetaData);
|
if (data == null) {
|
||||||
LOGGER.info(" - id: {}", id);
|
LOGGER.info("Need to add the data in the BDD ... ");
|
||||||
LOGGER.info(" - file_name: ", fileName);
|
try {
|
||||||
LOGGER.info(" - fileInputStream: {}", fileInputStream);
|
data = createNewData(tmpUID, fileMetaData.getFileName(), sha512);
|
||||||
LOGGER.info(" - fileMetaData: {}", fileMetaData);
|
} catch (final IOException ex) {
|
||||||
final CLASS_TYPE media = DataAccess.get(clazz, id);
|
removeTemporaryFile(tmpUID);
|
||||||
if (media == null) {
|
throw new FailException(Response.Status.NOT_MODIFIED,
|
||||||
return Response.notModified("Media Id does not exist or removed...").build();
|
clazz.getCanonicalName() + "[" + id.toString() + "] can not create input media", ex);
|
||||||
}
|
} catch (final SQLException ex) {
|
||||||
|
removeTemporaryFile(tmpUID);
|
||||||
final long tmpUID = getTmpDataId();
|
throw new FailException(Response.Status.NOT_MODIFIED,
|
||||||
final String sha512 = saveTemporaryFile(fileInputStream, tmpUID);
|
clazz.getCanonicalName() + "[" + id.toString() + "] Error in SQL insertion", ex);
|
||||||
Data data = getWithSha512(sha512);
|
}
|
||||||
if (data == null) {
|
} else if (data.deleted) {
|
||||||
LOGGER.info("Need to add the data in the BDD ... ");
|
LOGGER.error("Data already exist but deleted");
|
||||||
try {
|
undelete(data.uuid);
|
||||||
data = createNewData(tmpUID, fileName, sha512);
|
data.deleted = false;
|
||||||
} catch (final IOException ex) {
|
} else {
|
||||||
removeTemporaryFile(tmpUID);
|
LOGGER.error("Data already exist ... all good");
|
||||||
ex.printStackTrace();
|
}
|
||||||
return Response.notModified("can not create input media").build();
|
// Fist step: retrieve all the Id of each parents:...
|
||||||
} catch (final SQLException ex) {
|
LOGGER.info("Find typeNode");
|
||||||
ex.printStackTrace();
|
if (id instanceof final Long idLong) {
|
||||||
removeTemporaryFile(tmpUID);
|
AddOnDataJson.addLink(clazz, idLong, "covers", data.uuid);
|
||||||
return Response.notModified("Error in SQL insertion ...").build();
|
} else if (id instanceof final UUID idUUID) {
|
||||||
}
|
AddOnDataJson.addLink(clazz, idUUID, "covers", data.uuid);
|
||||||
} else if (data.deleted) {
|
} else {
|
||||||
LOGGER.error("Data already exist but deleted");
|
throw new IOException("Fail to add Cover can not detect type...");
|
||||||
undelete(data.uuid);
|
|
||||||
data.deleted = false;
|
|
||||||
} else {
|
|
||||||
LOGGER.error("Data already exist ... all good");
|
|
||||||
}
|
|
||||||
// Fist step: retrieve all the Id of each parents:...
|
|
||||||
LOGGER.info("Find typeNode");
|
|
||||||
if (id instanceof final Long idLong) {
|
|
||||||
AddOnDataJson.addLink(clazz, idLong, "covers", data.uuid);
|
|
||||||
} else if (id instanceof final UUID idUUID) {
|
|
||||||
AddOnDataJson.addLink(clazz, idUUID, "covers", data.uuid);
|
|
||||||
} else {
|
|
||||||
throw new IOException("Fail to add Cover can not detect type...");
|
|
||||||
}
|
|
||||||
return Response.ok(DataAccess.get(clazz, id)).build();
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
System.out.println("Cat ann unexpected error ... ");
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return Response.serverError().build();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ export function RESTRequest({
|
|||||||
data,
|
data,
|
||||||
params,
|
params,
|
||||||
queries,
|
queries,
|
||||||
callback,
|
callbacks,
|
||||||
}: RESTRequestType): Promise<ModelResponseHttp> {
|
}: RESTRequestType): Promise<ModelResponseHttp> {
|
||||||
// Create the URL PATH:
|
// Create the URL PATH:
|
||||||
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
||||||
@ -268,10 +268,10 @@ export function RESTRequest({
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let action: undefined | Promise<Response> = undefined;
|
let action: undefined | Promise<Response> = undefined;
|
||||||
if (
|
if (
|
||||||
isNullOrUndefined(callback) ||
|
isNullOrUndefined(callbacks) ||
|
||||||
(isNullOrUndefined(callback.progressDownload) &&
|
(isNullOrUndefined(callbacks.progressDownload) &&
|
||||||
isNullOrUndefined(callback.progressUpload) &&
|
isNullOrUndefined(callbacks.progressUpload) &&
|
||||||
isNullOrUndefined(callback.abortHandle))
|
isNullOrUndefined(callbacks.abortHandle))
|
||||||
) {
|
) {
|
||||||
// No information needed: call the generic fetch interface
|
// No information needed: call the generic fetch interface
|
||||||
action = fetch(generateUrl, {
|
action = fetch(generateUrl, {
|
||||||
@ -288,7 +288,7 @@ export function RESTRequest({
|
|||||||
headers,
|
headers,
|
||||||
body,
|
body,
|
||||||
},
|
},
|
||||||
callback
|
callbacks
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
action
|
action
|
||||||
|
@ -1 +1 @@
|
|||||||
0.12.1
|
0.12.3-dev
|
||||||
|
Loading…
x
Reference in New Issue
Block a user