Skip to content

Instantly share code, notes, and snippets.

View rotty3000's full-sized avatar

Raymond Augé rotty3000

View GitHub Profile
@rotty3000
rotty3000 / WikiGroupServiceConfiguration.java
Last active October 16, 2015 15:08
exception on metatype
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
@rotty3000
rotty3000 / spin.sh
Created July 6, 2015 14:58
bash: spin while process completes in the background
#!/bin/bash
spin() {
local s=("|" "/" "-" '\x5C')
local i=0
while kill -0 $1 2> /dev/null; do
echo -en "[${s[$i]}]"\\r
i=$(( $i == 3 ? 0 : $i + 1 ))
sleep .1
done
@rotty3000
rotty3000 / setup.sh
Last active August 29, 2015 14:24
Build equinox osgi, services, http.servlet, and run http.servlet.tests
#!/bin/bash
checkoutMasterSubmodule() {
(
local name=${1##*/}
echo "[----> Initing Submodule '${name}']"
git submodule update "${name}" 2>/dev/null
cd "${name}"
git checkout master 2>/dev/null
)&
@rotty3000
rotty3000 / setup-liferay.sh
Created March 31, 2015 16:01
Setting up Liferay 7.0 M4 with details on OSGi
#!/bin/bash
# Get it!
wget http://sourceforge.net/projects/lportal/files/Liferay%20Portal/7.0.0%20M4/liferay-portal-tomcat-7.0-ce-m4-20150224120313668.zip/download -O liferay-portal-tomcat-7.0-ce-m4.zip
# Unzip it!
unzip liferay-portal-tomcat-7.0-ce-m4.zip
# Trim off some legacy apps!
rm -rf liferay-portal-7.0-ce-m4/tomcat-7.0.42/webapps/calendar-portlet liferay-portal-7.0-ce-m4/tomcat-7.0.42/webapps/marketplace-portlet liferay-portal-7.0-ce-m4/tomcat-7.0.42/webapps/opensocial-portlet liferay-portal-7.0-ce-m4/tomcat-7.0.42/webapps/web-form-portlet liferay-portal-7.0-ce-m4/tomcat-7.0.42/webapps/kaleo-web liferay-portal-7.0-ce-m4/tomcat-7.0.42/webapps/notifications-portlet liferay-portal-7.0-ce-m4/tomcat-7.0.42/webapps/resources-importer-web liferay-portal-7.0-ce-m4/tomcat-7.0.42/webapps/sync-web liferay-portal-7.0-ce-m4/tomcat-7.0.42/webapps/welcome-theme
@rotty3000
rotty3000 / DDMJsResources.java
Last active October 24, 2023 05:25
resources example, serving any resources in your bundle
@Component(
property = {
"osgi.http.whiteboard.resource.pattern=/kaleo/resources/*",
"osgi.http.whiteboard.resource.prefix=/",
"osgi.http.whiteboard.servlet.pattern=/kaleo/resources/*" // temporary since this was the old property
},
service = Servlet.class
)
public class DDMJsResources extends HttpServlet {
}
@rotty3000
rotty3000 / bnd.bnd
Created February 6, 2015 16:43
wiki
Import-Package:\
!com.liferay.portal.tools.sql,\
!javax.activation.*,\
!javax.crypto.*,\
!javax.imageio.*,\
!javax.mail.*,\
!javax.naming.*,\
!javax.sql,\
!junit.framework.*,\
!net.sf.akismet.*,\
@rotty3000
rotty3000 / BaseDB.java.patch
Created February 5, 2015 21:34
BaseDB.java use templateManager
@@ -23,8 +23,12 @@ import com.liferay.portal.kernel.dao.db.IndexMetadataFactoryUtil;
import com.liferay.portal.kernel.dao.jdbc.DataAccess;
import com.liferay.portal.kernel.io.unsync.UnsyncBufferedReader;
import com.liferay.portal.kernel.io.unsync.UnsyncStringReader;
+import com.liferay.portal.kernel.io.unsync.UnsyncStringWriter;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
+import com.liferay.portal.kernel.template.StringTemplateResource;
+import com.liferay.portal.kernel.template.Template;
+import com.liferay.portal.kernel.template.TemplateManagerUtil;
@rotty3000
rotty3000 / code.md
Last active August 29, 2015 14:08
If you hate checked exceptions try this

Hate Checked Exceptions???

Try this little trick borrowed from Netty.

So you have an exception:

  • you don't want to check
  • you don't want to swallow
  • you don't want to pollute the method signature

Consider the following class Throw:

@@ -18,7 +18,9 @@ import com.liferay.portal.kernel.io.OutputStreamWriter;
import com.liferay.portal.kernel.io.unsync.UnsyncBufferedReader;
import com.liferay.portal.kernel.io.unsync.UnsyncBufferedWriter;
import com.liferay.portal.kernel.io.unsync.UnsyncStringReader;
+import com.liferay.portal.kernel.microsofttranslator.MicrosoftTranslator;
import com.liferay.portal.kernel.microsofttranslator.MicrosoftTranslatorException;
+import com.liferay.portal.kernel.microsofttranslator.MicrosoftTranslatorFactoryUtil;
import com.liferay.portal.kernel.util.FileUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.NaturalOrderStringComparator;
@rotty3000
rotty3000 / FIAndEquinoxTest.java
Last active August 29, 2015 14:07
embedded framework example to test fileinstall
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.ServiceLoader;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;