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>
|
||||
<groupId>kangaroo-and-rabbit</groupId>
|
||||
<artifactId>archidata</artifactId>
|
||||
<version>0.12.1</version>
|
||||
<version>0.12.3-SNAPSHOT</version>
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
<maven.compiler.version>3.1</maven.compiler.version>
|
||||
|
@ -192,7 +192,7 @@ public class TsApiGeneration {
|
||||
data.append("\n\t\t\tdata,");
|
||||
}
|
||||
if (needGenerateProgress) {
|
||||
data.append("\n\t\t\tcallback,");
|
||||
data.append("\n\t\t\tcallbacks,");
|
||||
}
|
||||
data.append("\n\t\t}: {");
|
||||
data.append("\n\t\trestConfig: RESTConfig,");
|
||||
@ -350,7 +350,7 @@ public class TsApiGeneration {
|
||||
data.append("\n\t\t\tdata,");
|
||||
}
|
||||
if (needGenerateProgress) {
|
||||
data.append("\n\t\t\tcallback,");
|
||||
data.append("\n\t\t\tcallbacks,");
|
||||
}
|
||||
data.append("\n\t\t}");
|
||||
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.options.Condition;
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -214,73 +216,54 @@ public class DataTools {
|
||||
return data;
|
||||
}
|
||||
|
||||
public static <CLASS_TYPE, ID_TYPE> Response uploadCover(
|
||||
public static <CLASS_TYPE, ID_TYPE> void uploadCover(
|
||||
final Class<CLASS_TYPE> clazz,
|
||||
final ID_TYPE id,
|
||||
final InputStream fileInputStream,
|
||||
final FormDataContentDisposition fileMetaData) {
|
||||
return uploadCover(clazz, id, fileMetaData.getFileName(), fileInputStream, fileMetaData);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static <CLASS_TYPE, ID_TYPE> Response uploadCover(
|
||||
final Class<CLASS_TYPE> clazz,
|
||||
final ID_TYPE id,
|
||||
String fileName,
|
||||
final InputStream fileInputStream,
|
||||
final FormDataContentDisposition fileMetaData) {
|
||||
try {
|
||||
// correct input string stream :
|
||||
fileName = multipartCorrection(fileName);
|
||||
|
||||
// public NodeSmall uploadFile(final FormDataMultiPart form) {
|
||||
LOGGER.info("Upload media file: {}", fileMetaData);
|
||||
LOGGER.info(" - id: {}", id);
|
||||
LOGGER.info(" - file_name: ", fileName);
|
||||
LOGGER.info(" - fileInputStream: {}", fileInputStream);
|
||||
LOGGER.info(" - fileMetaData: {}", fileMetaData);
|
||||
final CLASS_TYPE media = DataAccess.get(clazz, id);
|
||||
if (media == null) {
|
||||
return Response.notModified("Media Id does not exist or removed...").build();
|
||||
}
|
||||
|
||||
final long tmpUID = getTmpDataId();
|
||||
final String sha512 = saveTemporaryFile(fileInputStream, tmpUID);
|
||||
Data data = getWithSha512(sha512);
|
||||
if (data == null) {
|
||||
LOGGER.info("Need to add the data in the BDD ... ");
|
||||
try {
|
||||
data = createNewData(tmpUID, fileName, sha512);
|
||||
} catch (final IOException ex) {
|
||||
removeTemporaryFile(tmpUID);
|
||||
ex.printStackTrace();
|
||||
return Response.notModified("can not create input media").build();
|
||||
} catch (final SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
removeTemporaryFile(tmpUID);
|
||||
return Response.notModified("Error in SQL insertion ...").build();
|
||||
}
|
||||
} else if (data.deleted) {
|
||||
LOGGER.error("Data already exist but deleted");
|
||||
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();
|
||||
final FormDataContentDisposition fileMetaData) throws Exception {
|
||||
// public NodeSmall uploadFile(final FormDataMultiPart form) {
|
||||
LOGGER.info("Upload media file: {}", fileMetaData);
|
||||
LOGGER.info(" - id: {}", id);
|
||||
LOGGER.info(" - file_name: ", fileMetaData.getFileName());
|
||||
LOGGER.info(" - fileInputStream: {}", fileInputStream);
|
||||
LOGGER.info(" - fileMetaData: {}", fileMetaData);
|
||||
final CLASS_TYPE media = DataAccess.get(clazz, id);
|
||||
if (media == null) {
|
||||
throw new InputException(clazz.getCanonicalName(),
|
||||
"[" + id.toString() + "] Id does not exist or removed...");
|
||||
}
|
||||
|
||||
final long tmpUID = getTmpDataId();
|
||||
final String sha512 = saveTemporaryFile(fileInputStream, tmpUID);
|
||||
Data data = getWithSha512(sha512);
|
||||
if (data == null) {
|
||||
LOGGER.info("Need to add the data in the BDD ... ");
|
||||
try {
|
||||
data = createNewData(tmpUID, fileMetaData.getFileName(), sha512);
|
||||
} catch (final IOException ex) {
|
||||
removeTemporaryFile(tmpUID);
|
||||
throw new FailException(Response.Status.NOT_MODIFIED,
|
||||
clazz.getCanonicalName() + "[" + id.toString() + "] can not create input media", ex);
|
||||
} catch (final SQLException ex) {
|
||||
removeTemporaryFile(tmpUID);
|
||||
throw new FailException(Response.Status.NOT_MODIFIED,
|
||||
clazz.getCanonicalName() + "[" + id.toString() + "] Error in SQL insertion", ex);
|
||||
}
|
||||
} else if (data.deleted) {
|
||||
LOGGER.error("Data already exist but deleted");
|
||||
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.serverError().build();
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ export function RESTRequest({
|
||||
data,
|
||||
params,
|
||||
queries,
|
||||
callback,
|
||||
callbacks,
|
||||
}: RESTRequestType): Promise<ModelResponseHttp> {
|
||||
// Create the URL PATH:
|
||||
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
||||
@ -268,10 +268,10 @@ export function RESTRequest({
|
||||
return new Promise((resolve, reject) => {
|
||||
let action: undefined | Promise<Response> = undefined;
|
||||
if (
|
||||
isNullOrUndefined(callback) ||
|
||||
(isNullOrUndefined(callback.progressDownload) &&
|
||||
isNullOrUndefined(callback.progressUpload) &&
|
||||
isNullOrUndefined(callback.abortHandle))
|
||||
isNullOrUndefined(callbacks) ||
|
||||
(isNullOrUndefined(callbacks.progressDownload) &&
|
||||
isNullOrUndefined(callbacks.progressUpload) &&
|
||||
isNullOrUndefined(callbacks.abortHandle))
|
||||
) {
|
||||
// No information needed: call the generic fetch interface
|
||||
action = fetch(generateUrl, {
|
||||
@ -288,7 +288,7 @@ export function RESTRequest({
|
||||
headers,
|
||||
body,
|
||||
},
|
||||
callback
|
||||
callbacks
|
||||
);
|
||||
}
|
||||
action
|
||||
|
@ -1 +1 @@
|
||||
0.12.1
|
||||
0.12.3-dev
|
||||
|
Loading…
x
Reference in New Issue
Block a user