From 1ca70afd59247b220da08be19de55cdc3c75bd06 Mon Sep 17 00:00:00 2001 From: Jim Moore Date: Thu, 18 Jun 2015 12:44:41 -0600 Subject: [PATCH 1/3] Changed to support AEM 6.1 --- .gitignore | 1 + .java-version | 1 + build.gradle | 13 ++--- gradle/wrapper/gradle-wrapper.properties | 2 +- .../twcable/jackalope/impl/cq/PageImpl.java | 12 +++++ .../jackalope/impl/cq/PageManagerImpl.java | 47 +++++++++++++++++++ .../impl/sling/NodeResourceImpl.java | 5 +- .../sling/SimpleResourceResolverFactory.java | 11 +++++ 8 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 .java-version diff --git a/.gitignore b/.gitignore index e5008f7..a78fa30 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ build/ *.iws out/ atlassian-ide-plugin.xml +*.jar diff --git a/.java-version b/.java-version new file mode 100644 index 0000000..6259340 --- /dev/null +++ b/.java-version @@ -0,0 +1 @@ +1.8 diff --git a/build.gradle b/build.gradle index 6547bab..39d6793 100644 --- a/build.gradle +++ b/build.gradle @@ -23,6 +23,9 @@ repositories { maven { url "http://repo.adobe.com/nexus/content/groups/public" } + + // hack to allow getting to a working version of AEM 6.1 uberjar without running afoul of licensing restrictions + flatDir { dirs '.' } } sourceCompatibility = '1.7' @@ -32,15 +35,13 @@ targetCompatibility = '1.7' dependencies { // AEM's new "uber-jar" - compile "com.adobe.aem:aem-api:6.0.0.1", { - exclude group: "org.slf4j", module: "slf4j-simple" - exclude group: "com.adobe.cq.testing", module: "cq-integration-testing" - } +// compile "com.adobe.aem:uber-jar:6.1.0" // broken + compile name: "uberjar-6.1" // install into the top-level dir of project compile "javax.jcr:jcr:2.0" compile "com.google.guava:guava:15.0" - compile "org.apache.sling:org.apache.sling.jcr.resource:2.3.8" - compile "org.slf4j:slf4j-api:1.6.6" + compile "org.apache.sling:org.apache.sling.jcr.resource:2.5.0" + compile "org.slf4j:slf4j-api:1.7.6" compile "javax.servlet:servlet-api:2.5" compile "commons-io:commons-io:2.4" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c93c687..ad9d71b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,2 +1,2 @@ #Tue Feb 24 15:51:41 MST 2015 -distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-bin.zip diff --git a/src/main/java/com/twcable/jackalope/impl/cq/PageImpl.java b/src/main/java/com/twcable/jackalope/impl/cq/PageImpl.java index e5ffe77..011d8f0 100644 --- a/src/main/java/com/twcable/jackalope/impl/cq/PageImpl.java +++ b/src/main/java/com/twcable/jackalope/impl/cq/PageImpl.java @@ -216,6 +216,18 @@ public Calendar getOffTime() { } + @Override + public Calendar getDeleted() { + throw new UnsupportedOperationException(); + } + + + @Override + public String getDeletedBy() { + throw new UnsupportedOperationException(); + } + + @Override public String getLastModifiedBy() { ValueMap properties = getProperties(); diff --git a/src/main/java/com/twcable/jackalope/impl/cq/PageManagerImpl.java b/src/main/java/com/twcable/jackalope/impl/cq/PageManagerImpl.java index 4e2c772..b9f7f13 100644 --- a/src/main/java/com/twcable/jackalope/impl/cq/PageManagerImpl.java +++ b/src/main/java/com/twcable/jackalope/impl/cq/PageManagerImpl.java @@ -124,16 +124,63 @@ public Page create(String parentPath, String pageName, String template, String t @Override public Page move(Page page, String destination, String beforeName, boolean shallow, boolean resolveConflicts, String[] adjustRefs) throws WCMException { + return this.move(page, destination, beforeName, shallow, resolveConflicts, adjustRefs, null); + } + + + /** + * Moves the given page to the new destination and automatically saves the changes. + * If source and destination are equals the page is just ordered. + * + * @param page the page to move + * @param destination the path of the new destination + * @param beforeName the name of the next page. if null the page is ordered at the end. + * @param shallow if true only the page content is moved + * @param resolveConflict if true resolves name conflict if destination already exists. + * @param adjustRefs list of paths to pages that refer to the moved one. those references will be adjusted. + * @param publishRefs list of referencing paths that will be republished. + * @return the new page at the new location + * @throws WCMException if an error during this operation occurs. + */ + @Override + public Page move(Page page, String destination, String beforeName, boolean shallow, boolean resolveConflict, + String[] adjustRefs, String[] publishRefs) throws WCMException { throw new UnsupportedOperationException(); } @Override public Resource move(Resource resource, String destination, String beforeName, boolean shallow, boolean resolveConflicts, String[] adjustRefs) throws WCMException { + return this.move(resource, destination, beforeName, shallow, resolveConflicts, adjustRefs, null); + } + + + /** + * Moves the given resource to the new destination and automatically saves the changes. + * If source and destination are equals the resource is just ordered. + * + * @param resource the resource to move + * @param destination the path of the new destination + * @param beforeName the name of the next page. if null the page is ordered at the end. + * @param shallow if true only the resource content is moved. + * @param resolveConflict if true resolves name conflict if destination already exists. + * @param adjustRefs list of paths to pages that refer to the moved one. those references will be adjusted. + * @param publishRefs list of referencing paths that will be republished. + * @return the new page at the new location + * @throws WCMException if an error during this operation occurs. + */ + @Override + public Resource move(Resource resource, String destination, String beforeName, boolean shallow, boolean resolveConflict, String[] adjustRefs, String[] publishRefs) throws WCMException { throw new UnsupportedOperationException(); } + @Override + public Resource copy(CopyOptions copyOptions) throws WCMException { + return copy(copyOptions.resource, copyOptions.destination, copyOptions.beforeName, copyOptions.shallow, copyOptions.resolveConflict, copyOptions.autoSave); + } + + @Override public Page copy(Page page, String destination, String beforeName, boolean shallow, boolean resolveConflict) throws WCMException { return copy(page, destination, beforeName, shallow, resolveConflict, false); diff --git a/src/main/java/com/twcable/jackalope/impl/sling/NodeResourceImpl.java b/src/main/java/com/twcable/jackalope/impl/sling/NodeResourceImpl.java index 823a9c8..264d74a 100644 --- a/src/main/java/com/twcable/jackalope/impl/sling/NodeResourceImpl.java +++ b/src/main/java/com/twcable/jackalope/impl/sling/NodeResourceImpl.java @@ -29,9 +29,9 @@ import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.api.resource.ResourceUtil; import org.apache.sling.api.resource.ValueMap; +import org.apache.sling.api.wrappers.ModifiableValueMapDecorator; import org.apache.sling.jcr.resource.JcrModifiablePropertyMap; import org.apache.sling.jcr.resource.JcrPropertyMap; -import org.apache.sling.jcr.resource.internal.JcrModifiableValueMap; import javax.jcr.Node; import javax.jcr.Property; @@ -132,7 +132,8 @@ public AdapterType adaptTo(Class type) { if (type.equals(Node.class)) return (AdapterType)node; if (type.equals(ValueMap.class) || type.equals(Map.class)) return (AdapterType)new JcrPropertyMap(node); if (type.equals(PersistableValueMap.class)) return (AdapterType)new JcrModifiablePropertyMap(node); - if (type.equals(ModifiableValueMap.class)) return (AdapterType)new JcrModifiableValueMap(node, null); + if (type.equals(ModifiableValueMap.class)) + return (AdapterType)new ModifiableValueMapDecorator(new JcrModifiablePropertyMap(node, null)); if (type.equals(Page.class)) { try { diff --git a/src/main/java/com/twcable/jackalope/impl/sling/SimpleResourceResolverFactory.java b/src/main/java/com/twcable/jackalope/impl/sling/SimpleResourceResolverFactory.java index 20a783d..8ece3ad 100644 --- a/src/main/java/com/twcable/jackalope/impl/sling/SimpleResourceResolverFactory.java +++ b/src/main/java/com/twcable/jackalope/impl/sling/SimpleResourceResolverFactory.java @@ -21,6 +21,7 @@ import org.apache.sling.api.resource.ResourceResolverFactory; import org.apache.sling.jcr.api.SlingRepository; +import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import java.util.Map; @@ -37,21 +38,31 @@ public SimpleResourceResolverFactory(@Nonnull SlingRepository repository) { } + @Nonnull @Override public ResourceResolver getResourceResolver(Map authenticationInfo) throws LoginException { return this.resourceResolver; } + @Nonnull @Override public ResourceResolver getAdministrativeResourceResolver(Map authenticationInfo) throws LoginException { return this.resourceResolver; } + @Nonnull @Override public ResourceResolver getServiceResourceResolver(Map authenticationInfo) throws LoginException { return this.resourceResolver; } + + @Override + @CheckForNull + public ResourceResolver getThreadResourceResolver() { + return this.resourceResolver; + } + } From 2264af231173f3b20d685a501e774c9f3fe52d6a Mon Sep 17 00:00:00 2001 From: Brett Birschbach Date: Fri, 28 Oct 2016 11:37:31 -0500 Subject: [PATCH 2/3] Add support for AEM-6.2. --- build.gradle | 11 +++-------- gradle.properties | 2 +- .../com/twcable/jackalope/impl/cq/AssetImpl.java | 15 +++++++++++++++ .../com/twcable/jackalope/impl/cq/PageImpl.java | 4 ++-- .../jackalope/impl/jcr/RepositoryImpl.java | 5 +++++ .../impl/sling/ResourceResolverImpl.java | 15 +++++++++++++++ .../jackalope/impl/sling/SlingRepositoryImpl.java | 7 +++++++ 7 files changed, 48 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 39d6793..1fecb9d 100644 --- a/build.gradle +++ b/build.gradle @@ -23,20 +23,15 @@ repositories { maven { url "http://repo.adobe.com/nexus/content/groups/public" } - - // hack to allow getting to a working version of AEM 6.1 uberjar without running afoul of licensing restrictions - flatDir { dirs '.' } } -sourceCompatibility = '1.7' -targetCompatibility = '1.7' +sourceCompatibility = '1.8' +targetCompatibility = '1.8' dependencies { - // AEM's new "uber-jar" -// compile "com.adobe.aem:uber-jar:6.1.0" // broken - compile name: "uberjar-6.1" // install into the top-level dir of project + compile "com.adobe.aem:uber-jar:6.2.0:apis" compile "javax.jcr:jcr:2.0" compile "com.google.guava:guava:15.0" diff --git a/gradle.properties b/gradle.properties index 511c02a..c7b0f8e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ # suppress inspection "UnusedProperty" for whole file description = Provides a convenient way of stubbing out Sling and the JCR group = com.twcable.jackalope -version = 3.0.2 +version = 4.0.0 diff --git a/src/main/java/com/twcable/jackalope/impl/cq/AssetImpl.java b/src/main/java/com/twcable/jackalope/impl/cq/AssetImpl.java index 63ded89..5c9c12f 100644 --- a/src/main/java/com/twcable/jackalope/impl/cq/AssetImpl.java +++ b/src/main/java/com/twcable/jackalope/impl/cq/AssetImpl.java @@ -65,6 +65,11 @@ public Rendition getRendition(String s) { return null; } + @Override + public Rendition getImagePreviewRendition() { + throw new UnsupportedOperationException(); + } + @Override public Rendition getOriginal() { @@ -191,6 +196,16 @@ public boolean isBatchMode() { return false; } + @Override + public String getMetadataValueFromJcr(String s) { + throw new UnsupportedOperationException(); + } + + @Override + public String getID() { + throw new UnsupportedOperationException(); + } + @Override public String getMetadataValue(String s) { diff --git a/src/main/java/com/twcable/jackalope/impl/cq/PageImpl.java b/src/main/java/com/twcable/jackalope/impl/cq/PageImpl.java index 846e240..b223278 100644 --- a/src/main/java/com/twcable/jackalope/impl/cq/PageImpl.java +++ b/src/main/java/com/twcable/jackalope/impl/cq/PageImpl.java @@ -220,13 +220,13 @@ public Calendar getOffTime() { @Override public Calendar getDeleted() { - throw new UnsupportedOperationException(); + return this.getProperties().get("deleted", Calendar.class); } @Override public String getDeletedBy() { - throw new UnsupportedOperationException(); + return this.getProperties().get("deletedBy", String.class); } diff --git a/src/main/java/com/twcable/jackalope/impl/jcr/RepositoryImpl.java b/src/main/java/com/twcable/jackalope/impl/jcr/RepositoryImpl.java index ca05961..f22d5cb 100644 --- a/src/main/java/com/twcable/jackalope/impl/jcr/RepositoryImpl.java +++ b/src/main/java/com/twcable/jackalope/impl/jcr/RepositoryImpl.java @@ -115,4 +115,9 @@ public Session loginService(String s, String s1) throws LoginException, Reposito return session; } + @Override + public Session impersonateFromService(String s, Credentials credentials, String s1) throws LoginException, RepositoryException { + throw new UnsupportedOperationException(); + } + } diff --git a/src/main/java/com/twcable/jackalope/impl/sling/ResourceResolverImpl.java b/src/main/java/com/twcable/jackalope/impl/sling/ResourceResolverImpl.java index 281a03c..3c0afe5 100644 --- a/src/main/java/com/twcable/jackalope/impl/sling/ResourceResolverImpl.java +++ b/src/main/java/com/twcable/jackalope/impl/sling/ResourceResolverImpl.java @@ -129,6 +129,11 @@ public Iterator listChildren(Resource parent) { return parent.listChildren(); } + @Override + public Resource getParent(@Nonnull Resource resource) { + return resource.getParent(); + } + @Override public Iterable getChildren(Resource resource) { @@ -295,6 +300,16 @@ public boolean isResourceType(Resource resource, String resourceType) { public void refresh() { } + @Override + public Resource copy(String s, String s1) throws PersistenceException { + throw new UnsupportedOperationException(); + } + + @Override + public Resource move(String s, String s1) throws PersistenceException { + throw new UnsupportedOperationException(); + } + @Override @SuppressWarnings("unchecked") diff --git a/src/main/java/com/twcable/jackalope/impl/sling/SlingRepositoryImpl.java b/src/main/java/com/twcable/jackalope/impl/sling/SlingRepositoryImpl.java index 22b9c70..1b0dcfb 100644 --- a/src/main/java/com/twcable/jackalope/impl/sling/SlingRepositoryImpl.java +++ b/src/main/java/com/twcable/jackalope/impl/sling/SlingRepositoryImpl.java @@ -19,6 +19,8 @@ import com.twcable.jackalope.impl.jcr.RepositoryImpl; import org.apache.sling.jcr.api.SlingRepository; +import javax.jcr.Credentials; +import javax.jcr.LoginException; import javax.jcr.RepositoryException; import javax.jcr.Session; @@ -35,4 +37,9 @@ public Session loginAdministrative(String workspace) throws RepositoryException return login(); } + @Override + public Session impersonateFromService(String s, Credentials credentials, String s1) throws LoginException, RepositoryException { + throw new UnsupportedOperationException(); + } + } From ae5d2a4858f99b586a25ab344abc546bc9ea9ee9 Mon Sep 17 00:00:00 2001 From: Brett Birschbach Date: Fri, 28 Oct 2016 11:46:26 -0500 Subject: [PATCH 3/3] Updated release notes/README to reflect new 4.0.0 version for AEM 6.2 --- README.md | 2 +- RELEASE_NOTES.md | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b78e6fd..c30f3a4 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ repositories { } } -testCompile 'com.twcable.jackalope:jackalope:3.0.2' +testCompile 'com.twcable.jackalope:jackalope:4.0.0' ``` # Releasing diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 0e3b951..868b1f8 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,8 @@ # RELEASE NOTES +## 4.0.0 +* Updated to support AEM 6.2, from AEM 6.0 + ## 3.0.2 Bug fixes: