-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
261 additions
and
49 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
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
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
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
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
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
20 changes: 20 additions & 0 deletions
20
bundle/src/main/content/META-INF/vault/definition/.content.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. | ||
--> | ||
<jcr:root xmlns:vlt="http://www.day.com/jcr/vault/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" | ||
jcr:primaryType="vlt:PackageDefinition"> | ||
<thumbnail.png/> | ||
</jcr:root> |
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
43 changes: 43 additions & 0 deletions
43
...java/de/valtech/aecu/core/groovy/console/bindings/actions/resource/ChangePrimaryType.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,43 @@ | ||
package de.valtech.aecu.core.groovy.console.bindings.actions.resource; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.jcr.Node; | ||
import javax.jcr.RepositoryException; | ||
|
||
import org.apache.sling.api.resource.PersistenceException; | ||
import org.apache.sling.api.resource.Resource; | ||
|
||
import de.valtech.aecu.core.groovy.console.bindings.actions.Action; | ||
|
||
/** | ||
* Changes the jcr:primaryType of a node. | ||
* | ||
* @author Sajith | ||
*/ | ||
public class ChangePrimaryType implements Action { | ||
|
||
protected String newPrimaryType; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param newPrimaryType new type | ||
*/ | ||
public ChangePrimaryType(@Nonnull String newPrimaryType) { | ||
this.newPrimaryType = newPrimaryType; | ||
} | ||
|
||
@Override | ||
public String doAction(@Nonnull Resource resource) throws PersistenceException { | ||
Node node = resource.adaptTo(Node.class); | ||
try { | ||
if (null != node) { | ||
node.setPrimaryType(newPrimaryType); | ||
return "Updated jcr:primaryType to " + newPrimaryType; | ||
} | ||
} catch (RepositoryException e) { | ||
throw new PersistenceException("ERROR: could not update jcr:primaryType to " + newPrimaryType, e); | ||
} | ||
return "WARNING: could not update jcr:primaryType to " + newPrimaryType; | ||
} | ||
} |
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
58 changes: 58 additions & 0 deletions
58
.../de/valtech/aecu/core/groovy/console/bindings/actions/resource/ChangePrimaryTypeTest.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,58 @@ | ||
package de.valtech.aecu.core.groovy.console.bindings.actions.resource; | ||
|
||
import org.apache.sling.api.resource.PersistenceException; | ||
import org.apache.sling.api.resource.Resource; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
import javax.jcr.Node; | ||
import javax.jcr.RepositoryException; | ||
import javax.jcr.lock.LockException; | ||
import javax.jcr.nodetype.ConstraintViolationException; | ||
import javax.jcr.nodetype.NoSuchNodeTypeException; | ||
import javax.jcr.version.VersionException; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.mockito.Mockito.*; | ||
|
||
/** | ||
* Tests ChangePrimaryTypeTest | ||
* | ||
* @author Sajith | ||
*/ | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class ChangePrimaryTypeTest { | ||
|
||
private static final String newPrimaryType = "nt:unstructured"; | ||
|
||
@Mock | ||
private Resource resource; | ||
|
||
@Mock | ||
private Node node; | ||
|
||
@Before | ||
public void setup() { | ||
when(resource.adaptTo(Node.class)).thenReturn(node); | ||
} | ||
|
||
@Test | ||
public void test_doAction_setPrimaryType() throws PersistenceException, RepositoryException { | ||
ChangePrimaryType changePrimaryType = new ChangePrimaryType(newPrimaryType); | ||
String result = changePrimaryType.doAction(resource); | ||
verify(node, times(1)).setPrimaryType(newPrimaryType); | ||
assertEquals("Updated jcr:primaryType to " + newPrimaryType, result); | ||
} | ||
|
||
@Test | ||
public void test_doAction_nodeIsNull() throws PersistenceException, RepositoryException { | ||
when(resource.adaptTo(Node.class)).thenReturn(null); | ||
ChangePrimaryType changePrimaryType = new ChangePrimaryType(newPrimaryType); | ||
changePrimaryType.doAction(resource); | ||
verify(node, never()).setPrimaryType(newPrimaryType); | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
examples/src/main/content/META-INF/vault/definition/.content.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. | ||
--> | ||
<jcr:root xmlns:vlt="http://www.day.com/jcr/vault/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" | ||
jcr:primaryType="vlt:PackageDefinition"> | ||
<thumbnail.png/> | ||
</jcr:root> |
13 changes: 13 additions & 0 deletions
13
..._root/var/groovyconsole/scripts/aecu/aecu-examples/advanced-filter/advanced-filter.groovy
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,13 @@ | ||
def complexFilter = new ORFilter( | ||
[ new FilterByProperty("sling:resourceType", "weretail/components/content/heroimage"), | ||
new ANDFilter( [ | ||
new FilterByProperty("sling:resourceType", "weretail/components/content/image"), | ||
new FilterByNodeName("image") | ||
] ) | ||
]) | ||
|
||
aecu.contentUpgradeBuilder() | ||
.forDescendantResourcesOf("/content/we-retail/us/en") | ||
.filterWith(complexFilter) | ||
.printPath() | ||
.run() |
1 change: 1 addition & 0 deletions
1
...r/groovyconsole/scripts/aecu/aecu-examples/generic-examples/runmode.author/script1.groovy
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 @@ | ||
println "Sample script1" |
2 changes: 1 addition & 1 deletion
2
...migrations.author/script2.fallback.groovy → ...es/runmode.author/script2.fallback.groovy
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,2 +1,2 @@ | ||
// Scripts with extension ".fallback.groovy" will be executed if the non-fallback script fails | ||
println "Executing fallback script for project1 - script2" | ||
println "Executing fallback script for script2" |
1 change: 1 addition & 0 deletions
1
...r/groovyconsole/scripts/aecu/aecu-examples/generic-examples/runmode.author/script2.groovy
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 @@ | ||
println "Sample script2" |
2 changes: 2 additions & 0 deletions
2
...yconsole/scripts/aecu/aecu-examples/generic-examples/runmode.author/script3.always.groovy
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,2 @@ | ||
// scripts with always flag are executed on each deployment | ||
println "Sample script3" |
2 changes: 0 additions & 2 deletions
2
...ot/var/groovyconsole/scripts/aecu/aecu-examples/project1/migrations.author/script1.groovy
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...ot/var/groovyconsole/scripts/aecu/aecu-examples/project1/migrations.author/script2.groovy
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...ot/var/groovyconsole/scripts/aecu/aecu-examples/project1/migrations.author/script3.groovy
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...ot/var/groovyconsole/scripts/aecu/aecu-examples/project1/migrations.author/script4.groovy
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.