catching all interface errors

This commit is contained in:
gexce
2017-11-10 08:47:26 +01:00
parent db3c35b4c0
commit ddb7697e55
4 changed files with 50 additions and 32 deletions
@@ -2,4 +2,4 @@
logging.level.com.bayer=DEBUG
#logging.level.com.bayer.edam.migration.interceptors=INFO
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level- %msg%n
logging.file=application_2017-11-09_QA.log
logging.file=application_2017-11-10_QA.log
@@ -48,8 +48,7 @@ public class Definitions {
fieldIDs = new HashMap<String, String>();
users = new HashMap<String, String>();
// XXX
classifications.put("Migration.Filetest", new WriteClassification("f1d058987a3043d5b021a819007ff3c0", 1));
classifications.put("Migration.Test", new WriteClassification("f1d058987a3043d5b021a819007ff3c0", 1));
// QA values
classifications.put("Migration", new WriteClassification("2bd24882-b7d8-4d30-8e6f-a7ef00eb33e7", 1));
@@ -203,6 +202,8 @@ public class Definitions {
// XXX PROD values
// classifications.put("Migration.Test", new WriteClassification("0c60449fd3ef43a39eeea827007fb0eb", 1));
//
// classifications.put("Migration", new WriteClassification("351a41cfa5114e6ca3cba81f0089dd2c", 1));
// classifications.put("Migration.Logos", new WriteClassification("fc6f04881e0e42eb9bc1a81f008a0d8d", 1));
//
@@ -36,6 +36,7 @@ import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestTemplate;
import com.bayer.edam.migration.adam.Campaign;
@@ -140,8 +141,8 @@ public class MamMigrationSelective implements CommandLineRunner {
// XXX
// if needed start from a certain ID
// if (id > 32348)
// continue;
if (id > 70746)
continue;
@@ -190,7 +191,7 @@ public class MamMigrationSelective implements CommandLineRunner {
HashSet<String> campaignGuids = new HashSet<String>();
// XXX
record.addClassification("Migration.Filetest");
record.addClassification("Migration.Test");
// globally applicable classifications
record.addClassification("Migration");
@@ -505,6 +506,13 @@ public class MamMigrationSelective implements CommandLineRunner {
catch (HttpStatusCodeException hsce) {
log.error("RESULT Skipping entry " + entry.id + ": Error while creating record " + hsce.getStatusCode().toString());
log.error(hsce.getResponseBodyAsString());
log.error(hsce.getRootCause().toString());
hsce.printStackTrace();
}
catch (ResourceAccessException rae) {
log.error("RESULT Could not create record for entry " + entry.id + ": " + rae.getMessage());
log.error(rae.getRootCause().toString());
rae.printStackTrace();
}
}
@@ -574,29 +582,37 @@ public class MamMigrationSelective implements CommandLineRunner {
MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<String, Object>();
parameters.add("file", new FileSystemResource(file));
UploadResult result = fileTransferTemplate.exchange(Definitions.adamHost + "/uploads", HttpMethod.POST,
new HttpEntity<MultiValueMap<String, Object>>(parameters, adamUploadHeaders), UploadResult.class).getBody();
try {
UploadResult result = fileTransferTemplate.exchange(Definitions.adamHost + "/uploads", HttpMethod.POST,
new HttpEntity<MultiValueMap<String, Object>>(parameters, adamUploadHeaders), UploadResult.class).getBody();
if (result.token != null) {
log.debug("Storing upload token " + result.token);
UploadReference reference = new UploadReference();
reference.targetRecord = recordLocation;
reference.isMaster = isMaster;
reference.token = result.token;
reference.cachePath = file.getAbsolutePath();
openUploads.add(reference);
}
else if (result.uri != null) {
log.debug("Storing upload reference " + result.uri);
UploadReference reference = new UploadReference();
reference.targetRecord = recordLocation;
reference.isMaster = isMaster;
reference.uri = result.uri;
reference.cachePath = file.getAbsolutePath();
openUploads.add(reference);
}
else {
log.error("No token/URI after upload!");
}
if (result.token != null) {
log.debug("Storing upload token " + result.token);
UploadReference reference = new UploadReference();
reference.targetRecord = recordLocation;
reference.isMaster = isMaster;
reference.token = result.token;
reference.filename = file.getName();
openUploads.add(reference);
}
else if (result.uri != null) {
log.debug("Storing upload reference " + result.uri);
UploadReference reference = new UploadReference();
reference.targetRecord = recordLocation;
reference.isMaster = isMaster;
reference.uri = result.uri;
reference.filename = file.getName();
openUploads.add(reference);
}
else {
log.error("No token/URI after upload!");
catch (ResourceAccessException rae) {
log.error("Could not upload " + file.getAbsolutePath() + "(" + isMaster + ") for " + recordLocation + " from entry " + entry.id + ": " + rae.getMessage());
log.error(rae.getRootCause().toString());
rae.printStackTrace();
}
}
@@ -625,7 +641,7 @@ public class MamMigrationSelective implements CommandLineRunner {
UploadFileRecord fileRecord = new UploadFileRecord();
fileRecord.addFile(reference.token, reference.isMaster);
log.debug("Attach " + reference.filename + " to " + reference.targetRecord);
log.debug("Attach " + reference.cachePath + " to " + reference.targetRecord);
HttpEntity<UploadFileRecord> httpEntity = new HttpEntity<UploadFileRecord>(fileRecord, adamHeaders);
try {
@@ -640,7 +656,7 @@ public class MamMigrationSelective implements CommandLineRunner {
processedReferences.add(reference);
}
else {
log.debug("Checking status of " + reference.filename + " for " + reference.uri);
log.debug("Checking status of " + reference.cachePath + " for " + reference.uri);
UploadResult result = restTemplate.exchange(Definitions.adamHost + reference.uri, HttpMethod.GET, adamHeadersEntity, UploadResult.class).getBody();
log.debug("Result: " + result);
@@ -651,7 +667,7 @@ public class MamMigrationSelective implements CommandLineRunner {
}
else if (result.status != null) {
if (result.status.equals("Error")) {
log.error("System could not process file " + reference.filename + " for " + reference.targetRecord);
log.error("System could not process file " + reference.cachePath + " for " + reference.targetRecord);
processedReferences.add(reference);
}
}
@@ -8,7 +8,8 @@ public class UploadReference {
String uri;
String token;
String filename;
// String filename;
boolean isMaster;
String cachePath;
}