1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package io.wcm.devops.conga.plugins.aem.maven.model;
21
22 import static io.wcm.devops.conga.plugins.aem.postprocessor.ContentPackagePropertiesPostProcessor.DEPENDENCY_CHAIN_IGNORE_PROPERTY;
23 import static io.wcm.devops.conga.plugins.aem.postprocessor.ContentPackagePropertiesPostProcessor.MODEL_OPTIONS_PROPERTY;
24 import static org.apache.jackrabbit.vault.packaging.PackageProperties.NAME_GROUP;
25 import static org.apache.jackrabbit.vault.packaging.PackageProperties.NAME_NAME;
26 import static org.apache.jackrabbit.vault.packaging.PackageProperties.NAME_PACKAGE_TYPE;
27 import static org.apache.jackrabbit.vault.packaging.PackageProperties.NAME_VERSION;
28
29 import java.io.File;
30 import java.util.List;
31 import java.util.Map;
32 import java.util.Objects;
33
34 import org.jetbrains.annotations.Nullable;
35
36
37
38
39 public final class ModelContentPackageFile extends AbstractInstallableFile implements ContentPackageFile {
40
41 private final Boolean install;
42 private final Boolean force;
43 private final Boolean recursive;
44 private final Integer delayAfterInstallSec;
45 private final Integer httpSocketTimeoutSec;
46 private final Boolean dependencyChainIgnore;
47
48 private final String name;
49 private final String group;
50 private final String version;
51 private final String packageType;
52
53
54
55
56
57
58 @SuppressWarnings("unchecked")
59 public ModelContentPackageFile(File file, Map<String, Object> fileData, List<String> variants) {
60 super(file, variants);
61
62 this.install = (Boolean)fileData.get("install");
63 this.force = (Boolean)fileData.get("force");
64 this.recursive = (Boolean)fileData.get("recursive");
65 this.delayAfterInstallSec = (Integer)fileData.get("delayAfterInstallSec");
66 this.httpSocketTimeoutSec = (Integer)fileData.get("httpSocketTimeoutSec");
67 this.dependencyChainIgnore = (Boolean)fileData.get(DEPENDENCY_CHAIN_IGNORE_PROPERTY);
68
69 Map<String, Object> contentPackageProperties = (Map<String, Object>)fileData.get(MODEL_OPTIONS_PROPERTY);
70 if (contentPackageProperties == null) {
71 throw new IllegalArgumentException(MODEL_OPTIONS_PROPERTY + " missing.");
72 }
73 this.name = Objects.toString(contentPackageProperties.get(NAME_NAME), null);
74 this.group = Objects.toString(contentPackageProperties.get(NAME_GROUP), null);
75 this.version = Objects.toString(contentPackageProperties.get(NAME_VERSION), null);
76 this.packageType = Objects.toString(contentPackageProperties.get(NAME_PACKAGE_TYPE), null);
77 }
78
79 public Boolean getInstall() {
80 return this.install;
81 }
82
83 @Nullable
84 public Boolean getForce() {
85 return this.force;
86 }
87
88 @Nullable
89 public Boolean getRecursive() {
90 return this.recursive;
91 }
92
93 @Nullable
94 public Integer getDelayAfterInstallSec() {
95 return this.delayAfterInstallSec;
96 }
97
98 @Nullable
99 public Integer getHttpSocketTimeoutSec() {
100 return this.httpSocketTimeoutSec;
101 }
102
103 @Override
104 public String getName() {
105 return this.name;
106 }
107
108 @Override
109 public String getGroup() {
110 return this.group;
111 }
112
113 @Override
114 public String getVersion() {
115 return this.version;
116 }
117
118 @Override
119 public String getPackageType() {
120 return this.packageType;
121 }
122
123 @Override
124 public boolean isDependencyChainIgnore() {
125 return dependencyChainIgnore != null && dependencyChainIgnore;
126 }
127
128 }