Skip to content

Commit

Permalink
AEM: use tool as method parameter for extension
Browse files Browse the repository at this point in the history
  • Loading branch information
alegauss committed Feb 17, 2024
1 parent 90913e6 commit e5b1545
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private TurCmsTargetAttrValueList process(TurCmsContext context,
return TurCmsTargetAttrValueList.singleItem(context.getTurCmsTargetAttr());
} else {
return hasCustomClass(context) ?
attributeByClass(context) :
attributeByClass(context, turAEMIndexerTool) :
attributeByCMS(context, turSNAttributeSpecList, turAEMIndexerTool);
}
}
Expand Down Expand Up @@ -240,7 +240,7 @@ private TurCmsTargetAttrValueList addValuesToAttributes(TurCmsTargetAttr turCmsT
return new TurCmsTargetAttrValueList();
}

private TurCmsTargetAttrValueList attributeByClass(TurCmsContext context) {
private TurCmsTargetAttrValueList attributeByClass(TurCmsContext context, TurAEMIndexerTool turAEMIndexerTool) {
String className = context.getTurCmsSourceAttr().getClassName();
log.debug(STR."ClassName : \{className}");
try {
Expand All @@ -249,7 +249,7 @@ private TurCmsTargetAttrValueList attributeByClass(TurCmsContext context) {
((ExtAttributeInterface) Objects.requireNonNull(Class.forName(className)
.getDeclaredConstructor().newInstance()))
.consume(context.getTurCmsTargetAttr(), context.getTurCmsSourceAttr(),
(AemObject) context.getCmsObjectInstance(), context.getConfiguration()));
(AemObject) context.getCmsObjectInstance(), context.getConfiguration(), turAEMIndexerTool));
} catch (InstantiationException | IllegalAccessException | InvocationTargetException |
NoSuchMethodException | ClassNotFoundException e) {
log.error(e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.viglet.turing.connector.aem.indexer.ext;

import com.viglet.turing.connector.aem.indexer.AemObject;
import com.viglet.turing.connector.aem.indexer.TurAEMIndexerTool;
import com.viglet.turing.connector.cms.beans.TurMultiValue;
import com.viglet.turing.connector.cms.config.IHandlerConfiguration;
import com.viglet.turing.connector.cms.mappers.TurCmsSourceAttr;
import com.viglet.turing.connector.cms.mappers.TurCmsTargetAttr;

public interface ExtAttributeInterface {
TurMultiValue consume (TurCmsTargetAttr turCmsTargetAttr, TurCmsSourceAttr turCmsSourceAttr,
AemObject aemObject, IHandlerConfiguration config);
AemObject aemObject, IHandlerConfiguration config, TurAEMIndexerTool turAEMIndexerTool);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.viglet.turing.connector.aem.indexer.ext;

import com.viglet.turing.connector.aem.indexer.AemObject;
import com.viglet.turing.connector.aem.indexer.TurAEMIndexerTool;
import com.viglet.turing.connector.cms.beans.TurMultiValue;
import com.viglet.turing.connector.cms.config.IHandlerConfiguration;
import com.viglet.turing.connector.cms.mappers.TurCmsSourceAttr;
Expand All @@ -12,7 +13,7 @@
public class TurAEMCreationDate implements ExtAttributeInterface {
@Override
public TurMultiValue consume(TurCmsTargetAttr turCmsTargetAttr, TurCmsSourceAttr turCmsSourceAttr,
AemObject aemObject, IHandlerConfiguration config) {
AemObject aemObject, IHandlerConfiguration config, TurAEMIndexerTool turAEMIndexerTool) {
log.debug("Executing TurAEMCreationDate");
return Optional.ofNullable(aemObject.getCreatedDate()).map(createdDate ->
TurMultiValue.singleItem(createdDate.getTime())).orElse(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.viglet.turing.connector.aem.indexer.ext;

import com.viglet.turing.connector.aem.indexer.AemObject;
import com.viglet.turing.connector.aem.indexer.TurAEMIndexerTool;
import com.viglet.turing.connector.cms.beans.TurMultiValue;
import com.viglet.turing.connector.cms.config.IHandlerConfiguration;
import com.viglet.turing.connector.cms.mappers.TurCmsSourceAttr;
Expand All @@ -12,7 +13,7 @@
public class TurAEMModificationDate implements ExtAttributeInterface {
@Override
public TurMultiValue consume(TurCmsTargetAttr turCmsTargetAttr, TurCmsSourceAttr turCmsSourceAttr,
AemObject aemObject, IHandlerConfiguration config) {
AemObject aemObject, IHandlerConfiguration config, TurAEMIndexerTool turAEMIndexerTool) {
log.debug("Executing TurAEMModificationDate");
return Optional.ofNullable(aemObject.getLastModified())
.map(lastModified -> TurMultiValue.singleItem(lastModified.getTime())).orElse(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.viglet.turing.connector.aem.indexer.ext;

import com.viglet.turing.connector.aem.indexer.AemObject;
import com.viglet.turing.connector.aem.indexer.TurAEMIndexerTool;
import com.viglet.turing.connector.cms.beans.TurMultiValue;
import com.viglet.turing.connector.cms.config.IHandlerConfiguration;
import com.viglet.turing.connector.cms.mappers.TurCmsSourceAttr;
Expand All @@ -10,7 +11,7 @@
public class TurCTDName implements ExtAttributeInterface {
@Override
public TurMultiValue consume(TurCmsTargetAttr turCmsTargetAttr, TurCmsSourceAttr turCmsSourceAttr,
AemObject aemObject, IHandlerConfiguration config) {
AemObject aemObject, IHandlerConfiguration config, TurAEMIndexerTool turAEMIndexerTool) {
log.debug("Executing TurCTDName");
return TurMultiValue.singleItem(aemObject.getType());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.viglet.turing.connector.aem.indexer.ext;

import com.viglet.turing.connector.aem.indexer.AemObject;
import com.viglet.turing.connector.aem.indexer.TurAEMIndexerTool;
import com.viglet.turing.connector.cms.beans.TurMultiValue;
import com.viglet.turing.connector.cms.config.IHandlerConfiguration;
import com.viglet.turing.connector.cms.mappers.TurCmsSourceAttr;
Expand All @@ -12,7 +13,7 @@ public class TurContentId implements ExtAttributeInterface {

@Override
public TurMultiValue consume(TurCmsTargetAttr turCmsTargetAttr, TurCmsSourceAttr turCmsSourceAttr,
AemObject aemObject, IHandlerConfiguration config) {
AemObject aemObject, IHandlerConfiguration config, TurAEMIndexerTool turAEMIndexerTool) {
log.debug("Executing TurContentUrl");
return TurMultiValue
.singleItem(String.format(aemObject.getPath()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.viglet.turing.connector.aem.indexer.ext;

import com.viglet.turing.connector.aem.indexer.AemObject;
import com.viglet.turing.connector.aem.indexer.TurAEMIndexerTool;
import com.viglet.turing.connector.cms.beans.TurMultiValue;
import com.viglet.turing.connector.cms.config.IHandlerConfiguration;
import com.viglet.turing.connector.cms.mappers.TurCmsSourceAttr;
Expand All @@ -13,7 +14,7 @@ public static String getURL(AemObject aemObject, IHandlerConfiguration config) {
}
@Override
public TurMultiValue consume(TurCmsTargetAttr turCmsTargetAttr, TurCmsSourceAttr turCmsSourceAttr,
AemObject aemObject, IHandlerConfiguration config) {
AemObject aemObject, IHandlerConfiguration config, TurAEMIndexerTool turAEMIndexerTool) {
log.debug("Executing TurContentUrl");
return TurMultiValue
.singleItem(getURL(aemObject, config));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package com.viglet.turing.connector.aem.indexer.ext;

import com.viglet.turing.connector.aem.indexer.AemObject;
import com.viglet.turing.connector.aem.indexer.TurAEMIndexerTool;
import com.viglet.turing.connector.cms.beans.TurMultiValue;
import com.viglet.turing.connector.cms.config.IHandlerConfiguration;
import com.viglet.turing.connector.cms.mappers.TurCmsSourceAttr;
Expand All @@ -33,7 +34,7 @@ public class TurHTML2Text implements ExtAttributeInterface {
private static final String EMPTY_STRING = "";
@Override
public TurMultiValue consume(TurCmsTargetAttr turCmsTargetAttr, TurCmsSourceAttr turCmsSourceAttr,
AemObject aemObject, IHandlerConfiguration config) {
AemObject aemObject, IHandlerConfiguration config, TurAEMIndexerTool turAEMIndexerTool) {
log.debug("Executing HTML2Text");
if (turCmsSourceAttr.getName() != null && aemObject != null && aemObject.getAttributes() != null
&& aemObject.getAttributes().containsKey(turCmsSourceAttr.getName())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.viglet.turing.connector.aem.indexer.ext;

import com.viglet.turing.connector.aem.indexer.AemObject;
import com.viglet.turing.connector.aem.indexer.TurAEMIndexerTool;
import com.viglet.turing.connector.aem.indexer.TurAemUtils;
import com.viglet.turing.connector.cms.beans.TurMultiValue;
import com.viglet.turing.connector.cms.config.IHandlerConfiguration;
import com.viglet.turing.connector.cms.mappers.TurCmsSourceAttr;
import com.viglet.turing.connector.cms.mappers.TurCmsTargetAttr;
import com.viglet.turing.connector.cms.util.HtmlManipulator;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;

@Slf4j
Expand All @@ -18,8 +20,13 @@ public class TurPageComponents implements ExtAttributeInterface {

@Override
public TurMultiValue consume(TurCmsTargetAttr turCmsTargetAttr, TurCmsSourceAttr turCmsSourceAttr,
AemObject aemObject, IHandlerConfiguration config) {
AemObject aemObject, IHandlerConfiguration config, TurAEMIndexerTool turAEMIndexerTool) {
log.debug("Executing TurPageComponents");
return getResponsiveGridContent(aemObject);
}

@NotNull
public static TurMultiValue getResponsiveGridContent(AemObject aemObject) {
StringBuffer components = new StringBuffer();
if(aemObject.getJcrContentNode() != null && aemObject.getJcrContentNode().has(ROOT)
&& aemObject.getJcrContentNode().get(ROOT) instanceof JSONObject root
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.viglet.turing.connector.aem.indexer.ext;

import com.viglet.turing.connector.aem.indexer.AemObject;
import com.viglet.turing.connector.aem.indexer.TurAEMIndexerTool;
import com.viglet.turing.connector.cms.beans.TurMultiValue;
import com.viglet.turing.connector.cms.config.IHandlerConfiguration;
import com.viglet.turing.connector.cms.mappers.TurCmsSourceAttr;
Expand All @@ -12,7 +13,7 @@ public class TurSiteName implements ExtAttributeInterface {

@Override
public TurMultiValue consume(TurCmsTargetAttr turCmsTargetAttr, TurCmsSourceAttr turCmsSourceAttr,
AemObject aemObject, IHandlerConfiguration config) {
AemObject aemObject, IHandlerConfiguration config, TurAEMIndexerTool turAEMIndexerTool) {
log.debug("Executing TurSiteName");
return TurMultiValue.singleItem(EMPTY_STRING);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.viglet.turing.connector.aem.indexer.ext;

import com.viglet.turing.connector.aem.indexer.AemObject;
import com.viglet.turing.connector.aem.indexer.TurAEMIndexerTool;
import com.viglet.turing.connector.cms.beans.TurMultiValue;
import com.viglet.turing.connector.cms.config.IHandlerConfiguration;
import com.viglet.turing.connector.cms.mappers.TurCmsSourceAttr;
Expand All @@ -10,7 +11,7 @@
public class TurSourceApps implements ExtAttributeInterface {
@Override
public TurMultiValue consume(TurCmsTargetAttr turCmsTargetAttr, TurCmsSourceAttr turCmsSourceAttr,
AemObject aemObject, IHandlerConfiguration config) {
AemObject aemObject, IHandlerConfiguration config, TurAEMIndexerTool turAEMIndexerTool) {
log.debug("Executing TurSourceApps");
return TurMultiValue.singleItem(config.getProviderName());
}
Expand Down

0 comments on commit e5b1545

Please sign in to comment.