|
|
@ -62,8 +62,9 @@ public class ScormExtractor implements WorkflowProcess { |
|
|
|
|
|
|
|
|
|
|
|
/* Created for manually triggered workflows */ |
|
|
|
/* Created for manually triggered workflows */ |
|
|
|
String payloadPath = wi.getContentPath().replace("/jcr:content/renditions/original",""); |
|
|
|
String payloadPath = wi.getContentPath().replace("/jcr:content/renditions/original",""); |
|
|
|
String[] fileExtensions = params; |
|
|
|
String[] fileExtensions = params; // Valid extensions com from the 'Arguments' field in the workflows 'Process' tab
|
|
|
|
unzipFile(payloadPath, fileExtensions); |
|
|
|
unzipFile(payloadPath, fileExtensions); |
|
|
|
|
|
|
|
cleanup(payloadPath, resourceResolver); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void cleanup(String path, ResourceResolver resourceResolver) { |
|
|
|
private void cleanup(String path, ResourceResolver resourceResolver) { |
|
|
@ -90,10 +91,11 @@ public class ScormExtractor implements WorkflowProcess { |
|
|
|
Resource zipfile = resourceResolver.getResource(filePath); |
|
|
|
Resource zipfile = resourceResolver.getResource(filePath); |
|
|
|
AssetManager am = resourceResolver.adaptTo(AssetManager.class); |
|
|
|
AssetManager am = resourceResolver.adaptTo(AssetManager.class); |
|
|
|
log.warn("SCORM WORKFLOW: Resource - " + zipfile.getResourceType()); |
|
|
|
log.warn("SCORM WORKFLOW: Resource - " + zipfile.getResourceType()); |
|
|
|
|
|
|
|
|
|
|
|
Asset a = zipfile.adaptTo(Asset.class); |
|
|
|
Asset a = zipfile.adaptTo(Asset.class); |
|
|
|
InputStream is = a.getOriginal().getStream(); |
|
|
|
InputStream is = a.getOriginal().getStream(); |
|
|
|
//NOTE: now working in initial directory level, need to extract to new folders
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//NOTE: now working in initial directory level, need to extract to new folders
|
|
|
|
try (ZipInputStream zipIn = new ZipInputStream(is)) { |
|
|
|
try (ZipInputStream zipIn = new ZipInputStream(is)) { |
|
|
|
ZipEntry entry = zipIn.getNextEntry(); |
|
|
|
ZipEntry entry = zipIn.getNextEntry(); |
|
|
|
while (entry != null) { |
|
|
|
while (entry != null) { |
|
|
@ -117,6 +119,7 @@ public class ScormExtractor implements WorkflowProcess { |
|
|
|
while ((length = zipIn.read(buffer)) >= 0) { |
|
|
|
while ((length = zipIn.read(buffer)) >= 0) { |
|
|
|
fos.write(buffer, 0, length); |
|
|
|
fos.write(buffer, 0, length); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
log.warn("SCORM WORKFLOW: saving to AEM: " + zipFilePath); |
|
|
|
InputStream fis = new FileInputStream(f); |
|
|
|
InputStream fis = new FileInputStream(f); |
|
|
|
am.createAsset(zipFilePath, fis, null, true); |
|
|
|
am.createAsset(zipFilePath, fis, null, true); |
|
|
|
log.warn("SCORM WORKFLOW: file extracted: " + zipFilePath); |
|
|
|
log.warn("SCORM WORKFLOW: file extracted: " + zipFilePath); |
|
|
@ -128,7 +131,7 @@ public class ScormExtractor implements WorkflowProcess { |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (FileNotFoundException e) { |
|
|
|
} catch (FileNotFoundException e) { |
|
|
|
log.error(e.getMessage()); |
|
|
|
log.error(e.getMessage()); |
|
|
|
e.printStackTrace(); |
|
|
|
log.error(e.getStackTrace().toString()); |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
log.error(e.getMessage()); |
|
|
|
log.error(e.getMessage()); |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|