identify master file when attaching to record
This commit is contained in:
@@ -167,7 +167,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
|
|
||||||
while (openUploads.size() > 0) {
|
while (openUploads.size() > 0) {
|
||||||
log.debug("Sleeping...");
|
log.debug("Sleeping...");
|
||||||
TimeUnit.SECONDS.sleep(10); // XXX
|
TimeUnit.SECONDS.sleep(5); // XXX
|
||||||
|
|
||||||
log.debug("Checking back on open uploads");
|
log.debug("Checking back on open uploads");
|
||||||
attachOpenUploads();
|
attachOpenUploads();
|
||||||
@@ -468,8 +468,6 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
|
|
||||||
uploadFilesForEntry(entry, location);
|
uploadFilesForEntry(entry, location);
|
||||||
|
|
||||||
// TODO process file upload errors(?)
|
|
||||||
|
|
||||||
log.info("FINAL " + entry.id + fieldSeparator + location.toString() + fieldSeparator + entryJson);
|
log.info("FINAL " + entry.id + fieldSeparator + location.toString() + fieldSeparator + entryJson);
|
||||||
}
|
}
|
||||||
catch (HttpStatusCodeException hsce) {
|
catch (HttpStatusCodeException hsce) {
|
||||||
@@ -551,16 +549,16 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
log.debug("Storing upload token " + result.token);
|
log.debug("Storing upload token " + result.token);
|
||||||
UploadReference reference = new UploadReference();
|
UploadReference reference = new UploadReference();
|
||||||
reference.targetRecord = recordLocation;
|
reference.targetRecord = recordLocation;
|
||||||
// reference.isMaster = isMaster;
|
reference.isMaster = isMaster;
|
||||||
reference.token = result.token;
|
reference.token = result.token;
|
||||||
reference.filename = file.getName();
|
reference.filename = file.getName();
|
||||||
openUploads.add(reference);
|
openUploads.add(reference);
|
||||||
}
|
}
|
||||||
else if (result.uri != null) {
|
else if (result.uri != null) {
|
||||||
log.debug("Storing upload reference URI " + result.uri);
|
log.debug("Storing upload reference " + result.uri);
|
||||||
UploadReference reference = new UploadReference();
|
UploadReference reference = new UploadReference();
|
||||||
reference.targetRecord = recordLocation;
|
reference.targetRecord = recordLocation;
|
||||||
// reference.isMaster = isMaster;
|
reference.isMaster = isMaster;
|
||||||
reference.uri = result.uri;
|
reference.uri = result.uri;
|
||||||
reference.filename = file.getName();
|
reference.filename = file.getName();
|
||||||
openUploads.add(reference);
|
openUploads.add(reference);
|
||||||
@@ -594,17 +592,20 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
for (UploadReference reference : openUploads) {
|
for (UploadReference reference : openUploads) {
|
||||||
if (reference.token != null) {
|
if (reference.token != null) {
|
||||||
UploadFileRecord fileRecord = new UploadFileRecord();
|
UploadFileRecord fileRecord = new UploadFileRecord();
|
||||||
fileRecord.addFile(reference.token, reference.filename);
|
fileRecord.addFile(reference.token, reference.filename, reference.isMaster);
|
||||||
|
|
||||||
log.debug("Attach uploaded file to " + reference.targetRecord);
|
log.debug("Attach uploaded file to " + reference.targetRecord);
|
||||||
HttpEntity<UploadFileRecord> httpEntity = new HttpEntity<UploadFileRecord>(fileRecord, adamHeaders);
|
HttpEntity<UploadFileRecord> httpEntity = new HttpEntity<UploadFileRecord>(fileRecord, adamHeaders);
|
||||||
|
|
||||||
// TODO HIER GEHT'S WEITER - mal mit Browser testen
|
|
||||||
// TODO E:\56942 wieder herstellen
|
// TODO E:\56942 wieder herstellen
|
||||||
Void response = restTemplate.exchange(Definitions.adamHost + reference.targetRecord, HttpMethod.PUT, httpEntity, Void.class).getBody();
|
try {
|
||||||
|
ResponseEntity<Void> response = restTemplate.exchange(Definitions.adamHost + reference.targetRecord, HttpMethod.PUT, httpEntity, Void.class);
|
||||||
// TODO
|
log.debug("Response: " + response.toString());
|
||||||
log.debug("Response: " + response);
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
log.error("Exception while attaching file to record " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
processedReferences.add(reference);
|
processedReferences.add(reference);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ public class UploadReference {
|
|||||||
String token;
|
String token;
|
||||||
|
|
||||||
String filename;
|
String filename;
|
||||||
// String isMaster;
|
boolean isMaster;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,13 +34,12 @@ public class UploadFileRecord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Files {
|
public static class Files {
|
||||||
// public String master;
|
public String master;
|
||||||
public List<FileContent> addOrUpdate = new ArrayList<FileContent>();
|
public List<FileContent> addOrUpdate = new ArrayList<FileContent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UploadFileRecord(String masterToken, String masterFilename) {
|
public UploadFileRecord(String masterToken, String masterFilename) {
|
||||||
// files.master = masterToken;
|
addFile(masterToken, masterFilename, true);
|
||||||
addFile(masterToken, masterFilename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UploadFileRecord() {
|
public UploadFileRecord() {
|
||||||
@@ -49,7 +48,10 @@ public class UploadFileRecord {
|
|||||||
public String contentType = "Record";
|
public String contentType = "Record";
|
||||||
public Files files = new Files();
|
public Files files = new Files();
|
||||||
|
|
||||||
public void addFile(String token, String filename) {
|
public void addFile(String token, String filename, boolean isMaster) {
|
||||||
files.addOrUpdate.add(new FileContent(new Versions(new WriteFile(token, filename))));
|
files.addOrUpdate.add(new FileContent(new Versions(new WriteFile(token, filename))));
|
||||||
|
|
||||||
|
if (isMaster)
|
||||||
|
files.master = token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user