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
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public void savenReplicate(Object jsonGraphData,
ResourceResolver resolver,
Map<String, String> additionalConfigMap,
Resource urlResource,
ValueMap configDetailMap) throws RepositoryException,
ValueMap configDetailMap,
String cacheCleaningRequired) throws RepositoryException,
JsonProcessingException,
JSONException, PersistenceException,
ReplicationException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public class CDNDataAPIServiceImpl implements CDNDataAPIService {

@Reference
transient ResourceResolverFactory resolverFactory;

private String cacheCleaningRequired = "enable";

private static ObjectMapper mapperObject = new ObjectMapper()
.configure(FAIL_ON_MISSING_CREATOR_PROPERTIES, true);
Expand Down Expand Up @@ -162,6 +164,9 @@ private void updateSchemaAppCDNData(ResourceResolver resolver, Page page) {
String deploymentMethod = configDetailMap.get("deploymentMethod") != null
? (String) configDetailMap.get("deploymentMethod")
: StringUtils.EMPTY;
cacheCleaningRequired = configDetailMap.get("cacheCleaningRequired") != null
? (String) configDetailMap.get("cacheCleaningRequired")
: StringUtils.EMPTY;
Iterator<Page> childPages = page.listChildren(new PageFilter(), true);
String endpoint = ConfigurationUtil.getConfiguration(Constants.SCHEMAAPP_DATA_API_ENDPOINT_KEY,
Constants.API_ENDPOINT_CONFIG_PID, configurationAdmin, "");
Expand Down Expand Up @@ -335,7 +340,8 @@ private void save(ResourceResolver resolver,
resolver,
additionalConfigMap,
pageResource,
configDetailMap);
configDetailMap,
cacheCleaningRequired);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ private Node getDataNode(Node node)


@Override
public void savenReplicate(Object jsonGraphData, ResourceResolver resolver, Map<String, String> additionalConfigMap, Resource urlResource, ValueMap configDetailMap)
public void savenReplicate(Object jsonGraphData, ResourceResolver resolver, Map<String, String> additionalConfigMap, Resource urlResource,
ValueMap configDetailMap,
String cacheCleaningRequired)
throws RepositoryException, JsonProcessingException, JSONException, PersistenceException,
ReplicationException {
Node pageNode = urlResource.adaptTo(Node.class);
Expand All @@ -123,7 +125,9 @@ public void savenReplicate(Object jsonGraphData, ResourceResolver resolver, Map<
saveGraphDatatoNode(jsonGraphData, dataNode);
resolver.commit();
if (session != null) session.save();
flushService.invalidatePageJson(urlResource.getPath() + "/" +Constants.DATA);
if (StringUtils.isNotEmpty(cacheCleaningRequired) && cacheCleaningRequired.equalsIgnoreCase("enable")) {
flushService.invalidatePageJson(urlResource.getPath() + "/" +Constants.DATA);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void testReadCDNData() throws NoSuchFieldException, LoginException, IOException,
mockConnection();

cdnDataAPIServiceImpl.readCDNData();
verify(webhookHandlerService, times(1)).savenReplicate(any(), any(), any(), any(), any());
verify(webhookHandlerService, times(1)).savenReplicate(any(), any(), any(), any(), any(), any());
}

@Test
Expand All @@ -119,7 +119,7 @@ void testReadCDNDatawithJavaScript() throws NoSuchFieldException, LoginException
mockConnection();

cdnDataAPIServiceImpl.readCDNData();
verify(webhookHandlerService, times(1)).savenReplicate(any(), any(), any(), any(), any());
verify(webhookHandlerService, times(1)).savenReplicate(any(), any(), any(), any(), any(), any());
}

private void mockResource() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,35 @@
sling:resourceType="granite/ui/components/foundation/form/hidden"/>
</items>
</radiogroupA>
<radiogroupB
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/radiogroup"
required="{Boolean}true"
text="Dispatcher Cache Purge?"
fieldLabel="If enabled page updates will clear dispatcher cache within 30 minutes. If disabled markup is updated but the cache is not purged and only used when there is another cache clearing mechanism">
<items jcr:primaryType="nt:unstructured">
<option1
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/radio"
name="./cacheCleaningRequired"
text="Enable"
value="enable"/>
<option2
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/radio"
name="./cacheCleaningRequired"
text="Disable"
value="disable"/>
<radioDefaultValue jcr:primaryType="nt:unstructured"
name="./cacheCleaningRequired@DefaultValue"
value="enable"
sling:resourceType="granite/ui/components/foundation/form/hidden"/>
<radioDefaultWhenMissing jcr:primaryType="nt:unstructured"
name="./cacheCleaningRequired@UseDefaultWhenMissing"
value="true"
sling:resourceType="granite/ui/components/foundation/form/hidden"/>
</items>
</radiogroupB>
<connect
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/button"
Expand Down