-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from justinedelson/issue/custom-install-hook-f…
…actory allow suppression of install hooks via new builder option. fixes #11
- Loading branch information
Showing
11 changed files
with
285 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
language: java | ||
jdk: oraclejdk8 | ||
dist: trusty | ||
script: | ||
- mvn -B verify | ||
after_success: | ||
|
42 changes: 42 additions & 0 deletions
42
core/src/main/java/net/adamcin/oakpal/core/ImportOptionsWithInstallHookProcessorFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2019 Mark Adamcin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.adamcin.oakpal.core; | ||
|
||
import org.apache.jackrabbit.vault.fs.io.ImportOptions; | ||
import org.apache.jackrabbit.vault.packaging.InstallHookProcessor; | ||
import org.apache.jackrabbit.vault.packaging.InstallHookProcessorFactory; | ||
|
||
class ImportOptionsWithInstallHookProcessorFactory extends ImportOptions implements InstallHookProcessorFactory { | ||
|
||
private final ImportOptions optionsDelegate; | ||
private final InstallHookProcessorFactory factoryDelegate; | ||
|
||
ImportOptionsWithInstallHookProcessorFactory(ImportOptions optionsDelegate, InstallHookProcessorFactory factoryDelegate) { | ||
this.optionsDelegate = optionsDelegate; | ||
this.factoryDelegate = factoryDelegate; | ||
} | ||
|
||
@Override | ||
public InstallHookProcessor createInstallHookProcessor() { | ||
return factoryDelegate.createInstallHookProcessor(); | ||
} | ||
|
||
@Override | ||
public ImportOptions copy() { | ||
return new ImportOptionsWithInstallHookProcessorFactory(optionsDelegate.copy(), factoryDelegate); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
core/src/test/java/net/adamcin/oakpal/core/BadInstallHookTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2018 Mark Adamcin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.adamcin.oakpal.core; | ||
|
||
import net.adamcin.oakpal.testing.TestPackageUtil; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
|
||
public class BadInstallHookTest { | ||
|
||
@Test(expected = NoClassDefFoundError.class) | ||
public void testBadInstallHook() throws Exception { | ||
File badInstallHookPackage = TestPackageUtil.prepareTestPackageFromFolder("bad-install-hook.zip", | ||
new File("src/test/resources/package_with_bad_installhook")); | ||
|
||
new OakMachine.Builder().build().scanPackage(badInstallHookPackage); | ||
} | ||
|
||
@Test() | ||
public void testBadInstallHookNoOpProcessor() throws Exception { | ||
File badInstallHookPackage = TestPackageUtil.prepareTestPackageFromFolder("bad-install-hook.zip", | ||
new File("src/test/resources/package_with_bad_installhook")); | ||
|
||
new OakMachine.Builder().withInstallHookProcessorFactory(OakMachine.NOOP_INSTALL_HOOK_PROCESSOR_FACTORY) | ||
.build().scanPackage(badInstallHookPackage); | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
core/src/test/resources/package_with_bad_installhook/META-INF/vault/config.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<!-- | ||
Copyright 2012 Adobe Systems Incorporated | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<vaultfs version="1.1"> | ||
<!-- | ||
Defines the content aggregation. The order of the defined aggregates | ||
is important for finding the correct aggregator. | ||
--> | ||
<aggregates> | ||
<!-- | ||
Defines an aggregate that handles nt:file and nt:resource nodes. | ||
--> | ||
<aggregate type="file" title="File Aggregate"/> | ||
|
||
<!-- | ||
Defines an aggregate that handles file/folder like nodes. It matches | ||
all nt:hierarchyNode nodes that have or define a jcr:content | ||
child node and excludes child nodes that are nt:hierarchyNodes. | ||
--> | ||
<aggregate type="filefolder" title="File/Folder Aggregate"/> | ||
|
||
<!-- | ||
Defines an aggregate that handles nt:nodeType nodes and serializes | ||
them into .cnd notation. | ||
--> | ||
<aggregate type="nodetype" title="Node Type Aggregate" /> | ||
|
||
<!-- | ||
Defines an aggregate that defines full coverage for certain node | ||
types that cannot be covered by the default aggregator. | ||
--> | ||
<aggregate type="full" title="Full Coverage Aggregate"> | ||
<matches> | ||
<include nodeType="rep:AccessControl" respectSupertype="true" /> | ||
<include nodeType="cq:Widget" respectSupertype="true" /> | ||
<include nodeType="cq:WidgetCollection" respectSupertype="true" /> | ||
<include nodeType="cq:EditConfig" respectSupertype="true" /> | ||
<include nodeType="cq:WorkflowModel" respectSupertype="true" /> | ||
<include nodeType="vlt:FullCoverage" respectSupertype="true" /> | ||
<include nodeType="mix:language" respectSupertype="true" /> | ||
<include nodeType="sling:OsgiConfig" respectSupertype="true" /> | ||
</matches> | ||
</aggregate> | ||
|
||
<!-- | ||
Defines an aggregate that handles nt:folder like nodes. | ||
--> | ||
<aggregate type="generic" title="Folder Aggregate"> | ||
<matches> | ||
<include nodeType="nt:folder" respectSupertype="true" /> | ||
</matches> | ||
<contains> | ||
<exclude isNode="true" /> | ||
</contains> | ||
</aggregate> | ||
|
||
<!-- | ||
Defines the default aggregate | ||
--> | ||
<aggregate type="generic" title="Default Aggregator" isDefault="true"> | ||
<contains> | ||
<exclude nodeType="nt:hierarchyNode" respectSupertype="true" /> | ||
</contains> | ||
<matches> | ||
<!-- all --> | ||
</matches> | ||
</aggregate> | ||
|
||
</aggregates> | ||
|
||
<!-- | ||
defines the input handlers | ||
--> | ||
<handlers> | ||
<handler type="folder"/> | ||
<handler type="file"/> | ||
<handler type="nodetype"/> | ||
<handler type="generic"/> | ||
</handlers> | ||
</vaultfs> |
3 changes: 3 additions & 0 deletions
3
core/src/test/resources/package_with_bad_installhook/META-INF/vault/filter.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<workspaceFilter version="1.0"> | ||
</workspaceFilter> |
Binary file added
BIN
+3.3 KB
...with_bad_installhook/META-INF/vault/hooks/oakpal-testing-hooktest.hook-0.0.1-SNAPSHOT.jar
Binary file not shown.
16 changes: 16 additions & 0 deletions
16
core/src/test/resources/package_with_bad_installhook/META-INF/vault/properties.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> | ||
<properties> | ||
<comment>OakPAL Testing - Hook Test Content Package</comment> | ||
<entry key="createdBy">jedelson</entry> | ||
<entry key="name">oakpal-testing-hooktest.ui.apps</entry> | ||
<entry key="acHandling">merge_preserve</entry> | ||
<entry key="created">2019-06-24T20:25:50.546-0400</entry> | ||
<entry key="groupId">com.myco.testing</entry> | ||
<entry key="version">0.0.1-SNAPSHOT</entry> | ||
<entry key="requiresRoot">false</entry> | ||
<entry key="group">my-co</entry> | ||
<entry key="description">Maven Multimodule project for OakPAL Testing - HookTest.</entry> | ||
<entry key="artifactId">oakpal-testing-hooktest.ui.apps</entry> | ||
<entry key="path">/etc/packages/my-co/oakpal-testing-hooktest.ui.apps.zip</entry> | ||
</properties> |
20 changes: 20 additions & 0 deletions
20
core/src/test/resources/package_with_bad_installhook/META-INF/vault/settings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2012 Adobe Systems Incorporated | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<vault version="1.0"> | ||
<ignore name=".svn"/> | ||
<ignore name=".DS_Store"/> | ||
</vault> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters