Skip to content

Instantly share code, notes, and snippets.

@nshaw
nshaw / staging-errors-after-upgrade-from51.patch
Created February 14, 2012 14:28
staging-errors-after-upgrade-from51.patch
diff --git a/portal-impl/src/com/liferay/portal/lar/LayoutImporter.java b/portal-impl/src/com/liferay/portal/lar/LayoutImporter.java
index 21a05e0..a4b576f 100644
--- a/portal-impl/src/com/liferay/portal/lar/LayoutImporter.java
+++ b/portal-impl/src/com/liferay/portal/lar/LayoutImporter.java
@@ -970,7 +970,6 @@ public class LayoutImporter {
groupId, privateLayout);
}
else {
- importedLayout.setUuid(layout.getUuid());
importedLayout.setLayoutPrototypeUuid(
@nshaw
nshaw / gist:2229686
Created March 28, 2012 19:27
Sesame solr-spring.xml for dev 02
<?xml version="1.0"?>
<beans
default-destroy-method="destroy"
default-init-method="afterPropertiesSet"
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
>
<bean class="com.liferay.portal.spring.context.PortletBeanFactoryPostProcessor" />
@nshaw
nshaw / 20120503_uat_sass_errors
Created May 3, 2012 18:58
Sesame UAT SASS errors
Caused by: org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- file:/opt/liferay/deploys/RB_3.0.0-r5163/tomcat/webapps/ROOT/WEB-INF/lib/ruby-gems.jar!/gems/sass-3.1.7/lib/sass/../sass
14:52:08,571 ERROR [DynamicCSSFilter:181] Unable to parse SASS on CSS /opt/liferay/current/tomcat/webapps/ROOT/web/_template/css/styles.css
org.jruby.embed.EvalFailedException: (LoadError) no such file to load -- file:/opt/liferay/deploys/RB_3.0.0-r5163/tomcat/webapps/ROOT/WEB-INF/lib/ruby-gems.jar!/gems/sass-3.1.7/lib/sass/../sass
at org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:127)
at org.jruby.embed.ScriptingContainer.runUnit(ScriptingContainer.java:1231)
at org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1224)
at com.liferay.portal.scripting.ruby.RubyExecutor.eval(RubyExecutor.java:148)
at com.liferay.portal.scripting.ruby.RubyExecutor.eval(RubyExecutor.java:105)
at com.liferay.portal.servlet.filters.dynamiccss.DynamicCSSUtil._parseSass(DynamicCSSUti
@nshaw
nshaw / solr_boost_snippet.java
Created July 24, 2012 12:18
Adding boost factors at runtime
for (String assetType : assetTypes) {
BooleanQuery assetTypeQuery = BooleanQueryFactoryUtil.create(context);
assetTypesQuery.add(assetTypeQuery, BooleanClauseOccur.SHOULD);
if( (assetBoostFactors != null)
&& (index <= assetBoostFactors.length)) {
int boost = assetBoostFactors[index];
Class clazz = assetTypesQuery.getClass();
//Note: can't do instanceOf since BQI is in portal-impl
if ("com.liferay.portal.search.lucene.BooleanQueryImpl".equals(clazz.getName())) {
@nshaw
nshaw / gist:3637992
Created September 5, 2012 15:05
Customized WURFLDevice.java
/**
* Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation; version 3.0 of the License.
*
* 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
@nshaw
nshaw / gist:3638482
Created September 5, 2012 15:31
Patch tool ant targets
<target name="patching-init">
<property name="patching-tool.dir" value="${build.path}/patching-tool"/>
<property name="patches.dir" value="${patching-tool.dir}/patches"/>
<delete dir="${patching-tool.dir}"/>
<mkdir dir="${patches.dir}"/>
<unzip src="${bundles.dir}/patching-tool-6.zip" dest="${build.path}"/>
<copy todir="${patches.dir}">
<fileset dir="${bundles.dir}/patches" includes="*"/>
@nshaw
nshaw / gist:3638497
Created September 5, 2012 15:31
Patch tool - detect code conflicts
import java.util.zip.ZipFile
/*
* detect-patch-conflicts.groovy
* Input - patches.dir property to indicate the location of the patches zip files
* Output - detected.patch.conflict property - set to true if conflicts were found
*/
def conflict = false
// CUSTOM START - this configuraton should be paramaterized to generalize this script
@nshaw
nshaw / gist:3693859
Created September 10, 2012 21:05
patch for PortletExporter.java:exportAssetTags(PortletDataContext) to improve page publishing performance
for (AssetTag assetTag : assetTags) {
// CUSTOM START
// By only exporting tags that are more recent than the export start
// date of the Layout, we assume that at some point in time the
// exporting Site and the importing Site had exactly the same Tags,
// and that every Layout export will harvest any tags not found in
// the importing Site
if(portletDataContext.hasDateRange()) {
int diff = DateUtil.compareTo(portletDataContext.getStartDate(),
assetTag.getModifiedDate());
@nshaw
nshaw / CustomJSONServiceAction.java
Created September 11, 2012 12:43
Make HTTP request available to JSON services
public String getJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
String className = ParamUtil.getString(request, "serviceClassName");
boolean useThreadLocal = (className.indexOf("UmpServiceUtil") > 0) || (className.indexOf("MyStreetServiceUtil") > 0);
try {
if (useThreadLocal) {
JSONRequestThreadLocal.setRequest(request);
}
return super.getJSON(mapping, form, request, response);
}
@nshaw
nshaw / CustomServiceComponentLocalServiceImpl.java
Created September 11, 2012 12:54
Fix ServiceComponentLocalServiceImpl handling of indexes
public class CustomServiceComponentLocalServiceImpl extends
ServiceComponentLocalServiceImpl {
@Override
public void upgradeDB(
ClassLoader classLoader, String buildNamespace, long buildNumber,
boolean buildAutoUpgrade, ServiceComponent previousServiceComponent,
String tablesSQL, String sequencesSQL, String indexesSQL)
throws Exception {