Skip to content

Instantly share code, notes, and snippets.

@AFaust
AFaust / share-header.get.js
Last active December 22, 2015 07:49
This script removes some Share header items in a share-header.get.js customization. Currently there does not appear to be a utility to remove widgets from the new JS widget model, so this is what got the job done for me...
var widget, widgetsToRemove = [ "HEADER_SHARED_FILES", "HEADER_MY_FILES", "HEADER_PEOPLE", "HEADER_TASKS", "HEADER_REPOSITORY",
"HEADER_SEARCH" ], idx, max;
for (idx = 0, max = widgetsToRemove.length; idx < max; idx++)
{
findAndRemoveIn(model.jsonModel.widgets, null, null, widgetsToRemove[idx]);
}
function findAndRemoveIn(obj, arrContext, arrIdx, id)
{
@AFaust
AFaust / reset-site-theme.js
Created November 29, 2016 14:37
Alfresco JavaScript Console script to reset the theme of all sites in Alfresco to the system default
var sites, idx, site, dashboard, xmlConfig;
sites = search.query({ language: 'fts-alfresco', query: 'TYPE:"st:sites"'});
for (idx = 0; idx < sites.length; idx++)
{
site = sites[idx];
dashboard = site.childrenByXPath('cm:surf-config/cm:pages/cm:site/cm:' + site.name + '/cm:dashboard.xml')[0];
xmlConfig = dashboard.content;
@AFaust
AFaust / dashlet-removal.js
Last active November 29, 2016 14:40
Alfresco JavaScript Console script to remove various specific dashlets from user and site dashboards
var siteDashboardComponents, userDashboardComponents, idx;
siteDashboardComponents = companyhome.childrenByXPath('st:sites/cm:*/cm:surf-config/cm:components/*');
userDashboardComponents = companyhome.childrenByXPath('st:sites/cm:surf-config/cm:components/*');
function checkAndRemoveComponent (component)
{
var componentXml;
// we don't expect anything else but just to be sure
if (/dashboard.xml$/.test(component.name))
@AFaust
AFaust / cleanupAlfrescoHistAct.sql
Last active January 15, 2017 05:44
Delete all historic process instances and related historic data for workflows completed before a specific date (MySQL / MariaDB)
delete from act_hi_actinst where proc_inst_id_ in (select id_ from act_hi_procinst where end_time_ is not null and end_time_ < timestamp '2016-11-24');
delete from act_hi_attachment where proc_inst_id_ in (select id_ from act_hi_procinst where end_time_ is not null and end_time_ < timestamp '2016-11-24');
delete from act_hi_comment where proc_inst_id_ in (select id_ from act_hi_procinst where end_time_ is not null and end_time_ < timestamp '2016-11-24');
delete from act_hi_detail where proc_inst_id_ in (select id_ from act_hi_procinst where end_time_ is not null and end_time_ < timestamp '2016-11-24');
delete from act_hi_identitylink where proc_inst_id_ in (select id_ from act_hi_procinst where end_time_ is not null and end_time_ < timestamp '2016-11-24');
delete from act_hi_varinst where proc_inst_id_ in (select id_ from act_hi_procinst where end_time_ is not null and end_time_ < timestamp '2016-11-24');
delete from act_hi_taskinst where proc_inst_id_ in (select id_ from act_hi_procinst where end_time_ is no
@AFaust
AFaust / clearUserHomesBatch.js
Last active February 6, 2017 19:05
Example: JavaScript batch process to clear user homes using the Alfresco Enhanced Script Environment and its batch processing capabilities. See https://github.com/AFaust/alfresco-enhanced-script-environment and https://github.com/AFaust/alfresco-enhanced-script-environment/wiki/Batch-Processing
// character codes for 'a' to 'z'
var charCode = 97, max = 122;
// userProvider provides batches of users based on first name initial character
function userProvider()
{
var results = [], initial;
while(results.length === 0 && charCode <= max)
{
initial = String.fromCharCode(charCode++);
@AFaust
AFaust / ComplexCacheKeyTests.java
Created June 20, 2019 14:12
Unit test for using complex cache keys in Apache Ignite - sample for question on Ignite mailing list
import java.io.Serializable;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicyFactory;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.junit.Assert;
@AFaust
AFaust / reset_alf_auth_script.sql
Last active November 9, 2021 14:20
Reset Alfresco Authorised Users tracking (only meant for fixing errors, i.e. MNT-16663, or false-positive 'manual changes' detection - not to circumvent subscription terms)
-- clear all user license states
delete from alf_auth_status;
-- remove old checksum and keystore
-- ns_id = 1 should always be the system model, store_id = 2 always the system store
delete from alf_node_properties where qname_id in (
select id from alf_qname where ns_id = 1 and local_name in ('keyStore', 'authorizationChecksum')
) and node_id in (
select id from alf_node where store_id = 2
);
@AFaust
AFaust / alfresco
Created May 2, 2017 07:26
Alfresco logrotate.d examples - able to handle compress and clear historic timestamped log files
/opt/alfresco/tomcat/logs/catalina.out {
daily
rotate 27
notifempty
missingok
compress
delaycompress
copytruncate
}
@AFaust
AFaust / migrate-activiti-workflows.sql
Created May 24, 2019 14:32
Alfresco db-v4.2-migratActivitiWorkflows script (last suported on 5.2)
--
-- Title: Migrate old workflow details into act_hi_varinst
-- Database: PostgreSQL
-- Since: V4.2 Schema 6080
--
-- Please contact support@alfresco.com if you need assistance with the upgrade.
--
-- Migrate old workflow details into act_hi_varinst
--ASSIGN:START_INDEX=VALUE_
@AFaust
AFaust / printAlfrescoLog.js
Last active January 18, 2024 16:52
Useful Alfresco JavaScript console scripts
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));