Skip to content

Commit 87b6c42

Browse files
committed
detect external install hooks in mutable packages as well
This closes #17
1 parent 73caaf3 commit 87b6c42

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/it/project1/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010
<build>
1111
<pluginManagement>
1212
<plugins>
13+
<plugin>
14+
<artifactId>maven-clean-plugin</artifactId>
15+
<version>3.1.0</version>
16+
</plugin>
17+
<plugin>
18+
<artifactId>maven-install-plugin</artifactId>
19+
<version>3.0.0-M1</version>
20+
</plugin>
21+
<plugin>
22+
<artifactId>maven-deploy-plugin</artifactId>
23+
<version>3.0.0-M1</version>
24+
</plugin>
1325
<plugin>
1426
<artifactId>maven-resources-plugin</artifactId>
1527
<version>3.2.0</version>

src/it/project1/verify.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ String buildLog = new File(basedir, 'build.log').text
22

33
assert buildLog.contains('[WARNING] ValidationViolation: "netcentric-aem-cloud: Nodes below \'/libs\' may be overwritten by future product upgrades. Rather use \'/apps\'. Further details at https://experienceleague.adobe.com/docs/experience-manager-cloud-service/implementing/developing/full-stack/overlays.html?lang=en#developing", filePath=jcr_root/libs/cq/test/test.jsp, nodePath=/libs/cq/test/test.jsp') : 'libs violation not found'
44
assert buildLog.contains('[WARNING] ValidationViolation: "netcentric-aem-cloud: Using mutable nodes in this repository location is not allowed as it is not writable by the underlying service user on publish. Consider to use repoinit scripts instead or move that content to another location. Further details at https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/debugging/debugging-aem-as-a-cloud-service/build-and-deployment.html?lang=en#including-%2Fvar-in-content-package", filePath=jcr_root/var/example/test.txt, nodePath=/var/example/test.txt') : 'read only path in mutable package not detected'
5-
assert buildLog.contains('[WARNING] ValidationViolation: "netcentric-aem-cloud: Using install hooks in mutable content packages leads to deployment failures as the underlying service user on the publish does not have the right to execute those.", filePath=META-INF/vault/hooks/vault-hook-example-3.0.0.jar') : 'external hook violation not found'
5+
assert buildLog.contains('[WARNING] ValidationViolation: "netcentric-aem-cloud: Using install hooks in mutable content packages leads to deployment failures as the underlying service user on the publish does not have the right to execute those.", filePath=META-INF/vault/hooks/vault-hook-example-3.0.0.jar') : 'internal hook violation not found'
6+
assert buildLog.contains('[WARNING] ValidationViolation: "netcentric-aem-cloud: Using install hooks in mutable content packages leads to deployment failures as the underlying service user on the publish does not have the right to execute those.", filePath=META-INF/vault/properties') : 'external hook violation not found'
67
assert buildLog.contains('[WARNING] ValidationViolation: "netcentric-aem-cloud: Mutable nodes in mixed package types are not installed!", filePath=jcr_root/content/example/test.txt, nodePath=/content/example/test.txt') : 'mutable content in mixed package not found'

src/main/java/biz/netcentric/filevault/validator/aem/cloud/AemCloudValidator.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,21 @@
2222
import java.util.Collections;
2323
import java.util.regex.Pattern;
2424

25+
import org.apache.jackrabbit.vault.packaging.PackageProperties;
2526
import org.apache.jackrabbit.vault.packaging.PackageType;
2627
import org.apache.jackrabbit.vault.util.Constants;
2728
import org.apache.jackrabbit.vault.util.DocViewNode;
2829
import org.apache.jackrabbit.vault.validation.spi.DocumentViewXmlValidator;
2930
import org.apache.jackrabbit.vault.validation.spi.MetaInfPathValidator;
3031
import org.apache.jackrabbit.vault.validation.spi.NodePathValidator;
32+
import org.apache.jackrabbit.vault.validation.spi.PropertiesValidator;
3133
import org.apache.jackrabbit.vault.validation.spi.ValidationContext;
3234
import org.apache.jackrabbit.vault.validation.spi.ValidationMessage;
3335
import org.apache.jackrabbit.vault.validation.spi.ValidationMessageSeverity;
3436
import org.jetbrains.annotations.NotNull;
3537
import org.jetbrains.annotations.Nullable;
3638

37-
public class AemCloudValidator implements NodePathValidator, MetaInfPathValidator, DocumentViewXmlValidator {
39+
public class AemCloudValidator implements NodePathValidator, MetaInfPathValidator, DocumentViewXmlValidator, PropertiesValidator {
3840

3941
static final String VIOLATION_MESSAGE_CONDITION_AUTHOR_ONLY_CONTAINER = "only allowed in author-specific packages";
4042
static final String VIOLATION_MESSAGE_CONDITION_OVERALL = "not allowed";
@@ -212,4 +214,14 @@ static boolean isPackagePathInstalledConditionally(String runMode, Path packageR
212214
return null;
213215
}
214216

217+
@Override
218+
public @Nullable Collection<ValidationMessage> validate(@NotNull PackageProperties properties) {
219+
if (!properties.getExternalHooks().isEmpty()) {
220+
if (PackageType.CONTENT.equals(packageType) || PackageType.MIXED.equals(packageType)) {
221+
return Collections.singleton(new ValidationMessage(defaultSeverity, VIOLATION_MESSAGE_INSTALL_HOOK_IN_MUTABLE_PACKAGE));
222+
}
223+
}
224+
return null;
225+
}
226+
215227
}

0 commit comments

Comments
 (0)