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.importexport.BootstrapUtil;
37 import info.magnolia.module.InstallContext;
38
39 import java.io.IOException;
40
41 import javax.jcr.RepositoryException;
42
43
44
45
46
47
48
49 public class BootstrapSingleResource extends BootstrapResourcesTask {
50 private final String resource;
51 private final String subPath;
52
53 public BootstrapSingleResource(String name, String description, String resource) {
54 super(name, description);
55 this.resource = resource;
56 this.subPath = null;
57 }
58
59 public BootstrapSingleResource(String name, String description, String resource, int importUUIDBehavior) {
60 super(name, description, importUUIDBehavior);
61 this.resource = resource;
62 this.subPath = null;
63 }
64
65 public BootstrapSingleResource(String name, String description, String resource, String subPath) {
66 super(name, description);
67 this.resource = resource;
68 this.subPath = subPath;
69 }
70
71 public BootstrapSingleResource(String name, String description, String resource, String subPath, int importUUIDBehavior) {
72 super(name, description, importUUIDBehavior);
73 this.resource = resource;
74 this.subPath = subPath;
75 }
76
77 @Override
78 protected void bootstrap(InstallContext installContext, int importUUIDBehavior) throws IOException, RepositoryException {
79 if (subPath == null) {
80 super.bootstrap(installContext, importUUIDBehavior);
81 } else {
82 final String[] resourcesToBootstrap = getResourcesToBootstrap(installContext);
83 BootstrapUtil.bootstrap(resourcesToBootstrap[0], subPath, importUUIDBehavior);
84 }
85 }
86
87 @Override
88 protected String[] getResourcesToBootstrap(final InstallContext installContext) {
89 return new String[]{resource};
90 }
91 }