Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.3.10 #2279

Merged
merged 2 commits into from
Feb 22, 2025
Merged

0.3.10 #2279

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
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

4 changes: 0 additions & 4 deletions app.json

This file was deleted.

Empty file removed docs/.gitkeep
Empty file.
Binary file removed img/screenshots/turing-login.png
Binary file not shown.
Binary file removed img/screenshots/turing-se-edit.png
Binary file not shown.
Binary file removed img/screenshots/turing-se-new.png
Binary file not shown.
Binary file removed img/screenshots/turing-se.png
Binary file not shown.
Binary file removed img/screenshots/turing-sn-appearance.png
Binary file not shown.
Binary file removed img/screenshots/turing-sn-detail.png
Binary file not shown.
Binary file removed img/screenshots/turing-sn-field-detail.png
Binary file not shown.
Binary file removed img/screenshots/turing-sn-fields.png
Binary file not shown.
Binary file removed img/screenshots/turing-sn-new.png
Binary file not shown.
Binary file removed img/screenshots/turing-sn.png
Binary file not shown.
Binary file removed img/turing-diagram.png
Binary file not shown.
31 changes: 0 additions & 31 deletions qodana.yaml

This file was deleted.

1 change: 0 additions & 1 deletion system.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,11 @@

import java.util.*;

import static com.viglet.turing.connector.aem.commons.TurAemConstants.*;

