Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Java CI with Maven

on:
push:
branches: [ master, r6.5.4 ]
pull_request:
branches: [ master, r6.5.4 ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn -B package --file pom.xml
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ For support oof previous AEM versions see Adobe [AEM documentation](https://help
* Start AEM 6.4.5 author instance
* Install the main connector content package `cq-commerce-demandware-content`
* Optionally install one of the sample content packages `cq-commerce-demandware-sample-content` or `cq-commerce-demandware-multi-sample-content`
* Configure the connector to connect to your Saleforce Commerce instance as described in the [project wiki](../../wiki).
* Configure the connector to connect to your Saleforce Commerce instance as described in the [docs](./docs/Home.md).

### Build

Expand Down
1 change: 1 addition & 0 deletions bundles/commerce/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
</executions>
<configuration>
<instructions>
<Bundle-Category>ecommerce</Bundle-Category>
<!-- Import any version of javax.inject, to allow running on multiple versions of AEM -->
<Import-Package>javax.inject;version=0.0.0,*</Import-Package>
<Sling-Model-Packages>
Expand Down
2 changes: 1 addition & 1 deletion bundles/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
</executions>
<configuration>
<instructions>
<Bundle-Category>cq5</Bundle-Category>
<Bundle-Category>ecommerce</Bundle-Category>
<Export-Package>
com.adobe.cq.commerce.demandware,
com.adobe.cq.commerce.demandware.components
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2019 Adobe Systems Incorporated
~ Copyright 2019 Adobe Systems Incorporated and others
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand All @@ -24,4 +24,8 @@ public DemandwareClientException() {
public DemandwareClientException(final String message) {
super(message);
}

public DemandwareClientException(final String message, final Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public interface DemandwareCommerceConstants {
String ATTR_DATA = "data";
String ATTR_MIMETYPE = "mimetype";
String ATTR_BASE64 = "base64";
String ATTR_LOCALE = "locale";

/**
* special, Demandware specify page properties which need to be mapped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
import javax.net.ssl.SSLContext;

import com.adobe.cq.commerce.demandware.DemandwareClientException;
import com.adobe.granite.crypto.CryptoSupport;

import org.apache.commons.lang3.StringUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.ConfigurationPolicy;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.PropertyOption;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.http.client.RedirectStrategy;
import org.apache.http.client.config.RequestConfig;
Expand Down Expand Up @@ -112,6 +115,9 @@ public class DemandwareClientImpl implements DemandwareClient {

@Property(label = "WebDAV user password")
private static final String WEBDAV_PASSWORD = "webdav.password";

@Reference
private CryptoSupport cryptoSupport;

private String instanceEndPoint;
private int socketTimeout;
Expand Down Expand Up @@ -282,7 +288,8 @@ public String getWebDavUserPassword() {
}

@Activate
protected void activate(Map<String, Object> config) {
protected void activate(Map<String, Object> config)
throws Exception {
instanceId = PropertiesUtil.toString(config.get(INSTANCE_ID), null);
instanceEndPoint = PropertiesUtil.toString(config.get(INSTANCE_ENDPOINT), null);
assetDownloadEndpoint = PropertiesUtil.toString(config.get(ASSET_DOWNLOAD_ENDPOINT),null);
Expand All @@ -296,7 +303,17 @@ protected void activate(Map<String, Object> config) {

webDavEndpoint = PropertiesUtil.toString(config.get(WEBDAV_ENDPOINT), null);
webDavUser = PropertiesUtil.toString(config.get(WEBDAV_USER), null);
webDavUserPassword = PropertiesUtil.toString(config.get(WEBDAV_PASSWORD), null);

String password = PropertiesUtil.toString(config.get(WEBDAV_PASSWORD), null);
if(this.cryptoSupport.isProtected(password))
{
webDavUserPassword= this.cryptoSupport.unprotect(password);
}
else
{
webDavUserPassword = password;
}

protocolInterface = PropertiesUtil.toString(config.get(PROTOCOL_INTERFACE), null);
protocolSSL = StringUtils.trimToNull(PropertiesUtil.toString(config.get(PROTOCOL_SSL), "TLSv1.2"));
keystoreType = StringUtils.trimToNull(PropertiesUtil.toString(config.get(KEYSTORE_TYPE), "JKS"));
Expand Down
5 changes: 5 additions & 0 deletions bundles/init/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Category>ecommerce,example</Bundle-Category>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
1 change: 1 addition & 0 deletions bundles/libs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Category>ecommerce</Bundle-Category>
<Embed-Dependency>
sardine,
ant,
Expand Down
5 changes: 5 additions & 0 deletions bundles/pim/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Category>ecommerce</Bundle-Category>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
9 changes: 4 additions & 5 deletions bundles/replication/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Category>cq5</Bundle-Category>
<Bundle-Category>ecommerce,publishing</Bundle-Category>
<Export-Package>
com.adobe.cq.commerce.demandware.replication
com.adobe.cq.commerce.demandware.replication,
com.adobe.cq.commerce.demandware.replication.content.attributemapping,
com.adobe.cq.commerce.demandware.replication.content.resolution
</Export-Package>
<Private-Package>
com.adobe.cq.commerce.demandware.replication.*
</Private-Package>
</instructions>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2019 Adobe Systems Incorporated and others
~
~ 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 com.adobe.cq.commerce.demandware.replication;

import com.adobe.cq.commerce.demandware.DemandwareClientException;

/**
* A general exception indicating something went wrong during a replication
* request.
*/
public class DemandwareReplicationException extends DemandwareClientException {

public DemandwareReplicationException(String message) {
super(message);
}

public DemandwareReplicationException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2019 Adobe Systems Incorporated and others
~
~ 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 com.adobe.cq.commerce.demandware.replication;

import org.apache.sling.api.resource.LoginException;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.Designate;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

import java.util.Map;

import static java.util.Collections.singletonMap;

/**
* <p>
* Central service to provide login to JCR for all replication related
* SFCC services.
*
* <p>
* <b>Note</b>: if a method named create* is called the caller is responsible for
* cleaning up resources. => close the resource resolver.
* For example:
*
* <pre>{@code
* try (final ResourceResolver resolver = replicationLogin.createResourceResolver) {
* ...
* } catch(DemandwareReplicationException dre) {
* ...
* }
* }</pre>
*/
@Component(service = DemandwareReplicationLoginService.class)
@Designate(ocd = DemandwareReplicationLoginService.Configuration.class)
public class DemandwareReplicationLoginService {

@Reference
private ResourceResolverFactory rrf;

private Configuration configuration;

/**
* Create a service resource resolver for replication services.
*
* Note: You are responsible to close this resolver.
*
* @return the service resource resolver
* @throws DemandwareReplicationException if login fails
*/
public ResourceResolver createResourceResolver() {
try {
final Map<String, Object> info = singletonMap(
ResourceResolverFactory.SUBSERVICE, configuration.subserviceId());
return rrf.getServiceResourceResolver(info);
} catch (final LoginException e) {
throw new DemandwareReplicationException(
"Failed to obtain resource resolver for subservice ID '" + configuration.subserviceId() + "'", e);
}
}

@Activate
private void activate(final Configuration configuration) {
this.configuration = configuration;
}

@ObjectClassDefinition(name = "Demandware replication resource resolver factory")
protected @interface Configuration {

@AttributeDefinition(
name = "Subservice ID",
description = "The subservice ID to use during login."
)
String subserviceId() default "replication";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

package com.adobe.cq.commerce.demandware.replication.content;

import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import com.adobe.cq.commerce.demandware.DemandwareCommerceConstants;
import com.adobe.cq.commerce.demandware.replication.ContentBuilderPlugin;
import com.day.cq.replication.ReplicationAction;
import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.JcrConstants;
import org.apache.sling.api.resource.Resource;
Expand All @@ -29,11 +27,9 @@
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.osgi.service.component.ComponentContext;

import com.adobe.cq.commerce.demandware.DemandwareCommerceConstants;
import com.adobe.cq.commerce.demandware.replication.ContentBuilderPlugin;
import com.day.cq.commons.inherit.HierarchyNodeInheritanceValueMap;
import com.day.cq.replication.ReplicationAction;
import com.day.cq.wcm.api.Page;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Abstract {@code ContentBuilderPlugin} sharing a common set a of methods used by most plugins.
Expand Down Expand Up @@ -91,32 +87,6 @@ protected JSONObject getJSONPayload(JSONObject delivery) {
return pageData;
}

/**
* Get the correct content language in the correct format to be used with OCAPI.
*
* @param page the current page
* @return the language for the give page
*/
protected final String getLanguage(final Page page) {
return StringUtils.isNotEmpty(
new HierarchyNodeInheritanceValueMap(page.getContentResource()).getInherited(JcrConstants.JCR_LANGUAGE,
String.class)) ? getFormattedLocale(page.getLanguage(false)) : null;
}

/**
* Format a Java locale for usage with Demandware OCAPI. The OCAPI accepts locale's formatted like "de-DE", using
* dash instead of underscore.
*
* @param locale the {@code Locale}
* @return the formatted locale string
*/
protected final String getFormattedLocale(final Locale locale) {
if (locale != null) {
return StringUtils.replaceChars(locale.toString(), "_", "-");
}
return null;
}

/**
* Create "default" JSON object used for Demandware JSON object
*
Expand Down
Loading