Skip to content

Instantly share code, notes, and snippets.

@AFaust
AFaust / alfresco-access-audit-loginSummaryQuery.sql
Created October 5, 2022 16:20
Alfresco Audit alfresco-access Login Summary
select
unpsv.string_value as user,
max(audit_time) as lastLoginTime,
count(*) as loginCounts
from
alf_prop_link pl
left join alf_audit_entry ae on ae.audit_values_id = pl.root_prop_id
left join alf_prop_value unpv on unpv.id = ae.audit_user_id
left join alf_prop_string_value unpsv on unpsv.id = unpv.long_value
where
@AFaust
AFaust / clearAllJMXSettings.sql
Last active January 19, 2024 14:31
Alfresco SQL scripts for upgrade preparation
delete
from
alf_prop_link
where
root_prop_id in (
select
prop1_id
from
alf_prop_unique_ctx ctx
left join alf_prop_value pvj1 on ctx.value1_prop_id = pvj1.id
@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 / 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 [email protected] if you need assistance with the upgrade.
--
-- Migrate old workflow details into act_hi_varinst
--ASSIGN:START_INDEX=VALUE_
@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 / 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 / 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 / printAlfrescoLog.js
Last active August 22, 2024 03:47
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));