@Slf4j
public class TurAemAttrProcess {
public static final String JCR_TITLE = "jcr:title";
public static final String CQ_TAGS = "cq:tags";
public static final String DEFAULT = "default";
public static final String TEXT = "text";
public static final String JCR = "jcr:";
public static final String JSON = ".json";
public static final String SLING = "sling:";


public static boolean hasCustomClass(TurAemTargetAttr targetAttr) {
return targetAttr.getSourceAttrs() == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static com.viglet.turing.connector.aem.commons.TurAemConstants.*;

@Slf4j
public class TurAemCommonsUtils {
private TurAemCommonsUtils() {
Expand All @@ -69,10 +71,7 @@ protected boolean removeEldestEntry(Map.Entry<String, String> eldest) {
return size() > MAX_CACHE_SIZE;
}
};
public static final String JCR_PRIMARY_TYPE = "jcr:primaryType";
public static final String JCR_CONTENT = "jcr:content";
public static final String JCR_TITLE = "jcr:title";
public static final String ONCE = "once";


public static boolean isTypeEqualContentType(JSONObject jsonObject, TurAemSourceContext turAemSourceContext) {
return jsonObject.has(JCR_PRIMARY_TYPE) &&
Expand Down Expand Up @@ -231,10 +230,10 @@ public static Optional<TurAemObject> getAemObject(String url, TurAemSourceContex

public static Optional<JSONObject> getInfinityJson(String url, TurAemSourceContext turAemSourceContext,
boolean cached) {
String infinityJsonUrl = String.format(url.endsWith(TurAemAttrProcess.JSON) ? "%s%s" : "%s%s.infinity.json",
String infinityJsonUrl = String.format(url.endsWith(JSON) ? "%s%s" : "%s%s.infinity.json",
turAemSourceContext.getUrl(), url);
return getResponseBody(infinityJsonUrl, turAemSourceContext, cached).map(responseBody -> {
if (isResponseBodyJSONArray(responseBody) && !url.endsWith(TurAemAttrProcess.JSON)) {
if (isResponseBodyJSONArray(responseBody) && !url.endsWith(JSON)) {
return getInfinityJson(new JSONArray(responseBody).toList().getFirst().toString(),
turAemSourceContext, cached);
} else if (isResponseBodyJSONObject(responseBody)) {
Expand Down Expand Up @@ -334,15 +333,15 @@ private static String basicAuth(String username, String password) {
}

public static void getJsonNodeToComponent(JSONObject jsonObject, StringBuilder components) {
if (jsonObject.has(TurAemAttrProcess.JCR_TITLE) && jsonObject.get(TurAemAttrProcess.JCR_TITLE)
if (jsonObject.has(JCR_TITLE) && jsonObject.get(JCR_TITLE)
instanceof String title) {
components.append(title);
} else if (jsonObject.has(TurAemAttrProcess.TEXT) && jsonObject.get(TurAemAttrProcess.TEXT)
} else if (jsonObject.has(TEXT) && jsonObject.get(TEXT)
instanceof String text) {
components.append(text);
}
jsonObject.toMap().forEach((key, value) -> {
if (!key.startsWith(TurAemAttrProcess.JCR) && !key.startsWith(TurAemAttrProcess.SLING)
if (!key.startsWith(JCR) && !key.startsWith(SLING)
&& (jsonObject.get(key) instanceof JSONObject jsonObjectNode)) {
getJsonNodeToComponent(jsonObjectNode, components);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
*
* Copyright (C) 2016-2025 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.viglet.turing.connector.aem.commons;

public class TurAemConstants {
public static final String JCR_TITLE = "jcr:title";
public static final String CQ_TAGS = "cq:tags";
public static final String DEFAULT = "default";
public static final String TEXT = "text";
public static final String JCR = "jcr:";
public static final String JSON = ".json";
public static final String SLING = "sling:";
public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
public static final String HTML = ".html";
public static final String ACTIVATE = "Activate";
public static final String CQ_LAST_REPLICATED_PUBLISH = "cq:lastReplicated_publish";
public static final String CQ_LAST_REPLICATED = "cq:lastReplicated";
public static final String JCR_PRIMARY_TYPE = "jcr:primaryType";
public static final String JCR_CONTENT = "jcr:content";
public static final String ONCE = "once";
public static final String CONTENT_FRAGMENT = "contentFragment";
public static final String CQ_LAST_REPLICATION_ACTION = "cq:lastReplicationAction";
public static final String CQ_LAST_REPLICATION_ACTION_PUBLISH = "cq:lastReplicationAction_publish";
public static final String CQ_LAST_MODIFIED = "cq:lastModified";
public static final String CQ_MODEL = "cq:model";
public static final String CQ_TEMPLATE = "cq:template";
public static final String DATA_FOLDER = "data";
public static final String DATE_JSON_FORMAT = "E MMM dd yyyy HH:mm:ss 'GMT'Z";
public static final String EMPTY_VALUE = "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,14 @@
import java.text.SimpleDateFormat;
import java.util.*;

import static com.viglet.turing.connector.aem.commons.TurAemConstants.*;
import static com.viglet.turing.connector.aem.commons.TurAemConstants.JCR_CONTENT;
import static java.time.ZoneOffset.UTC;
import static org.apache.jackrabbit.JcrConstants.*;

@Getter
@Slf4j
public class TurAemObject {
public static final String JCR_TITLE = "jcr:title";
public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
public static final String HTML = ".html";
public static final String ACTIVATE = "Activate";
public static final String CQ_LAST_REPLICATED_PUBLISH = "cq:lastReplicated_publish";
public static final String CQ_LAST_REPLICATED = "cq:lastReplicated";
private Calendar lastModified;
private Calendar createdDate;
private Calendar publicationDate;
Expand All @@ -53,16 +49,6 @@ public class TurAemObject {
private String template;
private String model;
private final Map<String, Object> attributes = new HashMap<>();

public static final String CONTENT_FRAGMENT = "contentFragment";
public static final String CQ_LAST_REPLICATION_ACTION = "cq:lastReplicationAction";
public static final String CQ_LAST_REPLICATION_ACTION_PUBLISH = "cq:lastReplicationAction_publish";
public static final String CQ_LAST_MODIFIED = "cq:lastModified";
public static final String CQ_MODEL = "cq:model";
public static final String CQ_TEMPLATE = "cq:template";
public static final String DATA_FOLDER = "data";
public static final String DATE_JSON_FORMAT = "E MMM dd yyyy HH:mm:ss 'GMT'Z";
public static final String EMPTY_VALUE = "";
public final SimpleDateFormat aemJsonDateFormat = new SimpleDateFormat(DATE_JSON_FORMAT, Locale.ENGLISH);

public TurAemObject(String nodePath, JSONObject jcrNode) {
Expand All @@ -72,42 +58,70 @@ public TurAemObject(String nodePath, JSONObject jcrNode) {
this.type = jcrNode.has(JCR_PRIMARYTYPE) ? jcrNode.getString(JCR_PRIMARYTYPE) : EMPTY_VALUE;
try {
if (jcrNode.has(JCR_CONTENT)) {
this.jcrContentNode = jcrNode.getJSONObject(JCR_CONTENT);
this.template = jcrContentNode.has(CQ_TEMPLATE) ? this.jcrContentNode.getString(CQ_TEMPLATE) : EMPTY_VALUE;
this.delivered = isActivated(CQ_LAST_REPLICATION_ACTION)
&& isActivated(CQ_LAST_REPLICATION_ACTION_PUBLISH);
this.title = jcrContentNode.has(JCR_TITLE) ? this.jcrContentNode.getString(JCR_TITLE) : EMPTY_VALUE;
if (TurAemCommonsUtils.hasProperty(this.jcrContentNode, CONTENT_FRAGMENT)) {
this.contentFragment = this.jcrContentNode.getBoolean(CONTENT_FRAGMENT);
}
getDataFolder(jcrContentNode);
Calendar lastModifiedCalendar = Calendar.getInstance();
if (this.jcrContentNode.has(JCR_LASTMODIFIED)) {
lastModifiedCalendar.setTime(aemJsonDateFormat.parse(this.jcrContentNode.getString(JCR_LASTMODIFIED)));
this.lastModified = lastModifiedCalendar;
} else if (this.jcrContentNode.has(CQ_LAST_MODIFIED)) {
lastModifiedCalendar.setTime(aemJsonDateFormat.parse(this.jcrContentNode.getString(CQ_LAST_MODIFIED)));
this.lastModified = lastModifiedCalendar;
}
Calendar publicationDateCalendar = Calendar.getInstance();
if (this.jcrContentNode.has(CQ_LAST_REPLICATED_PUBLISH)) {
publicationDateCalendar.setTime(aemJsonDateFormat.parse(this.jcrContentNode.getString(CQ_LAST_REPLICATED_PUBLISH)));
this.publicationDate = publicationDateCalendar;
} else if (this.jcrContentNode.has(CQ_LAST_REPLICATED)) {
lastModifiedCalendar.setTime(aemJsonDateFormat.parse(this.jcrContentNode.getString(CQ_LAST_REPLICATED)));
this.publicationDate = publicationDateCalendar;
}
processJcrContent(jcrNode);
}
if (jcrNode.has(JCR_CREATED)) {
Calendar createdDateCalendar = Calendar.getInstance();
createdDateCalendar.setTime(aemJsonDateFormat.parse(jcrNode.getString(JCR_CREATED)));
this.createdDate = createdDateCalendar;
processJcrCreated(jcrNode);
}
} catch (ParseException e) {
log.error(e.getMessage(), e);
}
}

private void processJcrCreated(JSONObject jcrNode) throws ParseException {
Calendar createdDateCalendar = Calendar.getInstance();
createdDateCalendar.setTime(aemJsonDateFormat.parse(jcrNode.getString(JCR_CREATED)));
this.createdDate = createdDateCalendar;
}

private void processJcrContent(JSONObject jcrNode) throws ParseException {
this.jcrContentNode = jcrNode.getJSONObject(JCR_CONTENT);
this.template = getJcrTemplate();
this.delivered = getJcrDelivered();
this.title = getJcrTitle();
this.contentFragment = isJcrContentFragment();
getDataFolder(jcrContentNode);
this.lastModified = getJcrLastModified();
this.publicationDate = getJcrPublicationDate();
}

private boolean isJcrContentFragment() {
return TurAemCommonsUtils.hasProperty(this.jcrContentNode, CONTENT_FRAGMENT) ?
this.jcrContentNode.getBoolean(CONTENT_FRAGMENT) :
(this.contentFragment = false);
}

private boolean getJcrDelivered() {
return isActivated(CQ_LAST_REPLICATION_ACTION)
&& isActivated(CQ_LAST_REPLICATION_ACTION_PUBLISH);
}

private String getJcrTemplate() {
return jcrContentNode.has(CQ_TEMPLATE) ? this.jcrContentNode.getString(CQ_TEMPLATE) : EMPTY_VALUE;
}

private String getJcrTitle() {
return jcrContentNode.has(JCR_TITLE) ? this.jcrContentNode.getString(JCR_TITLE) : EMPTY_VALUE;
}

private Calendar getJcrPublicationDate() throws ParseException {
return getCalendar(CQ_LAST_REPLICATED_PUBLISH, CQ_LAST_REPLICATED);
}

private Calendar getCalendar(String cqLastReplicatedPublish, String cqLastReplicated) throws ParseException {
Calendar calendar = Calendar.getInstance();
if (this.jcrContentNode.has(cqLastReplicatedPublish)) {
calendar.setTime(aemJsonDateFormat.parse(this.jcrContentNode.getString(cqLastReplicatedPublish)));
} else if (this.jcrContentNode.has(cqLastReplicated)) {
calendar.setTime(aemJsonDateFormat.parse(this.jcrContentNode.getString(cqLastReplicated)));
}
return calendar;
}

private Calendar getJcrLastModified() throws ParseException {
return getCalendar(JCR_LASTMODIFIED, CQ_LAST_MODIFIED);
}

private boolean isActivated(String attribute) {
return jcrContentNode.has(attribute) && this.jcrContentNode.getString(attribute).equals(ACTIVATE);
}
Expand Down
8 changes: 8 additions & 0 deletions turing-aem/aem-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@
<mainClass>com.viglet.turing.connector.plugin.aem.TurAemPlugin</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,26 +163,6 @@ private TurSNSiteFieldExt saveSNSiteFieldExt(TurSNSite turSNSite, TurSNSiteField
.turSNSite(turSNSite).build());
}

private void addTurSNSiteFieldExt(TurSNFieldType turSNFieldType, TurSNSite turSNSite,
List<TurSNSiteFieldExt> turSNSiteFieldExtList) {
turSNSiteFieldExtList.add(turSNSiteFieldExtRepository.save(TurSNSiteFieldExt.builder()
.enabled(0)
.facet(0)
.facetRange(TurSNSiteFacetRangeEnum.DISABLED)
.facetType(TurSNSiteFacetFieldEnum.DEFAULT)
.facetItemType(TurSNSiteFacetFieldEnum.DEFAULT)
.facetSort(TurSNSiteFacetFieldSortEnum.COUNT)
.secondaryFacet(false)
.showAllFacetItems(false)
.hl(0)
.multiValued(1)
.facetPosition(0)
.mlt(0)
.snType(turSNFieldType)
.type(TurSEFieldType.STRING)
.turSNSite(turSNSite).build()));
}

@Operation(summary = "Show a Semantic Navigation Site Field Ext")
@GetMapping("/{id}")
public TurSNSiteFieldExt turSNSiteFieldExtGet(@PathVariable String ignoredSnSiteId, @PathVariable String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private boolean index(TurSNJobItem turSNJobItem, TurSNSite turSNSite) {
log.debug("Index");
Map<String, Object> attributes = this.removeDuplicateTerms(
turSNMergeProvidersProcess.mergeDocuments(turSNSite,
getConsolidateResults(turSNJobItem, turSNSite),
getConsolidateResults(turSNJobItem),
turSNJobItem.getLocale()));
createMissingFields(turSNSite, turSNJobItem.getSpecs());
return turSolrInstanceProcess.initSolrInstance(turSNSite.getName(),
Expand Down Expand Up @@ -285,7 +285,7 @@ private boolean existsFieldInSearchEngine(TurSNSite turSNSite, String coreName,
return TurSolrUtils.existsField(turSNSite.getTurSEInstance(), coreName, name);
}

private Map<String, Object> getConsolidateResults(TurSNJobItem turSNJobItem, TurSNSite turSNSite) {
private Map<String, Object> getConsolidateResults(TurSNJobItem turSNJobItem) {
Map<String, Object> consolidateResults = new HashMap<>();
Optional.ofNullable(turSNJobItem.getAttributes()).ifPresent(attributes ->
attributes.forEach((key, value1) -> {
Expand Down
26 changes: 0 additions & 26 deletions turing-app/src/main/java/com/viglet/turing/genai/TurAssistant.java

This file was deleted.

Loading
Loading