Special processing for media type "Logo Folder"
This commit is contained in:
@@ -2,4 +2,4 @@
|
|||||||
logging.level.com.bayer=DEBUG
|
logging.level.com.bayer=DEBUG
|
||||||
#logging.level.com.bayer.edam.migration.interceptors=INFO
|
#logging.level.com.bayer.edam.migration.interceptors=INFO
|
||||||
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level- %msg%n
|
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level- %msg%n
|
||||||
logging.file=application_2017-11-17.log
|
logging.file=application_2017-11-17_71537_Logo.log
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
static final String mamHost = "https://service.media-assistant.animalhealth.bayer.com";
|
static final String mamHost = "https://service.media-assistant.animalhealth.bayer.com";
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
static final String fileCache = "E:\\";
|
static final String fileCache = "E:\\_TEST\\";
|
||||||
|
|
||||||
static final String categoryJson = "resources/2017-10-19_categories.json";
|
static final String categoryJson = "resources/2017-10-19_categories.json";
|
||||||
static final String categoryMapping = "resources/Media_Assistant_Categories_131017_EDITED_without_archive.csv";
|
static final String categoryMapping = "resources/Media_Assistant_Categories_131017_EDITED_without_archive.csv";
|
||||||
@@ -114,8 +114,10 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
// entrySelection = new ArrayList<Long>(entryMap.keySet());
|
// entrySelection = new ArrayList<Long>(entryMap.keySet());
|
||||||
|
|
||||||
// Option 2: Process a fixed set of entry IDs
|
// Option 2: Process a fixed set of entry IDs
|
||||||
entrySelection = Arrays.asList(71725L, 71263L, 71048L, 70778L, 70746L, 70745L, 70440L, 70361L, 70340L, 70288L, 70161L, 70142L,
|
// entrySelection = Arrays.asList(71725L, 71263L, 71048L, 70778L, 70746L, 70745L, 70440L, 70361L, 70340L, 70288L, 70161L, 70142L,
|
||||||
63924L, 63201L, 57641L, 56942L);
|
// 63924L, 63201L, 57641L, 56942L);
|
||||||
|
|
||||||
|
entrySelection = Arrays.asList(71537L);
|
||||||
|
|
||||||
// Option 3: Read entry IDs from file
|
// Option 3: Read entry IDs from file
|
||||||
// entrySelection = new ArrayList<Long>();
|
// entrySelection = new ArrayList<Long>();
|
||||||
@@ -584,6 +586,53 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
log.info("Using extracted master file " + extractedMasterFilePath);
|
log.info("Using extracted master file " + extractedMasterFilePath);
|
||||||
masterFile = new File(extractedMasterFilePath);
|
masterFile = new File(extractedMasterFilePath);
|
||||||
}
|
}
|
||||||
|
else if (entry.mediaType.name.get("en").equals("Logo Folder")) {
|
||||||
|
String destPath = fileCache + entry.id + "\\";
|
||||||
|
log.info("Extracting single 'Logo Folder' files " + destPath);
|
||||||
|
zipFile.extractAll(destPath);
|
||||||
|
|
||||||
|
boolean pngFound = false;
|
||||||
|
boolean jpgFound = false;
|
||||||
|
String newMasterFilePath = null;
|
||||||
|
FileHeader newMasterFileHeader = null;
|
||||||
|
|
||||||
|
for (FileHeader header : fileHeaders) {
|
||||||
|
if (header.getFileName().toLowerCase().endsWith(".png")) {
|
||||||
|
pngFound = true;
|
||||||
|
newMasterFilePath = destPath + header.getFileName();
|
||||||
|
newMasterFileHeader = header;
|
||||||
|
}
|
||||||
|
else if (header.getFileName().toLowerCase().endsWith(".jpg") && !pngFound) {
|
||||||
|
jpgFound = true;
|
||||||
|
newMasterFilePath = destPath + header.getFileName();
|
||||||
|
newMasterFileHeader = header;
|
||||||
|
}
|
||||||
|
else if (!header.isDirectory() && !pngFound && !jpgFound) {
|
||||||
|
newMasterFilePath = destPath + header.getFileName();
|
||||||
|
newMasterFileHeader = header;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newMasterFilePath != null) {
|
||||||
|
masterFile = new File(newMasterFilePath);
|
||||||
|
log.info("Using extracted master file " + newMasterFilePath);
|
||||||
|
|
||||||
|
// add remaining extracted files
|
||||||
|
for (FileHeader header : fileHeaders) {
|
||||||
|
if (!header.isDirectory() && header != newMasterFileHeader) {
|
||||||
|
File extractedFile = new File(destPath + header.getFileName());
|
||||||
|
if (extractedFile.exists())
|
||||||
|
filesForUpload.add(extractedFile);
|
||||||
|
else
|
||||||
|
log.error("Could not find extraced file " + destPath + header.getFileName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log.info("No suitable master file found, uploading compressed file " + masterFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filesForUpload.add(masterFile);
|
filesForUpload.add(masterFile);
|
||||||
@@ -707,7 +756,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (RestClientException rce) {
|
catch (RestClientException rce) {
|
||||||
log.error("Failed to check status of " + reference.cachePath + " for " + reference.uri);
|
log.error("Failed to check status of " + reference.cachePath + " for " + reference.uri + ": " + rce.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user