Skip to content

Instantly share code, notes, and snippets.

View sustacek's full-sized avatar

Josef Šustáček sustacek

  • Liferay, Inc.
  • Czech Republic
View GitHub Profile
@sustacek
sustacek / ConfigsLister.java
Last active February 10, 2021 08:35
OSGi - list all instances of a factory config
import aQute.bnd.annotation.metatype.Meta;
import com.liferay.portal.configuration.metatype.annotations.ExtendedObjectClassDefinition;
import com.liferay.portal.configuration.metatype.bnd.util.ConfigurableUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import java.io.IOException;
@sustacek
sustacek / build.gradle
Created December 2, 2020 10:17
Verify bundle checksum in Liferay Workspace
// Make sure we can use the classes from the Download plugin, like the Verify below
buildscript {
repositories { jcenter() }
dependencies { classpath group: "de.undercouch", name: "gradle-download-task", version: "4.0.4" }
}
apply plugin: de.undercouch.gradle.tasks.download.DownloadTaskPlugin
[
'SHA-256': 'liferay.workspace.bundle.checksum[sha-256]',
'MD5': 'liferay.workspace.bundle.checksum[md5]',
@sustacek
sustacek / build.gradle
Last active November 4, 2020 09:30
Liferay Workspace - Tomcat version check between configs and used bundle
// [root]/build.gradle
// A sanity check in case the Tomcat version inside the bundle changes and we miss it
[
(initBundle): gradle.liferayWorkspace.homeDir,
(distBundle): file("${buildDir}/dist")
].each {Task task, File destDir ->
task.configure {
doLast {
println "Checking Tomcat files in " + destDir
@sustacek
sustacek / Cloud Formation boolean Parameter
Last active October 27, 2020 15:40
The snippet of a Cloud Formation template, which supports input of boolean parameter and using it for a resource with Boolean property.
{
...
"Parameters": {
"DbRdsMultiAZ": {
"Type": "String",
"Description": "Specifies if the RDS instance is deployed in multiple Availability Zones.",
"AllowedValues": [
"yes",
"no"
],
@sustacek
sustacek / gist:b0af0ae1969668042b112542cc8f4eb1
Created March 4, 2019 12:42
Enhanced log4j monitoring for DXP 7.1 - tomcat/webapps/ROOT/WEB-INF/classes/META-INF/portal-log4j-ext.xml
<?xml version="1.0"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender class="org.apache.log4j.rolling.RollingFileAppender" name="TEXT_FILE">
<!-- Inspired by: http://www.baeldung.com/java-logging-rolling-file-appenders -->
<!--
=== What happens when current log file needs to be rotated? ===
-->