Last active
April 25, 2025 13:13
-
-
Save AFaust/beaa309837397abf961f to your computer and use it in GitHub Desktop.
Useful Alfresco JavaScript console scripts
This file contains hidden or 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
// usefull in default Alfresco Docker images which don't provide jmap/jcmd CLI tools | |
var mbean = Packages.java.lang.management.ManagementFactory.getPlatformMXBean(Packages.com.sun.management.HotSpotDiagnosticMXBean); | |
mbean.dumpHeap('/usr/local/tomcat/temp/dump.hprof', true); |
This file contains hidden or 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 loggerRepository, rootLogger, appender, path, lines, idx; | |
loggerRepository = Packages.org.apache.log4j.LogManager.getLoggerRepository(); | |
rootLogger = loggerRepository.rootLogger; | |
appender = rootLogger.getAppender('File'); | |
path = appender.file; | |
lines = Packages.java.nio.file.Files.readAllLines(Packages.java.nio.file.Paths.get(path)); | |
for (idx = 0; idx < lines.size(); idx++) | |
{ | |
print(lines.get(idx)); | |
} |
This file contains hidden or 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 nodeRef, ctxt, nodeService, encryptor, encryptedPropValue, decryptedPropValue; | |
nodeRef = new Packages.org.alfresco.service.cmr.repository.NodeRef('workspace://SpacesStore/<uid>'); | |
ctxt = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext(); | |
nodeService = ctxt.getBean('NodeService', Packages.org.alfresco.service.cmr.repository.NodeService); | |
encryptor = ctxt.getBean('metadataEncryptor', Packages.org.alfresco.repo.node.encryption.MetadataEncryptor); | |
// need to use QName to denote property - can use Alfresco Java constants (example: OAuth access token) | |
encryptedPropValue = nodeService.getProperty(nodeRef, Packages.org.alfresco.repo.remotecredentials.RemoteCredentialsModel.PROP_OAUTH2_ACCESS_TOKEN); | |
decryptedPropValue = encryptor.decrypt(Packages.org.alfresco.repo.remotecredentials.RemoteCredentialsModel.PROP_OAUTH2_ACCESS_TOKEN, encryptedPropValue); | |
print(decryptedPropValue); |
This file contains hidden or 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,hazelcastInstanceFactory, hzInstance, hzLifecycleService; | |
ctxt = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext(); | |
hazelcastInstanceFactory = ctxt.getBean('hazelcastInstanceFactory', Packages.org.alfresco.enterprise.repo.cluster.core.HazelcastInstanceFactory); | |
hzInstance = hazelcastInstanceFactory.getInstance(); | |
hzLifecycleService = hzInstance.getLifecycleService(); | |
// this should reinitialize the local cluster node Hazelcast layer without invalidating any beans | |
// this can be useful if cluster node may be stuck / not discovering any other members after a split | |
hzLifecycleService.restart(); |
This file contains hidden or 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); | |
// fire (unless explicitly defined in Job detail Spring bean, scheduler group is always DEFAULT) | |
scheduler.triggerJob('<insertJobName>', 'DEFAULT'); |
This file contains hidden or 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, synchronizer; | |
ctxt = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext(); | |
synchronizer = ctxt.getBean('userRegistrySynchronizer', Packages.org.alfresco.repo.security.sync.UserRegistrySynchronizer); | |
// forceUpdate = false, isFullSync = false - change for full update / with deletions | |
synchronizer.synchronize(false, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment