Last active
November 29, 2022 18:08
-
-
Save hi-ko/a39a0d1b4c2ed2009865ba294e5c5a56 to your computer and use it in GitHub Desktop.
Alfresco Javascript Console Recipes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getGlobalPropertyValue(propertyValue){ | |
var ctxt = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext(); | |
var globalProperties = ctxt.getBean('global-properties', Packages.java.util.Properties); | |
var placeholderHelper = new Packages.org.springframework.util.PropertyPlaceholderHelper('${', '}', ':', true); | |
var propertyValue = globalProperties[propertyValue]; | |
if (propertyValue){ | |
propertyValue = placeholderHelper.replacePlaceholders(propertyValue, globalProperties); | |
} | |
return propertyValue; | |
} | |
logger.log(getGlobalPropertyValue("share.host")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getSolrSummary() { | |
model.solrSubsystemEnabled = true; | |
var indexSubsystem='solr6'; | |
var ctxt = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext(); | |
var solrContextFactory = ctxt.getBean(indexSubsystem, Packages.org.alfresco.repo.search.impl.solr.SolrChildApplicationContextFactory); | |
var solrContext = solrContextFactory.getApplicationContext(); | |
var solrAdminClient = solrContext | |
.getBean('search.solrAdminHTTPCLient', Packages.org.alfresco.repo.search.impl.solr.SolrAdminHTTPClient); | |
var args = new Packages.java.util.HashMap(); | |
args.action = 'SUMMARY'; | |
args.wt = 'json'; | |
var trackingSummaryResponse = solrAdminClient.execute(args); | |
args.action = 'STATUS'; | |
var trackingStatusResponse = solrAdminClient.execute(args); | |
var trackingSummary = JSON.parse(trackingSummaryResponse).Summary; | |
var trackingStatus = JSON.parse(trackingStatusResponse).status; | |
model.trackingSummary = trackingSummary; | |
model.trackingStatus = trackingStatus; | |
var coreNames = Object.keys(trackingSummary); | |
coreNames.sort(function(a, b){ | |
return a.localeCompare(b); | |
}); | |
model.coreNames = coreNames; | |
return model | |
} | |
print(getSolrSummary()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ctxt, scheduler; | |
// get Spring context and Quartz scheduler | |
ctxt = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext(); | |
scheduler = ctxt.getBean('schedulerFactory', Packages.org.quartz.Scheduler); | |
var jobKey = new Packages.org.quartz.JobKey('ldapPeopleJobDetail', 'DEFAULT'); | |
print(jobKey); | |
// fire (unless explicitly defined in Job detail Spring bean, scheduler group is always DEFAULT) | |
scheduler.triggerJob(jobKey); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment