Skip to content

Instantly share code, notes, and snippets.

View sammso's full-sized avatar

Sampsa Sohlman sammso

View GitHub Profile
@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,
@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);
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")

Overview

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

Groovy scripts

Writing the Liferay Layout

import java.io.FileInputStream;

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">
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

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 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;
}
@sammso
sammso / liferay-training-leiden-2017-10-24.md
Last active October 24, 2017 15:01
Liferay Fundamentals training at Leiden 2017-10-24

Snippets and tips for the course

Using Java 8 when having Java 9 with Mac

Edit your ~/.bash_profile file and add following line there after installing Java 8, where jdk1.8.0_112.jdk is your JDK installation version.

alias use-java8='export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home"'