Skip to content

Instantly share code, notes, and snippets.

View sammso's full-sized avatar

Sampsa Sohlman sammso

View GitHub Profile
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import groovy.io.FileType;
if ( args.length < 1 ) {
println "Usage";
println "";
println "groovy ThreadDumpSplitter.groovy <directory>";
return;
}

How to see installed patch version from Liferay Scripting console

Login Liferay 6.2 EE with administrative permissoins and make sure that you have been logged in to main portal instance. Then navigate to Control panel and under Configuration section choose Server Administration. From Server Administration choose Script tag and choose language as choise Groovy.

Copy paste following code script field and click Execute button.

import com.liferay.portal.kernel.util.*;
import com.liferay.portal.kernel.util.GetterUtil
import com.liferay.portal.kernel.util.Validator
import com.liferay.portal.kernel.xml.Document
import com.liferay.portal.kernel.xml.Element
import com.liferay.portal.kernel.xml.SAXReaderUtil
import com.liferay.portal.model.LayoutSet
import com.liferay.portal.model.Portlet
import com.liferay.portal.model.PortletPreferences
import com.liferay.portal.service.GroupLocalServiceUtil
import com.liferay.portal.service.LayoutSetLocalServiceUtil

01 Development environment

Fixed : https://filebin.ca/3Mdy63PxBLul/12.3SearchQueries.xml

<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
    <category filters="*" id="category_1494770019104" initial_state="0" label="12.3 Search Queries" largeicon="" smallicon="">
        <description/>
        <item category="category_1494770019104" id="item_1494771428516" label="04-component-property">

Overview

These scripts are created to test serialization through Liferay's Scripting console.

Groovy scripts

Writing the Liferay Layout

import java.io.FileInputStream;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Application;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
@ApplicationPath("/greeting")
@sammso
sammso / ChangeAllLiferayUserPasswords.js
Last active March 9, 2017 12:08
Example script that changes every user password at Liferay DB
/***
Example script that changes every user password at Liferay DB to qweqwea
*/
var companyId = 20155;
var users = Packages.com.liferay.portal.service.UserServiceUtil.getCompanyUsers(companyId, -1, -1);
for ( var i = 0 ; i < users.size(); i++ ) {
var user = users.get(i);
Packages.com.liferay.portal.service.UserServiceUtil.updatePassword(user.getUserId(), "qweqwe", "qweqwe", false);
@sammso
sammso / LiferayEhCacheConfigToSQL.groovy
Last active March 14, 2017 14:51
Tool to help analyze Liferay portal cache settings
/***
* ehCache configuration parser
*
* This parses the configurations to be imported following table
CREATE TABLE CacheSettings (
cacheType VARCHAR(12) NOT NULL,
bean VARCHAR(255) NOT NULL,
eternal VARCHAR(5) NOT NULL,
cacheSize INT NOT NULL,
import groovy.io.FileType
if ( args.length < 2 ) {
println "Scan's thread dump *.log files from directory";
println "";
println "Usage:";
println "groovy ThreadDumpAnalyzer.groovy <directory> <first value to look from thread dump> <second value to look from thread dump> <third value to look from thread dump>";
println "";
return;
}