Skip to content

Commit

Permalink
Only the KTBL-Data-Stream should be persisted.
Browse files Browse the repository at this point in the history
The TOSCIENCE & METADATA2 data streams should not be mapped or persisted for KTBL at first.
  • Loading branch information
hadoud committed Nov 27, 2023
1 parent 104b5d3 commit 3704914
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions app/controllers/Resource.java
Original file line number Diff line number Diff line change
Expand Up @@ -549,21 +549,17 @@ public static Promise<Result> updateDeepGreen(@PathParam("pid") String pid,
public static Promise<Result> updateKtbl(@PathParam("pid") String pid) {
return new ModifyAction().call(pid, node -> {
try {
play.Logger.debug("Starting updateKtbl");
String ktblContent = null;

play.Logger.debug("Starting KTBL Mapping");

Node readNode = new Read().readNode(pid);

MultipartFormData body = request().body().asMultipartFormData();

play.Logger.debug("getFile");
FilePart data = body.getFile("data");
play.Logger.debug("getFile done");

if (data == null) {
return (Result) JsonMessage(new Message("Missing File.", 400));
}
play.Logger.debug("Starting updateKtbl data with pid=" + pid);
play.Logger.debug("request().body().asJson()=" + data.toString());

/**
* 1.KTBL(Json)***************************************
Expand All @@ -578,29 +574,30 @@ public static Promise<Result> updateKtbl(@PathParam("pid") String pid) {

String result1 = modify.updateMetadata("ktbl", readNode, ktblMetadata);

play.Logger.debug("Done KTBL Mapping");

/**
* 2. TOSCIENCE(Json)***************************************
*/

String result2 =
modify.updateMetadata("toscience", readNode, ktblMetadata);
// String result2 =
// modify.updateMetadata("toscience", readNode, ktblMetadata);

/**
* 3. METADATA2(rdf)***************************************
*/
JSONObject ktblJson = new JSONObject(ktblMetadata);
Map<String, Object> rdf =
KTBLMapperHelper.getMapFromJSONObject(ktblJson);

String contentRewrite = modify.rewriteContent(rdf.toString(), pid);

String result3 =
modify.updateMetadata("metadata2", readNode, contentRewrite);
// JSONObject ktblJson = new JSONObject(ktblMetadata);
// Map<String, Object> rdf =
// KTBLMapperHelper.getMapFromJSONObject(ktblJson);
//
// String contentRewrite = modify.rewriteContent(rdf.toString(), pid);
//
// String result3 =
// modify.updateMetadata("metadata2", readNode, contentRewrite);

Globals.fedora.updateNode(readNode);

return JsonMessage(
new Message(result1 + "\n" + result2 + "\n" + result3));
return JsonMessage(new Message(result1));
} catch (Exception e) {
throw new HttpArchiveException(500, e);
}
Expand Down

0 comments on commit 3704914

Please sign in to comment.