1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.module.delta;
35
36 import info.magnolia.cms.core.HierarchyManager;
37 import info.magnolia.module.InstallContext;
38 import info.magnolia.module.files.MD5CheckingFileExtractor;
39 import info.magnolia.module.files.ModuleFileExtractorTransformer;
40 import info.magnolia.module.files.FileExtractionLogger;
41
42 import java.io.IOException;
43
44
45
46
47
48
49
50 public class ModuleFilesExtraction extends AbstractTask {
51
52 public ModuleFilesExtraction() {
53 super("Files extraction", "Extracts module files.");
54 }
55
56 @Override
57 public void execute(final InstallContext ctx) throws TaskExecutionException {
58 final String moduleName = ctx.getCurrentModuleDefinition().getName();
59
60 final HierarchyManager hm = ctx.getConfigHierarchyManager();
61 final MD5CheckingFileExtractor extractor = new MD5CheckingFileExtractor(new InstallContextLogger(ctx), hm);
62 try {
63 extractor.extractFiles(new ModuleFileExtractorTransformer(moduleName));
64 } catch (IOException e) {
65 throw new TaskExecutionException("Could not extract files for module " + ctx.getCurrentModuleDefinition() + ": " + e.getMessage(), e);
66 }
67 }
68
69 private static class InstallContextLogger implements FileExtractionLogger {
70 private final InstallContext ctx;
71
72 public InstallContextLogger(InstallContext ctx) {
73 this.ctx = ctx;
74 }
75
76 @Override
77 public void error(String message) {
78 ctx.warn(message);
79 }
80 }
81 }