Skip to content

Instantly share code, notes, and snippets.

View douglascrp's full-sized avatar

Douglas C. R. Paes douglascrp

View GitHub Profile
@douglascrp
douglascrp / triggerLdapSync.js
Last active August 30, 2017 12:00 — forked from AFaust/printAlfrescoLog.js
How to trigger Alfresco LDAP sync with JavaScript
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('ldapPeopleJobDetail', 'DEFAULT');
@douglascrp
douglascrp / 1_README.md
Created January 9, 2017 16:04 — forked from Daniel15/1_README.md
Complete Google Drive File Picker example

Google Drive File Picker Example

This is an example of how to use the Google Drive file picker and Google Drive API to retrieve files from Google Drive using pure JavaScript. At the time of writing (14th July 2013), Google have good examples for using these two APIs separately, but no documentation on using them together.

Note that this is just sample code, designed to be concise to demonstrate the API. In a production environment, you should include more error handling.

See a demo at http://stuff.dan.cx/js/filepicker/google/

@douglascrp
douglascrp / Importing JS
Created September 12, 2017 15:21 — forked from CesarCapillas/Importing JS
Alfresco Javascript Console Recipes
Import a script from the repository using a name-based path:
<import resource="/Company Home/Data Dictionary/Scripts/library.js">
Import a script from the repository using a NodeRef reference:
<import resource="workspace://SpacesStore/6f73de1b-d3b4-11db-80cb-112e6c2ea048">
Import a script from a Java classpath location:
/**
* Script to locate error nodes from solr error report, and do something with them.
*
* @author Younes Regaieg <younes.regaieg@xenit.eu>
* @version 1.0
**/
//----- Solr error report to be fetched from solr /solr4/alfresco/query?q=EXCEPTIONMESSAGE:*&wt=json&rows=<number-of-rows-to-fetch>
//----- Swap this dummy object with a real object from the output of the endpoint mentionned above.
var solrErrorsReport = {
// Delete thumbnails if exists. To be used in Alfresco javascript console. Starts from selected space
recurse(space, function(node) {
var doclib = node.getThumbnail('doclib');
var webpreview = node.getThumbnail('webpreview');
var webpreview2 = node.getThumbnail('web-preview');
var imgpreview = node.getThumbnail('imgpreview');
var pdf = node.getThumbnail('pdf');
if(doclib){
doclib.remove();
// To be used with Alfresco JS Console. Select folder in js console to create export package for
var exportaction = actions.create("export");
exportaction.parameters["store"] = "workspace://SpacesStore";
exportaction.parameters["package-name"] = space.properties.name + "_export.acp";
exportaction.parameters["destination"] = space.parent;
exportaction.parameters["include-children"] = true;
exportaction.parameters["include-self"]=true;
exportaction.parameters["encoding"]="UTF-8";
exportaction.execute(space);
@douglascrp
douglascrp / runas.js
Created February 6, 2019 13:23 — forked from yv84/runas.js
var RunAsUtil = {
execute: function(workFunction, runAsUser) {
Packages.org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(new Packages.org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork()
{
doWork: workFunction
}, runAsUser);
},
doInTransaction: function(workFunction) {
var txs = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext().getBean("TransactionService");
var th = txs.getRetryingTransactionHelper();
@douglascrp
douglascrp / cleaner.js
Created February 6, 2019 13:24 — forked from wingyplus/cleaner.js
Delete all file in archive store
importClass(Packages.org.springframework.web.context.ContextLoader);
importClass(Packages.org.alfresco.service.cmr.repository.StoreRef);
var ctx = ContextLoader.getCurrentWebApplicationContext();
var archiveService = ctx.getBean("nodeArchiveService");
archiveService.purgeAllArchivedNodes(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"));
importClass(Packages.org.springframework.web.context.ContextLoader);
importClass(Packages.org.alfresco.service.cmr.repository.TransformationOptions);
var context = ContextLoader.getCurrentWebApplicationContext();
var alfThumbnailService = context.getBean("thumbnailService");
alfThumbnailService.updateThumbnail(document.getThumbnail("webpreview").nodeRef, new TransformationOptions());
@douglascrp
douglascrp / start-wf-assigned-to-site-group.js
Created February 6, 2019 13:24 — forked from alfrescian/start-wf-assigned-to-site-group.js
Start Alfresco Workflow assigned to SiteManager group of a site
var ctx = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
var javaSiteService = ctx.getBean("siteService");
var site = javaSiteService.getSite(document.nodeRef);
var siteManagerGroup = javaSiteService.getSiteRoleGroup(site.getShortName(), "SiteManager", true);
var groupAssignee = people.getGroup(siteManagerGroup)
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "activiti$activitiParallelGroupReview";
workflow.parameters.requiredApprovePercent = 20;
workflow.parameters["bpm:workflowDescription"] = "Please review and approve: " + document.name;