Sfoglia il codice sorgente

Preview hook per file P7m

master 22.03
Salvatore La Manna 3 anni fa
parent
commit
66168d7075
  1. 3
      liferay-plugins-sdk-6.2/build.ture.properties
  2. 11
      liferay-plugins-sdk-6.2/build.ture.properties.save
  3. 27
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.classpath
  4. 37
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.project
  5. 12
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.settings/.jsdtscope
  6. 7
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.settings/org.eclipse.jdt.core.prefs
  7. 8
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.settings/org.eclipse.wst.common.component
  8. 7
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
  9. 11
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.settings/org.eclipse.wst.common.project.facet.core.xml
  10. 1
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.settings/org.eclipse.wst.jsdt.ui.superType.container
  11. 1
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.settings/org.eclipse.wst.jsdt.ui.superType.name
  12. 6
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/build.xml
  13. 3
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/META-INF/MANIFEST.MF
  14. 1
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/.gitignore
  15. 6
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/liferay-hook.xml
  16. 34
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/liferay-plugin-package.properties
  17. 462
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/configuration/ConfigurationImpl.java
  18. 383
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/configuration/easyconf/ClassLoaderAggregateProperties.java
  19. 161
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/configuration/easyconf/ClassLoaderComponentConfiguration.java
  20. 253
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/image/ImageMagickImpl.java
  21. 710
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/image/ImageToolImpl.java
  22. 65
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/image/LiferayConvertCmd.java
  23. 65
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/image/LiferayIdentifyCmd.java
  24. 45
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/log/Log4jLogFactoryImpl.java
  25. 164
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/log/Log4jLogImpl.java
  26. 48
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/ImageBaseImpl.java
  27. 121
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/ImageCacheModel.java
  28. 95
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/ImageImpl.java
  29. 512
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/ImageModelImpl.java
  30. 49
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/PortalPreferencesBaseImpl.java
  31. 100
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/PortalPreferencesCacheModel.java
  32. 25
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/PortalPreferencesImpl.java
  33. 407
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/PortalPreferencesModelImpl.java
  34. 575
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/repository/liferayrepository/model/LiferayFileEntry.java
  35. 412
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/repository/liferayrepository/model/LiferayFileVersion.java
  36. 418
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/repository/liferayrepository/model/LiferayFolder.java
  37. 33
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/repository/liferayrepository/model/LiferayModel.java
  38. 128
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/repository/liferayrepository/util/LiferayBase.java
  39. 135
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/util/ClassLoaderUtil.java
  40. 1112
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/util/FileImpl.java
  41. 572
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/util/PrefsPropsUtil.java
  42. 28
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/util/PropsFiles.java
  43. 348
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/util/PropsUtil.java
  44. 2156
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/util/PropsValues.java
  45. 357
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/BasePreferencesImpl.java
  46. 414
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/PortalPreferencesImpl.java
  47. 96
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/PortalPreferencesWrapper.java
  48. 58
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/PortalPreferencesWrapperCacheUtil.java
  49. 97
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/Preference.java
  50. 164
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/documentlibrary/service/permission/DLFileEntryPermission.java
  51. 165
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/documentlibrary/service/permission/DLFolderPermission.java
  52. 81
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/documentlibrary/service/permission/DLPermission.java
  53. 406
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/documentlibrary/util/DocumentConversionUtil.java
  54. 118
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/documentlibrary/util/LiferayPDFBoxConverter.java
  55. 636
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/it/mwg/sicilia/preview/SiciliaP7MProcessor.java
  56. 7
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/portal-ext.properties
  57. 1
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/portal.properties
  58. 3
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/web.xml
  59. 18
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/ivy.xml
  60. 1
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/ivy.xml.MD5
  61. 15
      liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/test/integration/arquillian.xml
  62. BIN
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/bcprov-ext-jdk15to18.jar
  63. BIN
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/bcprov-jdk15to18.jar
  64. 15
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/AsseverazioniUtil.java
  65. 6
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/SorteggioPraticaUtil.java
  66. 4
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties
  67. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/common/preview_file_entry.jsp
  68. 13
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/page_desc_edificio.jsp
  69. 5
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/page_dettagli_principali.jsp
  70. 13
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/gestionefirme/avvisi_actions.jsp
  71. 2
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/verify_fascicolo.jsp
  72. 8
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/soggettipratica/view.jsp

3
liferay-plugins-sdk-6.2/build.ture.properties

@ -7,3 +7,6 @@ app.server.tomcat.dir = /home/ture/liferay/portali/sismica/tomcat-7.0.62
app.server.type = tomcat
app.server.tomcat.portal.dir = /home/ture/liferay/portali/sismica/tomcat-7.0.62/webapps/ROOT
javac.encoding = UTF-8
ext.work.dir = /home/ture/liferay/src/work
app.server.dir = /home/ture/liferay/src/work/liferay-portal-6.2-ce-ga6/tomcat-7.0.62
app.server.zip.name = /home/ture/liferay/src/liferay-portal-tomcat-6.2-ce-ga6-patched.zip

11
liferay-plugins-sdk-6.2/build.ture.properties.save

@ -0,0 +1,11 @@
app.server.tomcat.lib.global.dir = /home/ture/liferay/portali/sismica/tomcat-7.0.62/lib/ext
app.server.tomcat.deploy.dir = /home/ture/liferay/portali/sismica/tomcat-7.0.62/webapps
app.server.parent.dir = /home/ture/liferay/portali/sismica
app.server.tomcat.dir = /home/ture/liferay/portali/sismica/tomcat-7.0.62
app.server.type = tomcat
app.server.tomcat.portal.dir = /home/ture/liferay/portali/sismica/tomcat-7.0.62/webapps/ROOT
javac.encoding = UTF-8
ext.work.dir=/home/ture/liferay/src/work
app.server.dir=/home/ture/liferay/src/work/liferay-portal-6.2-ce-ga6/tomcat-7.0.62
app.server.zip.name=/home/ture/liferay/src/liferay-portal-tomcat-6.2-ce-ga6-patched.zip

27
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.classpath

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="docroot/WEB-INF/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_80">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/com.liferay.ide.eclipse.server.tomcat.runtimeClasspathProvider/Liferay v6.2 CE (Tomcat 7)">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="com.liferay.ide.eclipse.server.plugin.container/hook">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=sicilia-p7m-preview-hook&amp;ivyXmlPath=ivy.xml&amp;confs=*&amp;ivySettingsPath=%24%7Bliferay_sdk_dir%3Asicilia-p7m-preview-hook%7D%2Fivy-settings.xml&amp;loadSettingsOnDemand=false&amp;ivyUserDir=%24%7Bliferay_sdk_dir%3Asicilia-p7m-preview-hook%7D%2F.ivy&amp;propertyFiles=">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="docroot/WEB-INF/classes"/>
</classpath>

37
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.project

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>sicilia-p7m-preview-hook</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.apache.ivyde.eclipse.ivynature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>

12
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.settings/.jsdtscope

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="docroot"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>

7
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.settings/org.eclipse.jdt.core.prefs

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

8
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.settings/org.eclipse.wst.common.component

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="sicilia-p7m-preview-hook">
<wb-resource deploy-path="/" source-path="/docroot" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/docroot/WEB-INF/src"/>
<property name="context-root" value="sicilia-p7m-preview-hook"/>
<property name="java-output-path" value="/sicilia-p7m-preview-hook/docroot/WEB-INF/classes"/>
</wb-module>
</project-modules>

7
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml

@ -0,0 +1,7 @@
<root>
<facet id="liferay.hook">
<node name="libprov">
<attribute name="provider-id" value="com.liferay.ide.eclipse.plugin.hook.libraryProvider"/>
</node>
</facet>
</root>

11
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.settings/org.eclipse.wst.common.project.facet.core.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Liferay v6.2 CE (Tomcat 7)"/>
<fixed facet="jst.web"/>
<fixed facet="java"/>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="liferay.hook" version="6.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>

1
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.settings/org.eclipse.wst.jsdt.ui.superType.container

@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary

1
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/.settings/org.eclipse.wst.jsdt.ui.superType.name

@ -0,0 +1 @@
Window

6
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/build.xml

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE project>
<project name="sicilia-p7m-preview-hook" basedir="." default="deploy">
<import file="../build-common-hook.xml" />
</project>

3
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/META-INF/MANIFEST.MF

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

1
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/.gitignore vendored

@ -0,0 +1 @@
/classes/

6
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/liferay-hook.xml

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd">
<hook>
<portal-properties>portal-ext.properties</portal-properties>
</hook>

34
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/liferay-plugin-package.properties

@ -0,0 +1,34 @@
name=Sicilia P7M preview
module-group-id=liferay
module-incremental-version=1
tags=
short-description=
long-description=
change-log=
page-url=http://www.liferay.com
author=Liferay, Inc.
licenses=LGPL
liferay-versions=6.2.0+
portal-dependency-jars= \
ant.jar, \
chardet.jar, \
commons-beanutils.jar, \
commons-collections.jar, \
commons-compress.jar, \
commons-configuration.jar, \
commons-digester.jar, \
commons-io.jar, \
commons-lang.jar, \
easyconf.jar, \
gif89.jar, \
im4java.jar, \
jai_codec.jar, \
jai_core.jar, \
jodconverter.jar, \
pdfbox.jar, \
poi.jar, \
portal-service.jar, \
ridl.jar, \
tika-core.jar, \
xpp3.jar, \
xstream.jar

462
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/configuration/ConfigurationImpl.java

@ -0,0 +1,462 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.configuration;
import com.germinus.easyconf.ComponentConfiguration;
import com.germinus.easyconf.ComponentProperties;
import com.liferay.portal.configuration.easyconf.ClassLoaderAggregateProperties;
import com.liferay.portal.configuration.easyconf.ClassLoaderComponentConfiguration;
import com.liferay.portal.kernel.configuration.Filter;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.util.PropertiesUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.Company;
import com.liferay.portal.model.CompanyConstants;
import com.liferay.portal.service.CompanyLocalServiceUtil;
import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.MapConfiguration;
/**
* @author Brian Wing Shun Chan
* @author Shuyang Zhou
*/
public class ConfigurationImpl
implements com.liferay.portal.kernel.configuration.Configuration {
public ConfigurationImpl(ClassLoader classLoader, String name) {
this(classLoader, name, CompanyConstants.SYSTEM);
}
public ConfigurationImpl(
ClassLoader classLoader, String name, long companyId) {
String webId = null;
if (companyId > CompanyConstants.SYSTEM) {
try {
Company company = CompanyLocalServiceUtil.getCompanyById(
companyId);
webId = company.getWebId();
}
catch (Exception e) {
_log.error(e, e);
}
}
_componentConfiguration = new ClassLoaderComponentConfiguration(
classLoader, webId, name);
printSources(companyId, webId);
}
@Override
public void addProperties(Properties properties) {
try {
ComponentProperties componentProperties =
_componentConfiguration.getProperties();
ClassLoaderAggregateProperties classLoaderAggregateProperties =
(ClassLoaderAggregateProperties)
componentProperties.toConfiguration();
Field field1 = CompositeConfiguration.class.getDeclaredField(
"configList");
field1.setAccessible(true);
// Add to configList of base conf
List<Configuration> configurations =
(List<Configuration>)field1.get(classLoaderAggregateProperties);
MapConfiguration newConfiguration = new MapConfiguration(
properties);
configurations.add(0, newConfiguration);
// Add to configList of AggregatedProperties itself
CompositeConfiguration compositeConfiguration =
classLoaderAggregateProperties.getBaseConfiguration();
configurations = (List<Configuration>)field1.get(
compositeConfiguration);
configurations.add(0, newConfiguration);
clearCache();
}
catch (Exception e) {
_log.error("The properties could not be added", e);
}
}
@Override
public void clearCache() {
_values.clear();
}
@Override
public boolean contains(String key) {
Object value = _values.get(key);
if (value == null) {
ComponentProperties componentProperties = getComponentProperties();
value = componentProperties.getProperty(key);
if (value == null) {
value = _nullValue;
}
_values.put(key, value);
}
if (value == _nullValue) {
return false;
}
return true;
}
@Override
public String get(String key) {
Object value = _values.get(key);
if (value == null) {
ComponentProperties componentProperties = getComponentProperties();
value = componentProperties.getString(key);
if (value == null) {
value = _nullValue;
}
_values.put(key, value);
}
else if (_PRINT_DUPLICATE_CALLS_TO_GET) {
System.out.println("Duplicate call to get " + key);
}
if (value instanceof String) {
return (String)value;
}
return null;
}
@Override
public String get(String key, Filter filter) {
String filterCacheKey = buildFilterCacheKey(key, filter, false);
Object value = null;
if (filterCacheKey != null) {
value = _values.get(filterCacheKey);
}
if (value == null) {
ComponentProperties componentProperties = getComponentProperties();
value = componentProperties.getString(
key, getEasyConfFilter(filter));
if (filterCacheKey != null) {
if (value == null) {
value = _nullValue;
}
_values.put(filterCacheKey, value);
}
}
if (value instanceof String) {
return (String)value;
}
return null;
}
@Override
public String[] getArray(String key) {
String cacheKey = _ARRAY_KEY_PREFIX.concat(key);
Object value = _values.get(cacheKey);
if (value == null) {
ComponentProperties componentProperties = getComponentProperties();
String[] array = componentProperties.getStringArray(key);
value = fixArrayValue(cacheKey, array);
}
if (value instanceof String[]) {
return (String[])value;
}
return _emptyArray;
}
@Override
public String[] getArray(String key, Filter filter) {
String filterCacheKey = buildFilterCacheKey(key, filter, true);
Object value = null;
if (filterCacheKey != null) {
value = _values.get(filterCacheKey);
}
if (value == null) {
ComponentProperties componentProperties = getComponentProperties();
String[] array = componentProperties.getStringArray(
key, getEasyConfFilter(filter));
value = fixArrayValue(filterCacheKey, array);
}
if (value instanceof String[]) {
return (String[])value;
}
return _emptyArray;
}
@Override
public Properties getProperties() {
// For some strange reason, componentProperties.getProperties() returns
// values with spaces after commas. So a property setting of "xyz=1,2,3"
// actually returns "xyz=1, 2, 3". This can break applications that
// don't expect that extra space. However, getting the property value
// directly through componentProperties returns the correct value. This
// method fixes the weird behavior by returning properties with the
// correct values.
Properties properties = new Properties();
ComponentProperties componentProperties = getComponentProperties();
Properties componentPropertiesProperties =
componentProperties.getProperties();
for (String key : componentPropertiesProperties.stringPropertyNames()) {
properties.setProperty(key, componentProperties.getString(key));
}
return properties;
}
@Override
public Properties getProperties(String prefix, boolean removePrefix) {
Properties properties = getProperties();
return PropertiesUtil.getProperties(properties, prefix, removePrefix);
}
@Override
public void removeProperties(Properties properties) {
try {
ComponentProperties componentProperties =
_componentConfiguration.getProperties();
ClassLoaderAggregateProperties classLoaderAggregateProperties =
(ClassLoaderAggregateProperties)
componentProperties.toConfiguration();
CompositeConfiguration compositeConfiguration =
classLoaderAggregateProperties.getBaseConfiguration();
Field field2 = CompositeConfiguration.class.getDeclaredField(
"configList");
field2.setAccessible(true);
@SuppressWarnings("unchecked")
List<Configuration> configurations =
(List<Configuration>)field2.get(compositeConfiguration);
Iterator<Configuration> itr = configurations.iterator();
while (itr.hasNext()) {
Configuration configuration = itr.next();
if (!(configuration instanceof MapConfiguration)) {
break;
}
MapConfiguration mapConfiguration =
(MapConfiguration)configuration;
if (mapConfiguration.getMap() == properties) {
itr.remove();
classLoaderAggregateProperties.removeConfiguration(
configuration);
}
}
clearCache();
}
catch (Exception e) {
_log.error("The properties could not be removed", e);
}
}
@Override
public void set(String key, String value) {
ComponentProperties componentProperties = getComponentProperties();
componentProperties.setProperty(key, value);
_values.put(key, value);
}
protected String buildFilterCacheKey(
String key, Filter filter, boolean arrayValue) {
if (filter.getVariables() != null) {
return null;
}
String[] selectors = filter.getSelectors();
int length = 0;
if (arrayValue) {
length = selectors.length + 2;
}
else {
length = selectors.length + 1;
}
StringBundler sb = new StringBundler(length);
if (arrayValue) {
sb.append(_ARRAY_KEY_PREFIX);
}
sb.append(key);
sb.append(selectors);
return sb.toString();
}
protected Object fixArrayValue(String cacheKey, String[] array) {
if (cacheKey == null) {
return array;
}
Object value = _nullValue;
if (ArrayUtil.isNotEmpty(array)) {
// Commons Configuration parses an empty property into a String
// array with one String containing one space. It also leaves a
// trailing array member if you set a property in more than one
// line.
if (Validator.isNull(array[array.length - 1])) {
String[] subArray = new String[array.length - 1];
System.arraycopy(array, 0, subArray, 0, subArray.length);
array = subArray;
}
if (array.length > 0) {
value = array;
}
}
_values.put(cacheKey, value);
return value;
}
protected ComponentProperties getComponentProperties() {
return _componentConfiguration.getProperties();
}
protected com.germinus.easyconf.Filter getEasyConfFilter(Filter filter) {
com.germinus.easyconf.Filter easyConfFilter =
com.germinus.easyconf.Filter.by(filter.getSelectors());
if (filter.getVariables() != null) {
easyConfFilter.setVariables(filter.getVariables());
}
return easyConfFilter;
}
protected void printSources(long companyId, String webId) {
ComponentProperties componentProperties = getComponentProperties();
List<String> sources = componentProperties.getLoadedSources();
for (int i = sources.size() - 1; i >= 0; i--) {
String source = sources.get(i);
if (_printedSources.contains(source)) {
continue;
}
_printedSources.add(source);
String info = "Loading " + source;
if (companyId > CompanyConstants.SYSTEM) {
info +=
" for {companyId=" + companyId + ", webId=" + webId + "}";
}
System.out.println(info);
}
}
private static final String _ARRAY_KEY_PREFIX = "ARRAY_";
private static final boolean _PRINT_DUPLICATE_CALLS_TO_GET = false;
private static Log _log = LogFactoryUtil.getLog(ConfigurationImpl.class);
private static String[] _emptyArray = new String[0];
private static Object _nullValue = new Object();
private ComponentConfiguration _componentConfiguration;
private Set<String> _printedSources = new HashSet<String>();
private Map<String, Object> _values =
new ConcurrentHashMap<String, Object>();
}

383
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/configuration/easyconf/ClassLoaderAggregateProperties.java

@ -0,0 +1,383 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.configuration.easyconf;
import com.germinus.easyconf.AggregatedProperties;
import com.germinus.easyconf.ConfigurationException;
import com.germinus.easyconf.Conventions;
import com.germinus.easyconf.DatasourceURL;
import com.germinus.easyconf.FileConfigurationChangedReloadingStrategy;
import com.germinus.easyconf.JndiURL;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.ArrayUtil;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.configuration.AbstractFileConfiguration;
import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.FileConfiguration;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.SubsetConfiguration;
import org.apache.commons.configuration.SystemConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
/**
* @author Raymond Augé
*/
public class ClassLoaderAggregateProperties extends AggregatedProperties {
public ClassLoaderAggregateProperties(
ClassLoader classLoader, String companyId, String componentName) {
super(companyId, componentName);
_classLoader = classLoader;
_companyId = companyId;
_componentName = componentName;
_prefixedSystemConfiguration = new SubsetConfiguration(
_systemConfiguration, _getPrefix(), null);
}
@Override
public void addBaseFileName(String fileName) {
URL url = _classLoader.getResource(fileName);
Configuration configuration = _addPropertiesSource(
fileName, url, _baseCompositeConfiguration);
if ((configuration != null) && !configuration.isEmpty()) {
_baseConfigurationLoaded = true;
}
}
@Override
public void addGlobalFileName(String fileName) {
URL url = _classLoader.getResource(fileName);
_addPropertiesSource(fileName, url, _globalCompositeConfiguration);
}
public CompositeConfiguration getBaseConfiguration() {
return _baseCompositeConfiguration;
}
@Override
public String getComponentName() {
return _componentName;
}
@Override
public Object getProperty(String key) {
Object value = null;
if (value == null) {
value = System.getProperty(_getPrefix().concat(key));
}
if (value == null) {
value = _globalCompositeConfiguration.getProperty(
_getPrefix().concat(key));
}
if (value == null) {
value = _globalCompositeConfiguration.getProperty(key);
}
if (value == null) {
value = _baseCompositeConfiguration.getProperty(key);
}
if (value == null) {
value = super.getProperty(key);
}
if (value == null) {
value = System.getProperty(key);
}
if ((value == null) && key.equals(Conventions.COMPANY_ID_PROPERTY)) {
value = _companyId;
}
if ((value == null) &&
key.equals(Conventions.COMPONENT_NAME_PROPERTY)) {
value = _componentName;
}
return value;
}
@Override
public boolean hasBaseConfiguration() {
return _baseConfigurationLoaded;
}
@Override
public List<String> loadedSources() {
return _loadedSources;
}
private Configuration _addDatasourceProperties(String datasourcePath) {
DatasourceURL datasourceURL = new DatasourceURL(
datasourcePath, _companyId, _componentName,
DatasourceURL.PROPERTIES_TABLE);
return datasourceURL.getConfiguration();
}
private Configuration _addFileProperties(
String fileName,
CompositeConfiguration loadedCompositeConfiguration)
throws ConfigurationException {
try {
FileConfiguration newFileConfiguration =
new PropertiesConfiguration(fileName);
URL url = newFileConfiguration.getURL();
if (_log.isDebugEnabled()) {
_log.debug("Adding file " + url);
}
Long delay = _getReloadDelay(
loadedCompositeConfiguration, newFileConfiguration);
if (delay != null) {
FileChangedReloadingStrategy fileChangedReloadingStrategy =
new FileConfigurationChangedReloadingStrategy();
if (_log.isDebugEnabled()) {
_log.debug(
"File " + url + " will be reloaded every " +
delay + " seconds");
}
long milliseconds = delay.longValue() * 1000;
fileChangedReloadingStrategy.setRefreshDelay(milliseconds);
newFileConfiguration.setReloadingStrategy(
fileChangedReloadingStrategy);
}
_addIncludedPropertiesSources(
newFileConfiguration, loadedCompositeConfiguration);
return newFileConfiguration;
}
catch (org.apache.commons.configuration.ConfigurationException ce) {
if (_log.isDebugEnabled()) {
_log.debug("Configuration source " + fileName + " ignored");
}
return null;
}
}
private void _addIncludedPropertiesSources(
Configuration newConfiguration,
CompositeConfiguration loadedCompositeConfiguration) {
CompositeConfiguration tempCompositeConfiguration =
new CompositeConfiguration();
tempCompositeConfiguration.addConfiguration(
_prefixedSystemConfiguration);
tempCompositeConfiguration.addConfiguration(newConfiguration);
tempCompositeConfiguration.addConfiguration(_systemConfiguration);
tempCompositeConfiguration.addProperty(
Conventions.COMPANY_ID_PROPERTY, _companyId);
tempCompositeConfiguration.addProperty(
Conventions.COMPONENT_NAME_PROPERTY, _componentName);
String[] fileNames = tempCompositeConfiguration.getStringArray(
Conventions.INCLUDE_PROPERTY);
ArrayUtil.reverse(fileNames);
for (String fileName : fileNames) {
URL url = null;
try {
url = _classLoader.getResource(fileName);
}
catch (RuntimeException re) {
if (fileName.startsWith("file:/")) {
throw re;
}
fileName = "file:/".concat(fileName);
url = _classLoader.getResource(fileName);
}
_addPropertiesSource(fileName, url, loadedCompositeConfiguration);
}
}
private Configuration _addJNDIProperties(String sourcePath) {
JndiURL jndiURL = new JndiURL(sourcePath, _companyId, _componentName);
return jndiURL.getConfiguration();
}
private Configuration _addPropertiesSource(
String sourceName, URL url,
CompositeConfiguration loadedCompositeConfiguration) {
try {
Configuration newConfiguration = null;
if (DatasourceURL.isDatasource(sourceName)) {
newConfiguration = _addDatasourceProperties(sourceName);
}
else if (JndiURL.isJndi(sourceName)) {
newConfiguration = _addJNDIProperties(sourceName);
}
else if (url != null) {
newConfiguration = _addURLProperties(
url, loadedCompositeConfiguration);
}
else {
newConfiguration = _addFileProperties(
sourceName, loadedCompositeConfiguration);
}
if (newConfiguration == null) {
return newConfiguration;
}
loadedCompositeConfiguration.addConfiguration(newConfiguration);
super.addConfiguration(newConfiguration);
if (newConfiguration instanceof AbstractFileConfiguration) {
AbstractFileConfiguration abstractFileConfiguration =
(AbstractFileConfiguration)newConfiguration;
URL abstractFileConfigurationURL =
abstractFileConfiguration.getURL();
_loadedSources.add(abstractFileConfigurationURL.toString());
}
else {
_loadedSources.add(sourceName);
}
return newConfiguration;
}
catch (Exception e) {
if (_log.isDebugEnabled()) {
_log.debug(
"Configuration source " + sourceName + " ignored: " +
e.getMessage());
}
return null;
}
}
private Configuration _addURLProperties(
URL url, CompositeConfiguration loadedCompositeConfiguration)
throws ConfigurationException {
try {
FileConfiguration newFileConfiguration =
new PropertiesConfiguration(url);
if (_log.isDebugEnabled()) {
_log.debug("Adding resource " + url);
}
Long delay = _getReloadDelay(
loadedCompositeConfiguration, newFileConfiguration);
if (delay != null) {
FileChangedReloadingStrategy fileChangedReloadingStrategy =
new FileConfigurationChangedReloadingStrategy();
if (_log.isDebugEnabled()) {
_log.debug(
"Resource " + url + " will be reloaded every " +
delay + " seconds");
}
long milliseconds = delay.longValue() * 1000;
fileChangedReloadingStrategy.setRefreshDelay(milliseconds);
newFileConfiguration.setReloadingStrategy(
fileChangedReloadingStrategy);
}
_addIncludedPropertiesSources(
newFileConfiguration, loadedCompositeConfiguration);
return newFileConfiguration;
}
catch (org.apache.commons.configuration.ConfigurationException ce) {
if (_log.isDebugEnabled()) {
_log.debug("Configuration source " + url + " ignored");
}
return null;
}
}
private String _getPrefix() {
return _componentName.concat(Conventions.PREFIX_SEPARATOR);
}
private Long _getReloadDelay(
CompositeConfiguration loadedCompositeConfiguration,
FileConfiguration newFileConfiguration) {
Long delay = newFileConfiguration.getLong(
Conventions.RELOAD_DELAY_PROPERTY, null);
if (delay == null) {
delay = loadedCompositeConfiguration.getLong(
Conventions.RELOAD_DELAY_PROPERTY, null);
}
return delay;
}
private static Log _log = LogFactoryUtil.getLog(
ClassLoaderAggregateProperties.class);
private CompositeConfiguration _baseCompositeConfiguration =
new CompositeConfiguration();
private boolean _baseConfigurationLoaded;
private ClassLoader _classLoader;
private String _companyId;
private String _componentName;
private CompositeConfiguration _globalCompositeConfiguration =
new CompositeConfiguration();
private List<String> _loadedSources = new ArrayList<String>();
private Configuration _prefixedSystemConfiguration;
private SystemConfiguration _systemConfiguration =
new SystemConfiguration();
}

161
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/configuration/easyconf/ClassLoaderComponentConfiguration.java

@ -0,0 +1,161 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.configuration.easyconf;
import com.germinus.easyconf.AggregatedProperties;
import com.germinus.easyconf.ComponentConfiguration;
import com.germinus.easyconf.ComponentProperties;
import com.germinus.easyconf.ConfigurationNotFoundException;
import com.germinus.easyconf.Conventions;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.SystemProperties;
import java.lang.reflect.Constructor;
/**
* @author Raymond Augé
*/
public class ClassLoaderComponentConfiguration extends ComponentConfiguration {
public ClassLoaderComponentConfiguration(
ClassLoader classLoader, String companyId, String componentName) {
super(companyId, componentName);
_classLoader = classLoader;
_companyId = companyId;
_componentName = componentName;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ComponentConfiguration)) {
return false;
}
ComponentConfiguration componentConfiguration =
(ComponentConfiguration)obj;
return _componentName.equals(componentConfiguration.getComponentName());
}
@Override
public String getComponentName() {
return _componentName;
}
@Override
public Object getConfigurationObject() {
throw new UnsupportedOperationException();
}
@Override
public Object getConfigurationObject(String configurationName) {
throw new UnsupportedOperationException();
}
@Override
public ComponentProperties getProperties() {
ComponentProperties componentProperties = _getAvailableProperties();
if (!componentProperties.hasBaseConfiguration()) {
throw new ConfigurationNotFoundException(
_componentName, "The base properties file was not found");
}
return componentProperties;
}
@Override
public int hashCode() {
return _componentName.hashCode();
}
@Override
public void saveConfigurationObject(Object configurationObject) {
throw new UnsupportedOperationException();
}
@Override
public void saveConfigurationObject(
String confName, Object configurationObject) {
throw new UnsupportedOperationException();
}
private ComponentProperties _getAvailableProperties() {
if (_properties != null) {
return _properties;
}
SystemProperties.set("base.path", ".");
ClassLoaderAggregateProperties classLoaderAggregateProperties =
new ClassLoaderAggregateProperties(
_classLoader, _companyId, _componentName);
classLoaderAggregateProperties.addGlobalFileName(
Conventions.GLOBAL_CONFIGURATION_FILE +
Conventions.PROPERTIES_EXTENSION);
classLoaderAggregateProperties.addBaseFileName(
_componentName + Conventions.PROPERTIES_EXTENSION);
if (_log.isInfoEnabled()) {
_log.info(
"Properties for " + _componentName + " loaded from " +
classLoaderAggregateProperties.loadedSources());
}
try {
_properties = _constructor.newInstance(
new Object[] {classLoaderAggregateProperties});
}
catch (Exception e) {
_log.error(e, e);
}
return _properties;
}
private static Log _log = LogFactoryUtil.getLog(
ClassLoaderComponentConfiguration.class);
private static Constructor<ComponentProperties> _constructor;
static {
try {
_constructor = ComponentProperties.class.getDeclaredConstructor(
AggregatedProperties.class);
_constructor.setAccessible(true);
}
catch (Exception e) {
_log.error(e, e);
}
}
private ClassLoader _classLoader;
private String _companyId;
private String _componentName;
private ComponentProperties _properties;
}

253
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/image/ImageMagickImpl.java

@ -0,0 +1,253 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.image;
import com.liferay.portal.kernel.configuration.Filter;
import com.liferay.portal.kernel.image.ImageMagick;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.security.pacl.DoPrivileged;
import com.liferay.portal.kernel.util.NamedThreadFactory;
import com.liferay.portal.kernel.util.OSDetector;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.util.ClassLoaderUtil;
import com.liferay.portal.util.PrefsPropsUtil;
import com.liferay.portal.util.PropsUtil;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.Future;
import javax.portlet.PortletPreferences;
import org.im4java.process.ArrayListOutputConsumer;
import org.im4java.process.ProcessExecutor;
import org.im4java.process.ProcessTask;
/**
* @author Alexander Chow
* @author Ivica Cardic
*/
@DoPrivileged
public class ImageMagickImpl implements ImageMagick {
public static ImageMagickImpl getInstance() {
return _instance;
}
@Override
public Future<?> convert(List<String> arguments) throws Exception {
if (!isEnabled()) {
throw new IllegalStateException(
"Cannot call \"convert\" when ImageMagick is disabled");
}
ProcessExecutor processExecutor = _getProcessExecutor();
LiferayConvertCmd liferayConvertCmd = new LiferayConvertCmd();
ProcessTask processTask = liferayConvertCmd.getProcessTask(
_globalSearchPath, getResourceLimits(), arguments);
processExecutor.execute(processTask);
return processTask;
}
@Override
public void destroy() {
if (_processExecutor == null) {
return;
}
synchronized (ProcessExecutor.class) {
_processExecutor.shutdownNow();
}
_processExecutor = null;
}
@Override
public String getGlobalSearchPath() throws Exception {
PortletPreferences preferences = PrefsPropsUtil.getPreferences(true);
String globalSearchPath = preferences.getValue(
PropsKeys.IMAGEMAGICK_GLOBAL_SEARCH_PATH, null);
if (Validator.isNotNull(globalSearchPath)) {
return globalSearchPath;
}
String filterName = null;
if (OSDetector.isApple()) {
filterName = "apple";
}
else if (OSDetector.isWindows()) {
filterName = "windows";
}
else {
filterName = "unix";
}
return PropsUtil.get(
PropsKeys.IMAGEMAGICK_GLOBAL_SEARCH_PATH, new Filter(filterName));
}
@Override
public Properties getResourceLimitsProperties() throws Exception {
Properties resourceLimitsProperties = PrefsPropsUtil.getProperties(
PropsKeys.IMAGEMAGICK_RESOURCE_LIMIT, true);
if (resourceLimitsProperties.isEmpty()) {
resourceLimitsProperties = PropsUtil.getProperties(
PropsKeys.IMAGEMAGICK_RESOURCE_LIMIT, true);
}
return resourceLimitsProperties;
}
@Override
public String[] identify(List<String> arguments) throws Exception {
if (!isEnabled()) {
throw new IllegalStateException(
"Cannot call \"identify\" when ImageMagick is disabled");
}
ProcessExecutor processExecutor = _getProcessExecutor();
LiferayIdentifyCmd liferayIdentifyCmd = new LiferayIdentifyCmd();
ArrayListOutputConsumer arrayListOutputConsumer =
new ArrayListOutputConsumer();
liferayIdentifyCmd.setOutputConsumer(arrayListOutputConsumer);
ProcessTask processTask = liferayIdentifyCmd.getProcessTask(
_globalSearchPath, getResourceLimits(), arguments);
processExecutor.execute(processTask);
processTask.get();
List<String> output = arrayListOutputConsumer.getOutput();
if (output != null) {
return output.toArray(new String[output.size()]);
}
return new String[0];
}
@Override
public boolean isEnabled() {
boolean enabled = false;
try {
enabled = PrefsPropsUtil.getBoolean(PropsKeys.IMAGEMAGICK_ENABLED);
}
catch (Exception e) {
if (_log.isWarnEnabled()) {
_log.warn(e, e);
}
}
if (!enabled && !_warned && _log.isWarnEnabled()) {
StringBundler sb = new StringBundler(7);
sb.append("Liferay is not configured to use ImageMagick and ");
sb.append("Ghostscript. For better quality document and image ");
sb.append("previews, install ImageMagick and Ghostscript. Enable ");
sb.append("ImageMagick in portal-ext.properties or in the Server ");
sb.append("Administration section of the Control Panel at: ");
sb.append("http://<server>/group/control_panel/manage/-/server/");
sb.append("external-services");
_log.warn(sb.toString());
_warned = true;
}
return enabled;
}
@Override
public void reset() {
if (isEnabled()) {
try {
_globalSearchPath = getGlobalSearchPath();
_resourceLimitsProperties = getResourceLimitsProperties();
}
catch (Exception e) {
_log.error(e, e);
}
}
}
protected LinkedList<String> getResourceLimits() {
LinkedList<String> resourceLimits = new LinkedList<String>();
if (_resourceLimitsProperties == null) {
return resourceLimits;
}
for (Object key : _resourceLimitsProperties.keySet()) {
String value = (String)_resourceLimitsProperties.get(key);
if (Validator.isNull(value)) {
continue;
}
resourceLimits.add("-limit");
resourceLimits.add((String)key);
resourceLimits.add(value);
}
return resourceLimits;
}
private ProcessExecutor _getProcessExecutor() {
if (_processExecutor != null) {
return _processExecutor;
}
synchronized (ProcessExecutor.class) {
if (_processExecutor == null) {
_processExecutor = new ProcessExecutor();
_processExecutor.setThreadFactory(
new NamedThreadFactory(
ImageMagickImpl.class.getName(), Thread.MIN_PRIORITY,
ClassLoaderUtil.getPortalClassLoader()));
}
}
return _processExecutor;
}
private static Log _log = LogFactoryUtil.getLog(ImageMagickImpl.class);
private static ImageMagickImpl _instance = new ImageMagickImpl();
private String _globalSearchPath;
private volatile ProcessExecutor _processExecutor;
private Properties _resourceLimitsProperties;
private boolean _warned;
}

710
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/image/ImageToolImpl.java

@ -0,0 +1,710 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.image;
import com.liferay.portal.kernel.image.ImageBag;
import com.liferay.portal.kernel.image.ImageMagick;
import com.liferay.portal.kernel.image.ImageTool;
import com.liferay.portal.kernel.io.unsync.UnsyncByteArrayInputStream;
import com.liferay.portal.kernel.io.unsync.UnsyncByteArrayOutputStream;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.security.pacl.DoPrivileged;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.util.JavaDetector;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.model.Image;
import com.liferay.portal.model.impl.ImageImpl;
import com.liferay.portal.util.FileImpl;
import com.liferay.portal.util.PropsUtil;
import com.liferay.portal.util.PropsValues;
import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.ImageDecoder;
import com.sun.media.jai.codec.ImageEncoder;
import java.awt.AlphaComposite;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.IndexColorModel;
import java.awt.image.RenderedImage;
import java.awt.image.SampleModel;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.imageio.ImageIO;
import javax.media.jai.RenderedImageAdapter;
import net.jmge.gif.Gif89Encoder;
import org.im4java.core.IMOperation;
/**
* @author Brian Wing Shun Chan
* @author Alexander Chow
* @author Shuyang Zhou
*/
@DoPrivileged
public class ImageToolImpl implements ImageTool {
public static ImageTool getInstance() {
return _instance;
}
public void afterPropertiesSet() {
ClassLoader classLoader = getClass().getClassLoader();
try {
InputStream is = classLoader.getResourceAsStream(
PropsUtil.get(PropsKeys.IMAGE_DEFAULT_SPACER));
if (is == null) {
_log.error("Default spacer is not available");
}
_defaultSpacer = getImage(is);
}
catch (Exception e) {
_log.error(
"Unable to configure the default spacer: " + e.getMessage());
}
try {
InputStream is = classLoader.getResourceAsStream(
PropsUtil.get(PropsKeys.IMAGE_DEFAULT_COMPANY_LOGO));
if (is == null) {
_log.error("Default company logo is not available");
}
_defaultCompanyLogo = getImage(is);
}
catch (Exception e) {
_log.error(
"Unable to configure the default company logo: " +
e.getMessage());
}
try {
InputStream is = classLoader.getResourceAsStream(
PropsUtil.get(PropsKeys.IMAGE_DEFAULT_ORGANIZATION_LOGO));
if (is == null) {
_log.error("Default organization logo is not available");
}
_defaultOrganizationLogo = getImage(is);
}
catch (Exception e) {
_log.error(
"Unable to configure the default organization logo: " +
e.getMessage());
}
try {
InputStream is = classLoader.getResourceAsStream(
PropsUtil.get(PropsKeys.IMAGE_DEFAULT_USER_FEMALE_PORTRAIT));
if (is == null) {
_log.error("Default user female portrait is not available");
}
_defaultUserFemalePortrait = getImage(is);
}
catch (Exception e) {
_log.error(
"Unable to configure the default user female portrait: " +
e.getMessage());
}
try {
InputStream is = classLoader.getResourceAsStream(
PropsUtil.get(PropsKeys.IMAGE_DEFAULT_USER_MALE_PORTRAIT));
if (is == null) {
_log.error("Default user male portrait is not available");
}
_defaultUserMalePortrait = getImage(is);
}
catch (Exception e) {
_log.error(
"Unable to configure the default user male portrait: " +
e.getMessage());
}
}
@Override
public Future<RenderedImage> convertCMYKtoRGB(byte[] bytes, String type) {
ImageMagick imageMagick = getImageMagick();
if (!imageMagick.isEnabled()) {
return null;
}
File inputFile = _fileUtil.createTempFile(type);
File outputFile = _fileUtil.createTempFile(type);
try {
_fileUtil.write(inputFile, bytes);
IMOperation imOperation = new IMOperation();
imOperation.addRawArgs("-format", "%[colorspace]");
imOperation.addImage(inputFile.getPath());
String[] output = imageMagick.identify(imOperation.getCmdArgs());
if ((output.length == 1) &&
StringUtil.equalsIgnoreCase(output[0], "CMYK")) {
if (_log.isInfoEnabled()) {
_log.info("The image is in the CMYK colorspace");
}
imOperation = new IMOperation();
imOperation.addRawArgs("-colorspace", "RGB");
imOperation.addImage(inputFile.getPath());
imOperation.addImage(outputFile.getPath());
Future<?> future = imageMagick.convert(
imOperation.getCmdArgs());
return new RenderedImageFuture(future, outputFile, type);
}
}
catch (Exception e) {
if (_log.isErrorEnabled()) {
_log.error(e, e);
}
}
finally {
_fileUtil.delete(inputFile);
_fileUtil.delete(outputFile);
}
return null;
}
@Override
public BufferedImage convertImageType(BufferedImage sourceImage, int type) {
BufferedImage targetImage = new BufferedImage(
sourceImage.getWidth(), sourceImage.getHeight(), type);
Graphics2D graphics = targetImage.createGraphics();
graphics.drawRenderedImage(sourceImage, null);
graphics.dispose();
return targetImage;
}
@Override
public void encodeGIF(RenderedImage renderedImage, OutputStream os)
throws IOException {
if (JavaDetector.isJDK6()) {
ImageIO.write(renderedImage, TYPE_GIF, os);
}
else {
BufferedImage bufferedImage = getBufferedImage(renderedImage);
if (!(bufferedImage.getColorModel() instanceof IndexColorModel)) {
bufferedImage = convertImageType(
bufferedImage, BufferedImage.TYPE_BYTE_INDEXED);
}
Gif89Encoder encoder = new Gif89Encoder(bufferedImage);
encoder.encode(os);
}
}
@Override
public void encodeWBMP(RenderedImage renderedImage, OutputStream os)
throws IOException {
BufferedImage bufferedImage = getBufferedImage(renderedImage);
SampleModel sampleModel = bufferedImage.getSampleModel();
int type = sampleModel.getDataType();
if ((bufferedImage.getType() != BufferedImage.TYPE_BYTE_BINARY) ||
(type < DataBuffer.TYPE_BYTE) || (type > DataBuffer.TYPE_INT) ||
(sampleModel.getNumBands() != 1) ||
(sampleModel.getSampleSize(0) != 1)) {
BufferedImage binaryImage = new BufferedImage(
bufferedImage.getWidth(), bufferedImage.getHeight(),
BufferedImage.TYPE_BYTE_BINARY);
Graphics graphics = binaryImage.getGraphics();
graphics.drawImage(bufferedImage, 0, 0, null);
renderedImage = binaryImage;
}
if (!ImageIO.write(renderedImage, "wbmp", os)) {
// See http://www.jguru.com/faq/view.jsp?EID=127723
os.write(0);
os.write(0);
os.write(toMultiByte(bufferedImage.getWidth()));
os.write(toMultiByte(bufferedImage.getHeight()));
DataBuffer dataBuffer = bufferedImage.getData().getDataBuffer();
int size = dataBuffer.getSize();
for (int i = 0; i < size; i++) {
os.write((byte)dataBuffer.getElem(i));
}
}
}
@Override
public BufferedImage getBufferedImage(RenderedImage renderedImage) {
if (renderedImage instanceof BufferedImage) {
return (BufferedImage)renderedImage;
}
RenderedImageAdapter adapter = new RenderedImageAdapter(renderedImage);
return adapter.getAsBufferedImage();
}
@Override
public byte[] getBytes(RenderedImage renderedImage, String contentType)
throws IOException {
UnsyncByteArrayOutputStream baos = new UnsyncByteArrayOutputStream();
write(renderedImage, contentType, baos);
return baos.toByteArray();
}
@Override
public Image getDefaultCompanyLogo() {
return _defaultCompanyLogo;
}
@Override
public Image getDefaultOrganizationLogo() {
return _defaultOrganizationLogo;
}
@Override
public Image getDefaultSpacer() {
return _defaultSpacer;
}
@Override
public Image getDefaultUserFemalePortrait() {
return _defaultUserFemalePortrait;
}
@Override
public Image getDefaultUserMalePortrait() {
return _defaultUserMalePortrait;
}
@Override
public Image getImage(byte[] bytes) throws IOException {
if (bytes == null) {
return null;
}
ImageBag imageBag = read(bytes);
RenderedImage renderedImage = imageBag.getRenderedImage();
if (renderedImage == null) {
throw new IOException("Unable to decode image");
}
String type = imageBag.getType();
int height = renderedImage.getHeight();
int width = renderedImage.getWidth();
int size = bytes.length;
Image image = new ImageImpl();
image.setTextObj(bytes);
image.setType(type);
image.setHeight(height);
image.setWidth(width);
image.setSize(size);
return image;
}
@Override
public Image getImage(File file) throws IOException {
byte[] bytes = _fileUtil.getBytes(file);
return getImage(bytes);
}
@Override
public Image getImage(InputStream is) throws IOException {
byte[] bytes = _fileUtil.getBytes(is, -1, true);
return getImage(bytes);
}
@Override
public Image getImage(InputStream is, boolean cleanUpStream)
throws IOException {
byte[] bytes = _fileUtil.getBytes(is, -1, cleanUpStream);
return getImage(bytes);
}
@Override
public boolean isNullOrDefaultSpacer(byte[] bytes) {
if (ArrayUtil.isEmpty(bytes) ||
Arrays.equals(bytes, getDefaultSpacer().getTextObj())) {
return true;
}
else {
return false;
}
}
@Override
public ImageBag read(byte[] bytes) {
RenderedImage renderedImage = null;
String type = TYPE_NOT_AVAILABLE;
Enumeration<ImageCodec> enu = ImageCodec.getCodecs();
while (enu.hasMoreElements()) {
ImageCodec codec = enu.nextElement();
if (codec.isFormatRecognized(bytes)) {
type = codec.getFormatName();
renderedImage = read(bytes, type);
break;
}
}
if (type.equals("jpeg")) {
type = TYPE_JPEG;
}
return new ImageBag(renderedImage, type);
}
@Override
public ImageBag read(File file) throws IOException {
return read(_fileUtil.getBytes(file));
}
@Override
public ImageBag read(InputStream inputStream) throws IOException {
return read(_fileUtil.getBytes(inputStream));
}
@Override
public RenderedImage scale(RenderedImage renderedImage, int width) {
if (width <= 0) {
return renderedImage;
}
int imageHeight = renderedImage.getHeight();
int imageWidth = renderedImage.getWidth();
double factor = (double)width / imageWidth;
int scaledHeight = (int)Math.round(factor * imageHeight);
int scaledWidth = width;
return doScale(renderedImage, scaledHeight, scaledWidth);
}
@Override
public RenderedImage scale(
RenderedImage renderedImage, int maxHeight, int maxWidth) {
int imageHeight = renderedImage.getHeight();
int imageWidth = renderedImage.getWidth();
if (maxHeight == 0) {
maxHeight = imageHeight;
}
if (maxWidth == 0) {
maxWidth = imageWidth;
}
if ((imageHeight <= maxHeight) && (imageWidth <= maxWidth)) {
return renderedImage;
}
double factor = Math.min(
(double)maxHeight / imageHeight, (double)maxWidth / imageWidth);
int scaledHeight = Math.max(1, (int)Math.round(factor * imageHeight));
int scaledWidth = Math.max(1, (int)Math.round(factor * imageWidth));
return doScale(renderedImage, scaledHeight, scaledWidth);
}
@Override
public void write(
RenderedImage renderedImage, String contentType, OutputStream os)
throws IOException {
if (contentType.contains(TYPE_BMP)) {
ImageEncoder imageEncoder = ImageCodec.createImageEncoder(
TYPE_BMP, os, null);
imageEncoder.encode(renderedImage);
}
else if (contentType.contains(TYPE_GIF)) {
encodeGIF(renderedImage, os);
}
else if (contentType.contains(TYPE_JPEG) ||
contentType.contains("jpeg")) {
ImageIO.write(renderedImage, "jpeg", os);
}
else if (contentType.contains(TYPE_PNG)) {
ImageIO.write(renderedImage, TYPE_PNG, os);
}
else if (contentType.contains(TYPE_TIFF) ||
contentType.contains("tif")) {
ImageEncoder imageEncoder = ImageCodec.createImageEncoder(
TYPE_TIFF, os, null);
imageEncoder.encode(renderedImage);
}
}
protected RenderedImage doScale(
RenderedImage renderedImage, int scaledHeight, int scaledWidth) {
// See http://www.oracle.com/technetwork/java/index-137037.html
BufferedImage originalBufferedImage = getBufferedImage(renderedImage);
ColorModel originalColorModel = originalBufferedImage.getColorModel();
Graphics2D originalGraphics2D = originalBufferedImage.createGraphics();
if (originalColorModel.hasAlpha()) {
originalGraphics2D.setComposite(AlphaComposite.Src);
}
GraphicsConfiguration originalGraphicsConfiguration =
originalGraphics2D.getDeviceConfiguration();
BufferedImage scaledBufferedImage =
originalGraphicsConfiguration.createCompatibleImage(
scaledWidth, scaledHeight,
originalBufferedImage.getTransparency());
Graphics scaledGraphics = scaledBufferedImage.getGraphics();
scaledGraphics.drawImage(
originalBufferedImage.getScaledInstance(
scaledWidth, scaledHeight, java.awt.Image.SCALE_SMOOTH),
0, 0, null);
originalGraphics2D.dispose();
return scaledBufferedImage;
}
protected ImageMagick getImageMagick() {
if (_imageMagick == null) {
_imageMagick = ImageMagickImpl.getInstance();
_imageMagick.reset();
}
return _imageMagick;
}
protected RenderedImage read(byte[] bytes, String type) {
RenderedImage renderedImage = null;
try {
if (type.equals(TYPE_JPEG)) {
type = "jpeg";
}
ImageDecoder imageDecoder = ImageCodec.createImageDecoder(
type, new UnsyncByteArrayInputStream(bytes), null);
renderedImage = imageDecoder.decodeAsRenderedImage();
}
catch (IOException ioe) {
if (_log.isDebugEnabled()) {
_log.debug(type + ": " + ioe.getMessage());
}
}
return renderedImage;
}
protected byte[] toMultiByte(int intValue) {
int numBits = 32;
int mask = 0x80000000;
while ((mask != 0) && ((intValue & mask) == 0)) {
numBits--;
mask >>>= 1;
}
int numBitsLeft = numBits;
byte[] multiBytes = new byte[(numBitsLeft + 6) / 7];
int maxIndex = multiBytes.length - 1;
for (int b = 0; b <= maxIndex; b++) {
multiBytes[b] = (byte)((intValue >>> ((maxIndex - b) * 7)) & 0x7f);
if (b != maxIndex) {
multiBytes[b] |= (byte)0x80;
}
}
return multiBytes;
}
private ImageToolImpl() {
ImageIO.setUseCache(PropsValues.IMAGE_IO_USE_DISK_CACHE);
}
private static Log _log = LogFactoryUtil.getLog(ImageToolImpl.class);
private static ImageTool _instance = new ImageToolImpl();
private static FileImpl _fileUtil = FileImpl.getInstance();
private static ImageMagick _imageMagick;
private Image _defaultCompanyLogo;
private Image _defaultOrganizationLogo;
private Image _defaultSpacer;
private Image _defaultUserFemalePortrait;
private Image _defaultUserMalePortrait;
private class RenderedImageFuture implements Future<RenderedImage> {
public RenderedImageFuture(
Future<?> future, File outputFile, String type) {
_future = future;
_outputFile = outputFile;
_type = type;
}
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
if (_future.isCancelled() || _future.isDone()) {
return false;
}
_future.cancel(true);
return true;
}
@Override
public RenderedImage get()
throws ExecutionException, InterruptedException {
_future.get();
byte[] bytes = new byte[0];
try {
bytes = _fileUtil.getBytes(_outputFile);
}
catch (IOException ioe) {
throw new ExecutionException(ioe);
}
ImageBag imageBag = read(bytes);
return imageBag.getRenderedImage();
}
@Override
public RenderedImage get(long timeout, TimeUnit timeUnit)
throws ExecutionException, InterruptedException, TimeoutException {
_future.get(timeout, timeUnit);
byte[] bytes = new byte[0];
try {
bytes = _fileUtil.getBytes(_outputFile);
}
catch (IOException ioe) {
throw new ExecutionException(ioe);
}
ImageBag imageBag = read(bytes);
return imageBag.getRenderedImage();
}
@Override
public boolean isCancelled() {
return _future.isCancelled();
}
@Override
public boolean isDone() {
return _future.isDone();
}
private final Future<?> _future;
private final File _outputFile;
private final String _type;
}
}

65
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/image/LiferayConvertCmd.java

@ -0,0 +1,65 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.image;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import java.util.LinkedList;
import java.util.List;
import org.im4java.core.ConvertCmd;
import org.im4java.process.ProcessTask;
/**
* @author Alexander Chow
* @author Ivica Cardic
*/
public class LiferayConvertCmd extends ConvertCmd {
public ProcessTask getProcessTask(
String globalSearchPath, List<String> resourceLimits,
List<String> commandArguments)
throws Exception {
setGlobalSearchPath(globalSearchPath);
LinkedList<String> arguments = new LinkedList<String>();
arguments.addAll(_instance.getCommand());
arguments.addAll(resourceLimits);
arguments.addAll(commandArguments);
if (_log.isInfoEnabled()) {
StringBundler sb = new StringBundler(arguments.size() * 2);
for (String argument : arguments) {
sb.append(argument);
sb.append(StringPool.SPACE);
}
_log.info("Excecuting command '" + sb.toString() + "'");
}
return getProcessTask(arguments);
}
private static Log _log = LogFactoryUtil.getLog(LiferayConvertCmd.class);
private static LiferayConvertCmd _instance = new LiferayConvertCmd();
}

65
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/image/LiferayIdentifyCmd.java

@ -0,0 +1,65 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.image;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import java.util.LinkedList;
import java.util.List;
import org.im4java.core.IdentifyCmd;
import org.im4java.process.ProcessTask;
/**
* @author Alexander Chow
* @author Ivica Cardic
*/
public class LiferayIdentifyCmd extends IdentifyCmd {
public ProcessTask getProcessTask(
String globalSearchPath, List<String> resourceLimits,
List<String> commandArguments)
throws Exception {
setGlobalSearchPath(globalSearchPath);
LinkedList<String> arguments = new LinkedList<String>();
arguments.addAll(_instance.getCommand());
arguments.addAll(resourceLimits);
arguments.addAll(commandArguments);
if (_log.isInfoEnabled()) {
StringBundler sb = new StringBundler(arguments.size() * 2);
for (String argument : arguments) {
sb.append(argument);
sb.append(StringPool.SPACE);
}
_log.info("Excecuting command '" + sb.toString() + "'");
}
return getProcessTask(arguments);
}
private static Log _log = LogFactoryUtil.getLog(LiferayIdentifyCmd.class);
private static LiferayIdentifyCmd _instance = new LiferayIdentifyCmd();
}

45
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/log/Log4jLogFactoryImpl.java

@ -0,0 +1,45 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.log;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactory;
import com.liferay.portal.kernel.security.pacl.DoPrivileged;
import com.liferay.util.log4j.Log4JUtil;
import org.apache.log4j.LogManager;
/**
* @author Brian Wing Shun Chan
*/
@DoPrivileged
public class Log4jLogFactoryImpl implements LogFactory {
@Override
public Log getLog(Class<?> c) {
return getLog(c.getName());
}
@Override
public Log getLog(String name) {
return new Log4jLogImpl(LogManager.getLogger(name));
}
@Override
public void setLevel(String name, String priority, boolean custom) {
Log4JUtil.setLevel(name, priority, custom);
}
}

164
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/log/Log4jLogImpl.java

@ -0,0 +1,164 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.log;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogWrapper;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
/**
* @author Brian Wing Shun Chan
*/
public class Log4jLogImpl implements Log {
public Log4jLogImpl(Logger logger) {
_logger = logger;
}
@Override
public void debug(Object msg) {
_logger.log(_logWrapperClassName, Level.DEBUG, msg, null);
}
@Override
public void debug(Object msg, Throwable t) {
_logger.log(_logWrapperClassName, Level.DEBUG, msg, t);
}
@Override
public void debug(Throwable t) {
_logger.log(_logWrapperClassName, Level.DEBUG, null, t);
}
@Override
public void error(Object msg) {
_logger.log(_logWrapperClassName, Level.ERROR, msg, null);
}
@Override
public void error(Object msg, Throwable t) {
_logger.log(_logWrapperClassName, Level.ERROR, msg, t);
}
@Override
public void error(Throwable t) {
_logger.log(_logWrapperClassName, Level.ERROR, null, t);
}
@Override
public void fatal(Object msg) {
_logger.log(_logWrapperClassName, Level.FATAL, msg, null);
}
@Override
public void fatal(Object msg, Throwable t) {
_logger.log(_logWrapperClassName, Level.FATAL, msg, t);
}
@Override
public void fatal(Throwable t) {
_logger.log(_logWrapperClassName, Level.FATAL, null, t);
}
public Logger getWrappedLogger() {
return _logger;
}
@Override
public void info(Object msg) {
_logger.log(_logWrapperClassName, Level.INFO, msg, null);
}
@Override
public void info(Object msg, Throwable t) {
_logger.log(_logWrapperClassName, Level.INFO, msg, t);
}
@Override
public void info(Throwable t) {
_logger.log(_logWrapperClassName, Level.INFO, null, t);
}
@Override
public boolean isDebugEnabled() {
return _logger.isDebugEnabled();
}
@Override
public boolean isErrorEnabled() {
return _logger.isEnabledFor(Level.ERROR);
}
@Override
public boolean isFatalEnabled() {
return _logger.isEnabledFor(Level.FATAL);
}
@Override
public boolean isInfoEnabled() {
return _logger.isInfoEnabled();
}
@Override
public boolean isTraceEnabled() {
return _logger.isTraceEnabled();
}
@Override
public boolean isWarnEnabled() {
return _logger.isEnabledFor(Level.WARN);
}
@Override
public void setLogWrapperClassName(String className) {
_logWrapperClassName = className;
}
@Override
public void trace(Object msg) {
_logger.log(_logWrapperClassName, Level.TRACE, msg, null);
}
@Override
public void trace(Object msg, Throwable t) {
_logger.log(_logWrapperClassName, Level.TRACE, msg, t);
}
@Override
public void trace(Throwable t) {
_logger.log(_logWrapperClassName, Level.TRACE, null, t);
}
@Override
public void warn(Object msg) {
_logger.log(_logWrapperClassName, Level.WARN, msg, null);
}
@Override
public void warn(Object msg, Throwable t) {
_logger.log(_logWrapperClassName, Level.WARN, msg, t);
}
@Override
public void warn(Throwable t) {
_logger.log(_logWrapperClassName, Level.WARN, null, t);
}
private Logger _logger;
private String _logWrapperClassName = LogWrapper.class.getName();
}

48
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/ImageBaseImpl.java

@ -0,0 +1,48 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.model.impl;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.model.Image;
import com.liferay.portal.service.ImageLocalServiceUtil;
/**
* The extended model base implementation for the Image service. Represents a row in the &quot;Image&quot; database table, with each column mapped to a property of this class.
*
* <p>
* This class exists only as a container for the default extended model level methods generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ImageImpl}.
* </p>
*
* @author Brian Wing Shun Chan
* @see ImageImpl
* @see com.liferay.portal.model.Image
* @generated
*/
public abstract class ImageBaseImpl extends ImageModelImpl implements Image {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. All methods that expect a image model instance should use the {@link Image} interface instead.
*/
@Override
public void persist() throws SystemException {
if (this.isNew()) {
ImageLocalServiceUtil.addImage(this);
}
else {
ImageLocalServiceUtil.updateImage(this);
}
}
}

121
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/ImageCacheModel.java

@ -0,0 +1,121 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.model.impl;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.Image;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Date;
/**
* The cache model class for representing Image in entity cache.
*
* @author Brian Wing Shun Chan
* @see Image
* @generated
*/
public class ImageCacheModel implements CacheModel<Image>, Externalizable {
@Override
public String toString() {
StringBundler sb = new StringBundler(13);
sb.append("{imageId=");
sb.append(imageId);
sb.append(", modifiedDate=");
sb.append(modifiedDate);
sb.append(", type=");
sb.append(type);
sb.append(", height=");
sb.append(height);
sb.append(", width=");
sb.append(width);
sb.append(", size=");
sb.append(size);
sb.append("}");
return sb.toString();
}
@Override
public Image toEntityModel() {
ImageImpl imageImpl = new ImageImpl();
imageImpl.setImageId(imageId);
if (modifiedDate == Long.MIN_VALUE) {
imageImpl.setModifiedDate(null);
}
else {
imageImpl.setModifiedDate(new Date(modifiedDate));
}
if (type == null) {
imageImpl.setType(StringPool.BLANK);
}
else {
imageImpl.setType(type);
}
imageImpl.setHeight(height);
imageImpl.setWidth(width);
imageImpl.setSize(size);
imageImpl.resetOriginalValues();
return imageImpl;
}
@Override
public void readExternal(ObjectInput objectInput) throws IOException {
imageId = objectInput.readLong();
modifiedDate = objectInput.readLong();
type = objectInput.readUTF();
height = objectInput.readInt();
width = objectInput.readInt();
size = objectInput.readInt();
}
@Override
public void writeExternal(ObjectOutput objectOutput)
throws IOException {
objectOutput.writeLong(imageId);
objectOutput.writeLong(modifiedDate);
if (type == null) {
objectOutput.writeUTF(StringPool.BLANK);
}
else {
objectOutput.writeUTF(type);
}
objectOutput.writeInt(height);
objectOutput.writeInt(width);
objectOutput.writeInt(size);
}
public long imageId;
public long modifiedDate;
public String type;
public int height;
public int width;
public int size;
}

95
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/ImageImpl.java

@ -0,0 +1,95 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.model.impl;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.FileUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.util.PropsValues;
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
import com.liferay.portlet.documentlibrary.store.DLStoreUtil;
import java.io.InputStream;
/**
* @author Brian Wing Shun Chan
*/
public class ImageImpl extends ImageBaseImpl {
public ImageImpl() {
}
@Override
public byte[] getTextObj() {
if (_textObj != null) {
return _textObj;
}
long imageId = getImageId();
try {
DLFileEntry dlFileEntry = null;
if (PropsValues.WEB_SERVER_SERVLET_CHECK_IMAGE_GALLERY) {
dlFileEntry =
DLFileEntryLocalServiceUtil.fetchFileEntryByAnyImageId(
imageId);
}
InputStream is = null;
if ((dlFileEntry != null) &&
(dlFileEntry.getLargeImageId() == imageId)) {
is = DLStoreUtil.getFileAsStream(
dlFileEntry.getCompanyId(),
dlFileEntry.getDataRepositoryId(), dlFileEntry.getName());
}
else {
is = DLStoreUtil.getFileAsStream(
_DEFAULT_COMPANY_ID, _DEFAULT_REPOSITORY_ID, getFileName());
}
byte[] bytes = FileUtil.getBytes(is);
_textObj = bytes;
}
catch (Exception e) {
_log.error("Error reading image " + imageId, e);
}
return _textObj;
}
@Override
public void setTextObj(byte[] textObj) {
_textObj = textObj;
}
protected String getFileName() {
return getImageId() + StringPool.PERIOD + getType();
}
private static final long _DEFAULT_COMPANY_ID = 0;
private static final long _DEFAULT_REPOSITORY_ID = 0;
private static Log _log = LogFactoryUtil.getLog(ImageImpl.class);
private byte[] _textObj;
}

512
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/ImageModelImpl.java

@ -0,0 +1,512 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.model.impl;
import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.Image;
import com.liferay.portal.model.ImageModel;
import com.liferay.portal.model.ImageSoap;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
import java.io.Serializable;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The base model implementation for the Image service. Represents a row in the &quot;Image&quot; database table, with each column mapped to a property of this class.
*
* <p>
* This implementation and its corresponding interface {@link com.liferay.portal.model.ImageModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ImageImpl}.
* </p>
*
* @author Brian Wing Shun Chan
* @see ImageImpl
* @see com.liferay.portal.model.Image
* @see com.liferay.portal.model.ImageModel
* @generated
*/
@JSON(strict = true)
public class ImageModelImpl extends BaseModelImpl<Image> implements ImageModel {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. All methods that expect a image model instance should use the {@link com.liferay.portal.model.Image} interface instead.
*/
public static final String TABLE_NAME = "Image";
public static final Object[][] TABLE_COLUMNS = {
{ "imageId", Types.BIGINT },
{ "modifiedDate", Types.TIMESTAMP },
{ "type_", Types.VARCHAR },
{ "height", Types.INTEGER },
{ "width", Types.INTEGER },
{ "size_", Types.INTEGER }
};
public static final String TABLE_SQL_CREATE = "create table Image (imageId LONG not null primary key,modifiedDate DATE null,type_ VARCHAR(75) null,height INTEGER,width INTEGER,size_ INTEGER)";
public static final String TABLE_SQL_DROP = "drop table Image";
public static final String ORDER_BY_JPQL = " ORDER BY image.imageId ASC";
public static final String ORDER_BY_SQL = " ORDER BY Image.imageId ASC";
public static final String DATA_SOURCE = "liferayDataSource";
public static final String SESSION_FACTORY = "liferaySessionFactory";
public static final String TX_MANAGER = "liferayTransactionManager";
public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
"value.object.entity.cache.enabled.com.liferay.portal.model.Image"),
true);
public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
"value.object.finder.cache.enabled.com.liferay.portal.model.Image"),
true);
public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
"value.object.column.bitmask.enabled.com.liferay.portal.model.Image"),
true);
public static long SIZE_COLUMN_BITMASK = 1L;
public static long IMAGEID_COLUMN_BITMASK = 2L;
/**
* Converts the soap model instance into a normal model instance.
*
* @param soapModel the soap model instance to convert
* @return the normal model instance
*/
public static Image toModel(ImageSoap soapModel) {
if (soapModel == null) {
return null;
}
Image model = new ImageImpl();
model.setImageId(soapModel.getImageId());
model.setModifiedDate(soapModel.getModifiedDate());
model.setType(soapModel.getType());
model.setHeight(soapModel.getHeight());
model.setWidth(soapModel.getWidth());
model.setSize(soapModel.getSize());
return model;
}
/**
* Converts the soap model instances into normal model instances.
*
* @param soapModels the soap model instances to convert
* @return the normal model instances
*/
public static List<Image> toModels(ImageSoap[] soapModels) {
if (soapModels == null) {
return null;
}
List<Image> models = new ArrayList<Image>(soapModels.length);
for (ImageSoap soapModel : soapModels) {
models.add(toModel(soapModel));
}
return models;
}
public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
"lock.expiration.time.com.liferay.portal.model.Image"));
public ImageModelImpl() {
}
@Override
public long getPrimaryKey() {
return _imageId;
}
@Override
public void setPrimaryKey(long primaryKey) {
setImageId(primaryKey);
}
@Override
public Serializable getPrimaryKeyObj() {
return _imageId;
}
@Override
public void setPrimaryKeyObj(Serializable primaryKeyObj) {
setPrimaryKey(((Long)primaryKeyObj).longValue());
}
@Override
public Class<?> getModelClass() {
return Image.class;
}
@Override
public String getModelClassName() {
return Image.class.getName();
}
@Override
public Map<String, Object> getModelAttributes() {
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("imageId", getImageId());
attributes.put("modifiedDate", getModifiedDate());
attributes.put("type", getType());
attributes.put("height", getHeight());
attributes.put("width", getWidth());
attributes.put("size", getSize());
return attributes;
}
@Override
public void setModelAttributes(Map<String, Object> attributes) {
Long imageId = (Long)attributes.get("imageId");
if (imageId != null) {
setImageId(imageId);
}
Date modifiedDate = (Date)attributes.get("modifiedDate");
if (modifiedDate != null) {
setModifiedDate(modifiedDate);
}
String type = (String)attributes.get("type");
if (type != null) {
setType(type);
}
Integer height = (Integer)attributes.get("height");
if (height != null) {
setHeight(height);
}
Integer width = (Integer)attributes.get("width");
if (width != null) {
setWidth(width);
}
Integer size = (Integer)attributes.get("size");
if (size != null) {
setSize(size);
}
}
@JSON
@Override
public long getImageId() {
return _imageId;
}
@Override
public void setImageId(long imageId) {
_columnBitmask = -1L;
_imageId = imageId;
}
@JSON
@Override
public Date getModifiedDate() {
return _modifiedDate;
}
@Override
public void setModifiedDate(Date modifiedDate) {
_modifiedDate = modifiedDate;
}
@JSON
@Override
public String getType() {
if (_type == null) {
return StringPool.BLANK;
}
else {
return _type;
}
}
@Override
public void setType(String type) {
_type = type;
}
@JSON
@Override
public int getHeight() {
return _height;
}
@Override
public void setHeight(int height) {
_height = height;
}
@JSON
@Override
public int getWidth() {
return _width;
}
@Override
public void setWidth(int width) {
_width = width;
}
@JSON
@Override
public int getSize() {
return _size;
}
@Override
public void setSize(int size) {
_columnBitmask |= SIZE_COLUMN_BITMASK;
if (!_setOriginalSize) {
_setOriginalSize = true;
_originalSize = _size;
}
_size = size;
}
public int getOriginalSize() {
return _originalSize;
}
public long getColumnBitmask() {
return _columnBitmask;
}
@Override
public ExpandoBridge getExpandoBridge() {
return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
Image.class.getName(), getPrimaryKey());
}
@Override
public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
ExpandoBridge expandoBridge = getExpandoBridge();
expandoBridge.setAttributes(serviceContext);
}
@Override
public Image toEscapedModel() {
if (_escapedModel == null) {
_escapedModel = (Image)ProxyUtil.newProxyInstance(_classLoader,
_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
}
return _escapedModel;
}
@Override
public Object clone() {
ImageImpl imageImpl = new ImageImpl();
imageImpl.setImageId(getImageId());
imageImpl.setModifiedDate(getModifiedDate());
imageImpl.setType(getType());
imageImpl.setHeight(getHeight());
imageImpl.setWidth(getWidth());
imageImpl.setSize(getSize());
imageImpl.resetOriginalValues();
return imageImpl;
}
@Override
public int compareTo(Image image) {
int value = 0;
if (getImageId() < image.getImageId()) {
value = -1;
}
else if (getImageId() > image.getImageId()) {
value = 1;
}
else {
value = 0;
}
if (value != 0) {
return value;
}
return 0;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Image)) {
return false;
}
Image image = (Image)obj;
long primaryKey = image.getPrimaryKey();
if (getPrimaryKey() == primaryKey) {
return true;
}
else {
return false;
}
}
@Override
public int hashCode() {
return (int)getPrimaryKey();
}
@Override
public void resetOriginalValues() {
ImageModelImpl imageModelImpl = this;
imageModelImpl._originalSize = imageModelImpl._size;
imageModelImpl._setOriginalSize = false;
imageModelImpl._columnBitmask = 0;
}
@Override
public CacheModel<Image> toCacheModel() {
ImageCacheModel imageCacheModel = new ImageCacheModel();
imageCacheModel.imageId = getImageId();
Date modifiedDate = getModifiedDate();
if (modifiedDate != null) {
imageCacheModel.modifiedDate = modifiedDate.getTime();
}
else {
imageCacheModel.modifiedDate = Long.MIN_VALUE;
}
imageCacheModel.type = getType();
String type = imageCacheModel.type;
if ((type != null) && (type.length() == 0)) {
imageCacheModel.type = null;
}
imageCacheModel.height = getHeight();
imageCacheModel.width = getWidth();
imageCacheModel.size = getSize();
return imageCacheModel;
}
@Override
public String toString() {
StringBundler sb = new StringBundler(13);
sb.append("{imageId=");
sb.append(getImageId());
sb.append(", modifiedDate=");
sb.append(getModifiedDate());
sb.append(", type=");
sb.append(getType());
sb.append(", height=");
sb.append(getHeight());
sb.append(", width=");
sb.append(getWidth());
sb.append(", size=");
sb.append(getSize());
sb.append("}");
return sb.toString();
}
@Override
public String toXmlString() {
StringBundler sb = new StringBundler(22);
sb.append("<model><model-name>");
sb.append("com.liferay.portal.model.Image");
sb.append("</model-name>");
sb.append(
"<column><column-name>imageId</column-name><column-value><![CDATA[");
sb.append(getImageId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
sb.append(getModifiedDate());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>type</column-name><column-value><![CDATA[");
sb.append(getType());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>height</column-name><column-value><![CDATA[");
sb.append(getHeight());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>width</column-name><column-value><![CDATA[");
sb.append(getWidth());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>size</column-name><column-value><![CDATA[");
sb.append(getSize());
sb.append("]]></column-value></column>");
sb.append("</model>");
return sb.toString();
}
private static ClassLoader _classLoader = Image.class.getClassLoader();
private static Class<?>[] _escapedModelInterfaces = new Class[] { Image.class };
private long _imageId;
private Date _modifiedDate;
private String _type;
private int _height;
private int _width;
private int _size;
private int _originalSize;
private boolean _setOriginalSize;
private long _columnBitmask;
private Image _escapedModel;
}

49
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/PortalPreferencesBaseImpl.java

@ -0,0 +1,49 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.model.impl;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.model.PortalPreferences;
import com.liferay.portal.service.PortalPreferencesLocalServiceUtil;
/**
* The extended model base implementation for the PortalPreferences service. Represents a row in the &quot;PortalPreferences&quot; database table, with each column mapped to a property of this class.
*
* <p>
* This class exists only as a container for the default extended model level methods generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PortalPreferencesImpl}.
* </p>
*
* @author Brian Wing Shun Chan
* @see PortalPreferencesImpl
* @see com.liferay.portal.model.PortalPreferences
* @generated
*/
public abstract class PortalPreferencesBaseImpl
extends PortalPreferencesModelImpl implements PortalPreferences {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. All methods that expect a portal preferences model instance should use the {@link PortalPreferences} interface instead.
*/
@Override
public void persist() throws SystemException {
if (this.isNew()) {
PortalPreferencesLocalServiceUtil.addPortalPreferences(this);
}
else {
PortalPreferencesLocalServiceUtil.updatePortalPreferences(this);
}
}
}

100
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/PortalPreferencesCacheModel.java

@ -0,0 +1,100 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.model.impl;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.PortalPreferences;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
/**
* The cache model class for representing PortalPreferences in entity cache.
*
* @author Brian Wing Shun Chan
* @see PortalPreferences
* @generated
*/
public class PortalPreferencesCacheModel implements CacheModel<PortalPreferences>,
Externalizable {
@Override
public String toString() {
StringBundler sb = new StringBundler(9);
sb.append("{portalPreferencesId=");
sb.append(portalPreferencesId);
sb.append(", ownerId=");
sb.append(ownerId);
sb.append(", ownerType=");
sb.append(ownerType);
sb.append(", preferences=");
sb.append(preferences);
sb.append("}");
return sb.toString();
}
@Override
public PortalPreferences toEntityModel() {
PortalPreferencesImpl portalPreferencesImpl = new PortalPreferencesImpl();
portalPreferencesImpl.setPortalPreferencesId(portalPreferencesId);
portalPreferencesImpl.setOwnerId(ownerId);
portalPreferencesImpl.setOwnerType(ownerType);
if (preferences == null) {
portalPreferencesImpl.setPreferences(StringPool.BLANK);
}
else {
portalPreferencesImpl.setPreferences(preferences);
}
portalPreferencesImpl.resetOriginalValues();
return portalPreferencesImpl;
}
@Override
public void readExternal(ObjectInput objectInput) throws IOException {
portalPreferencesId = objectInput.readLong();
ownerId = objectInput.readLong();
ownerType = objectInput.readInt();
preferences = objectInput.readUTF();
}
@Override
public void writeExternal(ObjectOutput objectOutput)
throws IOException {
objectOutput.writeLong(portalPreferencesId);
objectOutput.writeLong(ownerId);
objectOutput.writeInt(ownerType);
if (preferences == null) {
objectOutput.writeUTF(StringPool.BLANK);
}
else {
objectOutput.writeUTF(preferences);
}
}
public long portalPreferencesId;
public long ownerId;
public int ownerType;
public String preferences;
}

25
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/PortalPreferencesImpl.java

@ -0,0 +1,25 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.model.impl;
/**
* @author Alexander Chow
*/
public class PortalPreferencesImpl extends PortalPreferencesBaseImpl {
public PortalPreferencesImpl() {
}
}

407
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/model/impl/PortalPreferencesModelImpl.java

@ -0,0 +1,407 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.model.impl;
import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.PortalPreferences;
import com.liferay.portal.model.PortalPreferencesModel;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
import java.io.Serializable;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;
/**
* The base model implementation for the PortalPreferences service. Represents a row in the &quot;PortalPreferences&quot; database table, with each column mapped to a property of this class.
*
* <p>
* This implementation and its corresponding interface {@link com.liferay.portal.model.PortalPreferencesModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PortalPreferencesImpl}.
* </p>
*
* @author Brian Wing Shun Chan
* @see PortalPreferencesImpl
* @see com.liferay.portal.model.PortalPreferences
* @see com.liferay.portal.model.PortalPreferencesModel
* @generated
*/
public class PortalPreferencesModelImpl extends BaseModelImpl<PortalPreferences>
implements PortalPreferencesModel {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. All methods that expect a portal preferences model instance should use the {@link com.liferay.portal.model.PortalPreferences} interface instead.
*/
public static final String TABLE_NAME = "PortalPreferences";
public static final Object[][] TABLE_COLUMNS = {
{ "portalPreferencesId", Types.BIGINT },
{ "ownerId", Types.BIGINT },
{ "ownerType", Types.INTEGER },
{ "preferences", Types.CLOB }
};
public static final String TABLE_SQL_CREATE = "create table PortalPreferences (portalPreferencesId LONG not null primary key,ownerId LONG,ownerType INTEGER,preferences TEXT null)";
public static final String TABLE_SQL_DROP = "drop table PortalPreferences";
public static final String ORDER_BY_JPQL = " ORDER BY portalPreferences.portalPreferencesId ASC";
public static final String ORDER_BY_SQL = " ORDER BY PortalPreferences.portalPreferencesId ASC";
public static final String DATA_SOURCE = "liferayDataSource";
public static final String SESSION_FACTORY = "liferaySessionFactory";
public static final String TX_MANAGER = "liferayTransactionManager";
public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
"value.object.entity.cache.enabled.com.liferay.portal.model.PortalPreferences"),
true);
public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
"value.object.finder.cache.enabled.com.liferay.portal.model.PortalPreferences"),
true);
public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
"value.object.column.bitmask.enabled.com.liferay.portal.model.PortalPreferences"),
true);
public static long OWNERID_COLUMN_BITMASK = 1L;
public static long OWNERTYPE_COLUMN_BITMASK = 2L;
public static long PORTALPREFERENCESID_COLUMN_BITMASK = 4L;
public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
"lock.expiration.time.com.liferay.portal.model.PortalPreferences"));
public PortalPreferencesModelImpl() {
}
@Override
public long getPrimaryKey() {
return _portalPreferencesId;
}
@Override
public void setPrimaryKey(long primaryKey) {
setPortalPreferencesId(primaryKey);
}
@Override
public Serializable getPrimaryKeyObj() {
return _portalPreferencesId;
}
@Override
public void setPrimaryKeyObj(Serializable primaryKeyObj) {
setPrimaryKey(((Long)primaryKeyObj).longValue());
}
@Override
public Class<?> getModelClass() {
return PortalPreferences.class;
}
@Override
public String getModelClassName() {
return PortalPreferences.class.getName();
}
@Override
public Map<String, Object> getModelAttributes() {
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("portalPreferencesId", getPortalPreferencesId());
attributes.put("ownerId", getOwnerId());
attributes.put("ownerType", getOwnerType());
attributes.put("preferences", getPreferences());
return attributes;
}
@Override
public void setModelAttributes(Map<String, Object> attributes) {
Long portalPreferencesId = (Long)attributes.get("portalPreferencesId");
if (portalPreferencesId != null) {
setPortalPreferencesId(portalPreferencesId);
}
Long ownerId = (Long)attributes.get("ownerId");
if (ownerId != null) {
setOwnerId(ownerId);
}
Integer ownerType = (Integer)attributes.get("ownerType");
if (ownerType != null) {
setOwnerType(ownerType);
}
String preferences = (String)attributes.get("preferences");
if (preferences != null) {
setPreferences(preferences);
}
}
@Override
public long getPortalPreferencesId() {
return _portalPreferencesId;
}
@Override
public void setPortalPreferencesId(long portalPreferencesId) {
_portalPreferencesId = portalPreferencesId;
}
@Override
public long getOwnerId() {
return _ownerId;
}
@Override
public void setOwnerId(long ownerId) {
_columnBitmask |= OWNERID_COLUMN_BITMASK;
if (!_setOriginalOwnerId) {
_setOriginalOwnerId = true;
_originalOwnerId = _ownerId;
}
_ownerId = ownerId;
}
public long getOriginalOwnerId() {
return _originalOwnerId;
}
@Override
public int getOwnerType() {
return _ownerType;
}
@Override
public void setOwnerType(int ownerType) {
_columnBitmask |= OWNERTYPE_COLUMN_BITMASK;
if (!_setOriginalOwnerType) {
_setOriginalOwnerType = true;
_originalOwnerType = _ownerType;
}
_ownerType = ownerType;
}
public int getOriginalOwnerType() {
return _originalOwnerType;
}
@Override
public String getPreferences() {
if (_preferences == null) {
return StringPool.BLANK;
}
else {
return _preferences;
}
}
@Override
public void setPreferences(String preferences) {
_preferences = preferences;
}
public long getColumnBitmask() {
return _columnBitmask;
}
@Override
public ExpandoBridge getExpandoBridge() {
return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
PortalPreferences.class.getName(), getPrimaryKey());
}
@Override
public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
ExpandoBridge expandoBridge = getExpandoBridge();
expandoBridge.setAttributes(serviceContext);
}
@Override
public PortalPreferences toEscapedModel() {
if (_escapedModel == null) {
_escapedModel = (PortalPreferences)ProxyUtil.newProxyInstance(_classLoader,
_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
}
return _escapedModel;
}
@Override
public Object clone() {
PortalPreferencesImpl portalPreferencesImpl = new PortalPreferencesImpl();
portalPreferencesImpl.setPortalPreferencesId(getPortalPreferencesId());
portalPreferencesImpl.setOwnerId(getOwnerId());
portalPreferencesImpl.setOwnerType(getOwnerType());
portalPreferencesImpl.setPreferences(getPreferences());
portalPreferencesImpl.resetOriginalValues();
return portalPreferencesImpl;
}
@Override
public int compareTo(PortalPreferences portalPreferences) {
long primaryKey = portalPreferences.getPrimaryKey();
if (getPrimaryKey() < primaryKey) {
return -1;
}
else if (getPrimaryKey() > primaryKey) {
return 1;
}
else {
return 0;
}
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof PortalPreferences)) {
return false;
}
PortalPreferences portalPreferences = (PortalPreferences)obj;
long primaryKey = portalPreferences.getPrimaryKey();
if (getPrimaryKey() == primaryKey) {
return true;
}
else {
return false;
}
}
@Override
public int hashCode() {
return (int)getPrimaryKey();
}
@Override
public void resetOriginalValues() {
PortalPreferencesModelImpl portalPreferencesModelImpl = this;
portalPreferencesModelImpl._originalOwnerId = portalPreferencesModelImpl._ownerId;
portalPreferencesModelImpl._setOriginalOwnerId = false;
portalPreferencesModelImpl._originalOwnerType = portalPreferencesModelImpl._ownerType;
portalPreferencesModelImpl._setOriginalOwnerType = false;
portalPreferencesModelImpl._columnBitmask = 0;
}
@Override
public CacheModel<PortalPreferences> toCacheModel() {
PortalPreferencesCacheModel portalPreferencesCacheModel = new PortalPreferencesCacheModel();
portalPreferencesCacheModel.portalPreferencesId = getPortalPreferencesId();
portalPreferencesCacheModel.ownerId = getOwnerId();
portalPreferencesCacheModel.ownerType = getOwnerType();
portalPreferencesCacheModel.preferences = getPreferences();
String preferences = portalPreferencesCacheModel.preferences;
if ((preferences != null) && (preferences.length() == 0)) {
portalPreferencesCacheModel.preferences = null;
}
return portalPreferencesCacheModel;
}
@Override
public String toString() {
StringBundler sb = new StringBundler(9);
sb.append("{portalPreferencesId=");
sb.append(getPortalPreferencesId());
sb.append(", ownerId=");
sb.append(getOwnerId());
sb.append(", ownerType=");
sb.append(getOwnerType());
sb.append(", preferences=");
sb.append(getPreferences());
sb.append("}");
return sb.toString();
}
@Override
public String toXmlString() {
StringBundler sb = new StringBundler(16);
sb.append("<model><model-name>");
sb.append("com.liferay.portal.model.PortalPreferences");
sb.append("</model-name>");
sb.append(
"<column><column-name>portalPreferencesId</column-name><column-value><![CDATA[");
sb.append(getPortalPreferencesId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>ownerId</column-name><column-value><![CDATA[");
sb.append(getOwnerId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>ownerType</column-name><column-value><![CDATA[");
sb.append(getOwnerType());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>preferences</column-name><column-value><![CDATA[");
sb.append(getPreferences());
sb.append("]]></column-value></column>");
sb.append("</model>");
return sb.toString();
}
private static ClassLoader _classLoader = PortalPreferences.class.getClassLoader();
private static Class<?>[] _escapedModelInterfaces = new Class[] {
PortalPreferences.class
};
private long _portalPreferencesId;
private long _ownerId;
private long _originalOwnerId;
private boolean _setOriginalOwnerId;
private int _ownerType;
private int _originalOwnerType;
private boolean _setOriginalOwnerType;
private String _preferences;
private long _columnBitmask;
private PortalPreferences _escapedModel;
}

575
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/repository/liferayrepository/model/LiferayFileEntry.java

@ -0,0 +1,575 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.repository.liferayrepository.model;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.lar.StagedModelType;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.repository.model.FileVersion;
import com.liferay.portal.kernel.repository.model.Folder;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.Lock;
import com.liferay.portal.security.auth.PrincipalThreadLocal;
import com.liferay.portal.security.permission.PermissionChecker;
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.documentlibrary.model.DLFileEntryConstants;
import com.liferay.portlet.documentlibrary.model.DLFileVersion;
import com.liferay.portlet.documentlibrary.service.DLAppHelperLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFileVersionLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.permission.DLFileEntryPermission;
import com.liferay.portlet.expando.model.ExpandoBridge;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author Alexander Chow
*/
public class LiferayFileEntry extends LiferayModel implements FileEntry {
public LiferayFileEntry(DLFileEntry dlFileEntry) {
_dlFileEntry = dlFileEntry;
}
public LiferayFileEntry(DLFileEntry fileEntry, boolean escapedModel) {
_dlFileEntry = fileEntry;
_escapedModel = escapedModel;
}
@Override
public Object clone() {
LiferayFileEntry liferayFileEntry = new LiferayFileEntry(
_dlFileEntry, _escapedModel);
FileVersion cachedFileVersion = getCachedFileVersion();
if (cachedFileVersion != null) {
liferayFileEntry.setCachedFileVersion(cachedFileVersion);
}
liferayFileEntry.setCompanyId(getCompanyId());
liferayFileEntry.setCreateDate(getCreateDate());
liferayFileEntry.setGroupId(getGroupId());
liferayFileEntry.setModifiedDate(getModifiedDate());
liferayFileEntry.setPrimaryKey(getPrimaryKey());
liferayFileEntry.setUserId(getUserId());
liferayFileEntry.setUserName(getUserName());
try {
liferayFileEntry.setUserUuid(getUserUuid());
}
catch (SystemException se) {
}
liferayFileEntry.setUuid(getUuid());
return liferayFileEntry;
}
@Override
public boolean containsPermission(
PermissionChecker permissionChecker, String actionId)
throws PortalException, SystemException {
return DLFileEntryPermission.contains(
permissionChecker, _dlFileEntry, actionId);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof LiferayFileEntry)) {
return false;
}
LiferayFileEntry liferayFileEntry = (LiferayFileEntry)obj;
if (Validator.equals(_dlFileEntry, liferayFileEntry._dlFileEntry)) {
return true;
}
return false;
}
@Override
public Map<String, Serializable> getAttributes() {
ExpandoBridge expandoBridge = getExpandoBridge();
return expandoBridge.getAttributes();
}
public FileVersion getCachedFileVersion() {
if (_dlFileVersion == null) {
return null;
}
return new LiferayFileVersion(_dlFileVersion);
}
@Override
public long getCompanyId() {
return _dlFileEntry.getCompanyId();
}
@Override
public InputStream getContentStream()
throws PortalException, SystemException {
InputStream inputStream = _dlFileEntry.getContentStream();
try {
DLAppHelperLocalServiceUtil.getFileAsStream(
PrincipalThreadLocal.getUserId(), this, true);
}
catch (Exception e) {
_log.error(e);
}
return inputStream;
}
@Override
public InputStream getContentStream(String version)
throws PortalException, SystemException {
InputStream inputStream = _dlFileEntry.getContentStream(version);
try {
DLAppHelperLocalServiceUtil.getFileAsStream(
PrincipalThreadLocal.getUserId(), this, true);
}
catch (Exception e) {
_log.error(e);
}
return inputStream;
}
@Override
public Date getCreateDate() {
return _dlFileEntry.getCreateDate();
}
@Override
public String getDescription() {
return _dlFileEntry.getDescription();
}
public DLFileEntry getDLFileEntry() {
return _dlFileEntry;
}
@Override
public ExpandoBridge getExpandoBridge() {
return _dlFileEntry.getExpandoBridge();
}
@Override
public String getExtension() {
return _dlFileEntry.getExtension();
}
@Override
public long getFileEntryId() {
return _dlFileEntry.getFileEntryId();
}
@Override
public FileVersion getFileVersion()
throws PortalException, SystemException {
DLFileVersion dlFileVersion = _dlFileVersion;
if (dlFileVersion == null) {
dlFileVersion = _dlFileEntry.getFileVersion();
}
return new LiferayFileVersion(dlFileVersion);
}
@Override
public FileVersion getFileVersion(String version)
throws PortalException, SystemException {
return new LiferayFileVersion(_dlFileEntry.getFileVersion(version));
}
@Override
public List<FileVersion> getFileVersions(int status)
throws SystemException {
return toFileVersions(_dlFileEntry.getFileVersions(status));
}
@Override
public Folder getFolder() {
Folder folder = null;
try {
folder = new LiferayFolder(_dlFileEntry.getFolder());
}
catch (Exception e) {
return null;
}
return folder;
}
@Override
public long getFolderId() {
return _dlFileEntry.getFolderId();
}
@Override
public long getGroupId() {
return _dlFileEntry.getGroupId();
}
@Override
public String getIcon() {
return _dlFileEntry.getIcon();
}
@Override
public FileVersion getLatestFileVersion()
throws PortalException, SystemException {
return new LiferayFileVersion(_dlFileEntry.getLatestFileVersion(false));
}
@Override
public Lock getLock() {
return _dlFileEntry.getLock();
}
@Override
public String getMimeType() {
return _dlFileEntry.getMimeType();
}
@Override
public String getMimeType(String version) {
try {
DLFileVersion dlFileVersion =
DLFileVersionLocalServiceUtil.getFileVersion(
_dlFileEntry.getFileEntryId(), version);
return dlFileVersion.getMimeType();
}
catch (Exception e) {
}
return ContentTypes.APPLICATION_OCTET_STREAM;
}
@Override
public Object getModel() {
return _dlFileEntry;
}
@Override
public Class<?> getModelClass() {
return LiferayFileEntry.class;
}
@Override
public String getModelClassName() {
return LiferayFileEntry.class.getName();
}
@Override
public Date getModifiedDate() {
return _dlFileEntry.getModifiedDate();
}
@Override
public long getPrimaryKey() {
return _dlFileEntry.getPrimaryKey();
}
@Override
public Serializable getPrimaryKeyObj() {
return getPrimaryKey();
}
@Override
public int getReadCount() {
return _dlFileEntry.getReadCount();
}
@Override
public long getRepositoryId() {
return _dlFileEntry.getRepositoryId();
}
@Override
public long getSize() {
return _dlFileEntry.getSize();
}
@Override
public StagedModelType getStagedModelType() {
return new StagedModelType(DLFileEntryConstants.getClassName());
}
@Override
public String getTitle() {
return _dlFileEntry.getTitle();
}
@Override
public long getUserId() {
return _dlFileEntry.getUserId();
}
@Override
public String getUserName() {
return _dlFileEntry.getUserName();
}
@Override
public String getUserUuid() throws SystemException {
return _dlFileEntry.getUserUuid();
}
@Override
public String getUuid() {
return _dlFileEntry.getUuid();
}
@Override
public String getVersion() {
return _dlFileEntry.getVersion();
}
/**
* @deprecated As of 6.2.0, replaced by {@link DLFileVersion#getUserId()}
*/
@Override
public long getVersionUserId() {
long versionUserId = 0;
try {
DLFileVersion dlFileVersion = _dlFileEntry.getFileVersion();
versionUserId = dlFileVersion.getUserId();
}
catch (Exception e) {
_log.error(e, e);
}
return versionUserId;
}
/**
* @deprecated As of 6.2.0, replaced by {@link DLFileVersion#getUserName()}
*/
@Override
public String getVersionUserName() {
String versionUserName = StringPool.BLANK;
try {
DLFileVersion dlFileVersion = _dlFileEntry.getFileVersion();
versionUserName = dlFileVersion.getUserName();
}
catch (Exception e) {
_log.error(e, e);
}
return versionUserName;
}
/**
* @deprecated As of 6.2.0, replaced by {@link DLFileVersion#getUserUuid()}
*/
@Override
public String getVersionUserUuid() {
String versionUserUuid = StringPool.BLANK;
try {
DLFileVersion dlFileVersion = _dlFileEntry.getFileVersion();
versionUserUuid = dlFileVersion.getUserUuid();
}
catch (Exception e) {
_log.error(e, e);
}
return versionUserUuid;
}
@Override
public int hashCode() {
return _dlFileEntry.hashCode();
}
@Override
public boolean hasLock() {
return _dlFileEntry.hasLock();
}
@Override
public boolean isCheckedOut() {
return _dlFileEntry.isCheckedOut();
}
@Override
public boolean isDefaultRepository() {
if (_dlFileEntry.getGroupId() == _dlFileEntry.getRepositoryId()) {
return true;
}
else {
return false;
}
}
@Override
public boolean isEscapedModel() {
return _escapedModel;
}
@Override
public boolean isInTrash() {
return _dlFileEntry.isInTrash();
}
@Override
public boolean isInTrashContainer() {
try {
return _dlFileEntry.isInTrashContainer();
}
catch (Exception e) {
return false;
}
}
@Override
public boolean isManualCheckInRequired() {
return _dlFileEntry.isManualCheckInRequired();
}
@Override
public boolean isSupportsLocking() {
return true;
}
@Override
public boolean isSupportsMetadata() {
return true;
}
@Override
public boolean isSupportsSocial() {
return true;
}
public void setCachedFileVersion(FileVersion fileVersion) {
_dlFileVersion = (DLFileVersion)fileVersion.getModel();
}
@Override
public void setCompanyId(long companyId) {
_dlFileEntry.setCompanyId(companyId);
}
@Override
public void setCreateDate(Date date) {
_dlFileEntry.setCreateDate(date);
}
@Override
public void setGroupId(long groupId) {
_dlFileEntry.setGroupId(groupId);
}
@Override
public void setModifiedDate(Date date) {
_dlFileEntry.setModifiedDate(date);
}
public void setPrimaryKey(long primaryKey) {
_dlFileEntry.setPrimaryKey(primaryKey);
}
@Override
public void setPrimaryKeyObj(Serializable primaryKeyObj) {
setPrimaryKey(((Long)primaryKeyObj).longValue());
}
@Override
public void setUserId(long userId) {
_dlFileEntry.setUserId(userId);
}
@Override
public void setUserName(String userName) {
_dlFileEntry.setUserName(userName);
}
@Override
public void setUserUuid(String userUuid) {
_dlFileEntry.setUserUuid(userUuid);
}
@Override
public void setUuid(String uuid) {
_dlFileEntry.setUuid(uuid);
}
@Override
public FileEntry toEscapedModel() {
if (isEscapedModel()) {
return this;
}
else {
return new LiferayFileEntry(_dlFileEntry.toEscapedModel(), true);
}
}
@Override
public String toString() {
return _dlFileEntry.toString();
}
@Override
public FileEntry toUnescapedModel() {
if (isEscapedModel()) {
return new LiferayFileEntry(_dlFileEntry.toUnescapedModel(), true);
}
else {
return this;
}
}
private static Log _log = LogFactoryUtil.getLog(LiferayFileEntry.class);
private DLFileEntry _dlFileEntry;
private DLFileVersion _dlFileVersion;
private boolean _escapedModel;
}

412
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/repository/liferayrepository/model/LiferayFileVersion.java

@ -0,0 +1,412 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.repository.liferayrepository.model;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.lar.StagedModelType;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.repository.model.FileVersion;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.security.auth.PrincipalThreadLocal;
import com.liferay.portlet.documentlibrary.model.DLFileVersion;
import com.liferay.portlet.documentlibrary.service.DLAppHelperLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
import com.liferay.portlet.expando.model.ExpandoBridge;
import java.io.File;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
/**
* @author Alexander Chow
*/
public class LiferayFileVersion extends LiferayModel implements FileVersion {
public LiferayFileVersion(DLFileVersion dlFileVersion) {
_dlFileVersion = dlFileVersion;
}
public LiferayFileVersion(
DLFileVersion dlFileVersion, boolean escapedModel) {
_dlFileVersion = dlFileVersion;
_escapedModel = escapedModel;
}
@Override
public Object clone() {
LiferayFileVersion liferayFileVersion = new LiferayFileVersion(
_dlFileVersion, _escapedModel);
liferayFileVersion.setCompanyId(getCompanyId());
liferayFileVersion.setCreateDate(getCreateDate());
liferayFileVersion.setGroupId(getGroupId());
liferayFileVersion.setPrimaryKey(getPrimaryKey());
liferayFileVersion.setUserId(getUserId());
liferayFileVersion.setUserName(getUserName());
try {
liferayFileVersion.setUserUuid(getUserUuid());
}
catch (Exception e) {
}
liferayFileVersion.setUuid(getUuid());
return liferayFileVersion;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof LiferayFileVersion)) {
return false;
}
LiferayFileVersion liferayFileVersion = (LiferayFileVersion)obj;
if (Validator.equals(
_dlFileVersion, liferayFileVersion._dlFileVersion)) {
return true;
}
return false;
}
@Override
public Map<String, Serializable> getAttributes() {
ExpandoBridge expandoBridge = _dlFileVersion.getExpandoBridge();
return expandoBridge.getAttributes();
}
@Override
public String getChangeLog() {
return _dlFileVersion.getChangeLog();
}
@Override
public long getCompanyId() {
return _dlFileVersion.getCompanyId();
}
@Override
public InputStream getContentStream(boolean incrementCounter)
throws PortalException, SystemException {
InputStream inputStream = _dlFileVersion.getContentStream(
incrementCounter);
try {
DLAppHelperLocalServiceUtil.getFileAsStream(
PrincipalThreadLocal.getUserId(), getFileEntry(),
incrementCounter);
}
catch (Exception e) {
_log.error(e, e);
}
return inputStream;
}
@Override
public Date getCreateDate() {
return _dlFileVersion.getCreateDate();
}
@Override
public String getDescription() {
return _dlFileVersion.getDescription();
}
@Override
public ExpandoBridge getExpandoBridge() {
return _dlFileVersion.getExpandoBridge();
}
@Override
public String getExtension() {
return _dlFileVersion.getExtension();
}
@Override
public String getExtraSettings() {
return _dlFileVersion.getExtraSettings();
}
public File getFile(boolean incrementCounter)
throws PortalException, SystemException {
return DLFileEntryLocalServiceUtil.getFile(
PrincipalThreadLocal.getUserId(), _dlFileVersion.getFileEntryId(),
_dlFileVersion.getVersion(), incrementCounter);
}
@Override
public FileEntry getFileEntry() throws PortalException, SystemException {
return new LiferayFileEntry(_dlFileVersion.getFileEntry());
}
@Override
public long getFileEntryId() {
return _dlFileVersion.getFileEntryId();
}
@Override
public long getFileVersionId() {
return _dlFileVersion.getFileVersionId();
}
@Override
public long getGroupId() {
return _dlFileVersion.getGroupId();
}
@Override
public String getIcon() {
return _dlFileVersion.getIcon();
}
@Override
public String getMimeType() {
return _dlFileVersion.getMimeType();
}
@Override
public Object getModel() {
return _dlFileVersion;
}
@Override
public Class<?> getModelClass() {
return LiferayFileVersion.class;
}
@Override
public String getModelClassName() {
return LiferayFileVersion.class.getName();
}
@Override
public Date getModifiedDate() {
return _dlFileVersion.getModifiedDate();
}
@Override
public long getPrimaryKey() {
return _dlFileVersion.getPrimaryKey();
}
@Override
public Serializable getPrimaryKeyObj() {
return getPrimaryKey();
}
@Override
public long getRepositoryId() {
return _dlFileVersion.getRepositoryId();
}
@Override
public long getSize() {
return _dlFileVersion.getSize();
}
@Override
public StagedModelType getStagedModelType() {
return new StagedModelType(FileVersion.class);
}
@Override
public int getStatus() {
return _dlFileVersion.getStatus();
}
@Override
public long getStatusByUserId() {
return _dlFileVersion.getStatusByUserId();
}
@Override
public String getStatusByUserName() {
return _dlFileVersion.getStatusByUserName();
}
@Override
public String getStatusByUserUuid() throws SystemException {
return _dlFileVersion.getStatusByUserUuid();
}
@Override
public Date getStatusDate() {
return _dlFileVersion.getStatusDate();
}
@Override
public String getTitle() {
return _dlFileVersion.getTitle();
}
@Override
public long getUserId() {
return _dlFileVersion.getUserId();
}
@Override
public String getUserName() {
return _dlFileVersion.getUserName();
}
@Override
public String getUserUuid() throws SystemException {
return _dlFileVersion.getUserUuid();
}
@Override
public String getUuid() {
return _dlFileVersion.getUuid();
}
@Override
public String getVersion() {
return _dlFileVersion.getVersion();
}
@Override
public boolean isApproved() {
return _dlFileVersion.isApproved();
}
@Override
public boolean isDefaultRepository() {
if (_dlFileVersion.getGroupId() == _dlFileVersion.getRepositoryId()) {
return true;
}
else {
return false;
}
}
@Override
public boolean isDraft() {
return _dlFileVersion.isDraft();
}
@Override
public boolean isEscapedModel() {
return _escapedModel;
}
@Override
public boolean isExpired() {
return _dlFileVersion.isExpired();
}
@Override
public boolean isPending() {
return _dlFileVersion.isPending();
}
@Override
public void setCompanyId(long companyId) {
_dlFileVersion.setCompanyId(companyId);
}
@Override
public void setCreateDate(Date date) {
_dlFileVersion.setCreateDate(date);
}
@Override
public void setGroupId(long groupId) {
_dlFileVersion.setGroupId(groupId);
}
@Override
public void setModifiedDate(Date date) {
}
public void setPrimaryKey(long primaryKey) {
_dlFileVersion.setPrimaryKey(primaryKey);
}
@Override
public void setPrimaryKeyObj(Serializable primaryKeyObj) {
setPrimaryKey(((Long)primaryKeyObj).longValue());
}
@Override
public void setUserId(long userId) {
_dlFileVersion.setUserId(userId);
}
@Override
public void setUserName(String userName) {
_dlFileVersion.setUserName(userName);
}
@Override
public void setUserUuid(String userUuid) {
_dlFileVersion.setUserUuid(userUuid);
}
@Override
public void setUuid(String uuid) {
_dlFileVersion.setUuid(uuid);
}
@Override
public FileVersion toEscapedModel() {
if (isEscapedModel()) {
return this;
}
else {
return new LiferayFileVersion(
_dlFileVersion.toEscapedModel(), true);
}
}
@Override
public String toString() {
return _dlFileVersion.toString();
}
@Override
public FileVersion toUnescapedModel() {
if (isEscapedModel()) {
return new LiferayFileVersion(
_dlFileVersion.toUnescapedModel(), true);
}
else {
return this;
}
}
private static Log _log = LogFactoryUtil.getLog(LiferayFileVersion.class);
private DLFileVersion _dlFileVersion;
private boolean _escapedModel;
}

418
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/repository/liferayrepository/model/LiferayFolder.java

@ -0,0 +1,418 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.repository.liferayrepository.model;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.lar.StagedModelType;
import com.liferay.portal.kernel.repository.model.Folder;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.security.permission.PermissionChecker;
import com.liferay.portlet.documentlibrary.model.DLFolder;
import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
import com.liferay.portlet.documentlibrary.service.permission.DLFolderPermission;
import com.liferay.portlet.expando.model.ExpandoBridge;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author Alexander Chow
*/
public class LiferayFolder extends LiferayModel implements Folder {
public LiferayFolder(DLFolder dlFolder) {
_dlFolder = dlFolder;
}
public LiferayFolder(DLFolder dlFolder, boolean escapedModel) {
_dlFolder = dlFolder;
_escapedModel = escapedModel;
}
@Override
public Object clone() {
LiferayFolder liferayFolder = new LiferayFolder(
_dlFolder, _escapedModel);
liferayFolder.setCompanyId(getCompanyId());
liferayFolder.setCreateDate(getCreateDate());
liferayFolder.setGroupId(getGroupId());
liferayFolder.setModifiedDate(getModifiedDate());
liferayFolder.setPrimaryKey(getPrimaryKey());
liferayFolder.setUserId(getUserId());
liferayFolder.setUserName(getUserName());
try {
liferayFolder.setUserUuid(getUserUuid());
}
catch (SystemException se) {
}
liferayFolder.setUuid(getUuid());
return liferayFolder;
}
@Override
public boolean containsPermission(
PermissionChecker permissionChecker, String actionId)
throws PortalException, SystemException {
return DLFolderPermission.contains(
permissionChecker, _dlFolder, actionId);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof LiferayFolder)) {
return false;
}
LiferayFolder liferayFolder = (LiferayFolder)obj;
if (Validator.equals(_dlFolder, liferayFolder._dlFolder)) {
return true;
}
return false;
}
@Override
public List<Long> getAncestorFolderIds()
throws PortalException, SystemException {
return _dlFolder.getAncestorFolderIds();
}
@Override
public List<Folder> getAncestors() throws PortalException, SystemException {
return toFolders(_dlFolder.getAncestors());
}
@Override
public Map<String, Serializable> getAttributes() {
ExpandoBridge expandoBridge = getExpandoBridge();
return expandoBridge.getAttributes();
}
@Override
public long getCompanyId() {
return _dlFolder.getCompanyId();
}
@Override
public Date getCreateDate() {
return _dlFolder.getCreateDate();
}
@Override
public String getDescription() {
return _dlFolder.getDescription();
}
@Override
public ExpandoBridge getExpandoBridge() {
return _dlFolder.getExpandoBridge();
}
@Override
public long getFolderId() {
return _dlFolder.getFolderId();
}
@Override
public long getGroupId() {
return _dlFolder.getGroupId();
}
@Override
public Date getLastPostDate() {
return _dlFolder.getLastPostDate();
}
@Override
public Object getModel() {
return _dlFolder;
}
@Override
public Class<?> getModelClass() {
return LiferayFolder.class;
}
@Override
public String getModelClassName() {
return LiferayFolder.class.getName();
}
@Override
public Date getModifiedDate() {
return _dlFolder.getModifiedDate();
}
@Override
public String getName() {
return _dlFolder.getName();
}
@Override
public Folder getParentFolder() throws PortalException, SystemException {
DLFolder dlParentFolder = _dlFolder.getParentFolder();
if (dlParentFolder == null) {
return null;
}
else {
return new LiferayFolder(dlParentFolder);
}
}
@Override
public long getParentFolderId() {
return _dlFolder.getParentFolderId();
}
@Override
public long getPrimaryKey() {
return _dlFolder.getPrimaryKey();
}
@Override
public Serializable getPrimaryKeyObj() {
return getPrimaryKey();
}
@Override
public long getRepositoryId() {
return _dlFolder.getRepositoryId();
}
@Override
public StagedModelType getStagedModelType() {
return new StagedModelType(DLFolderConstants.getClassName());
}
@Override
public long getUserId() {
return _dlFolder.getUserId();
}
@Override
public String getUserName() {
return _dlFolder.getUserName();
}
@Override
public String getUserUuid() throws SystemException {
return _dlFolder.getUserUuid();
}
@Override
public String getUuid() {
return _dlFolder.getUuid();
}
@Override
public int hashCode() {
return _dlFolder.hashCode();
}
@Override
public boolean hasInheritableLock() {
return _dlFolder.hasInheritableLock();
}
@Override
public boolean hasLock() {
return _dlFolder.hasLock();
}
@Override
public boolean isDefaultRepository() {
if (_dlFolder.getGroupId() == _dlFolder.getRepositoryId()) {
return true;
}
else {
return false;
}
}
@Override
public boolean isEscapedModel() {
return _escapedModel;
}
@Override
public boolean isLocked() {
return _dlFolder.isLocked();
}
@Override
public boolean isMountPoint() {
return _dlFolder.isMountPoint();
}
@Override
public boolean isRoot() {
return _dlFolder.isRoot();
}
@Override
public boolean isSupportsLocking() {
if (isMountPoint()) {
return false;
}
else {
return true;
}
}
@Override
public boolean isSupportsMetadata() {
if (isMountPoint()) {
return false;
}
else {
return true;
}
}
@Override
public boolean isSupportsMultipleUpload() {
if (isMountPoint()) {
return false;
}
else {
return true;
}
}
@Override
public boolean isSupportsShortcuts() {
if (isMountPoint()) {
return false;
}
else {
return true;
}
}
@Override
public boolean isSupportsSocial() {
if (isMountPoint()) {
return false;
}
else {
return true;
}
}
@Override
public boolean isSupportsSubscribing() {
if (isMountPoint()) {
return false;
}
else {
return true;
}
}
@Override
public void setCompanyId(long companyId) {
_dlFolder.setCompanyId(companyId);
}
@Override
public void setCreateDate(Date date) {
_dlFolder.setCreateDate(date);
}
@Override
public void setGroupId(long groupId) {
_dlFolder.setGroupId(groupId);
}
@Override
public void setModifiedDate(Date date) {
_dlFolder.setModifiedDate(date);
}
public void setPrimaryKey(long primaryKey) {
_dlFolder.setPrimaryKey(primaryKey);
}
@Override
public void setPrimaryKeyObj(Serializable primaryKeyObj) {
setPrimaryKey(((Long)primaryKeyObj).longValue());
}
@Override
public void setUserId(long userId) {
_dlFolder.setUserId(userId);
}
@Override
public void setUserName(String userName) {
_dlFolder.setUserName(userName);
}
@Override
public void setUserUuid(String userUuid) {
_dlFolder.setUserUuid(userUuid);
}
@Override
public void setUuid(String uuid) {
_dlFolder.setUuid(uuid);
}
@Override
public Folder toEscapedModel() {
if (isEscapedModel()) {
return this;
}
else {
return new LiferayFolder(_dlFolder.toEscapedModel(), true);
}
}
@Override
public String toString() {
return _dlFolder.toString();
}
@Override
public Folder toUnescapedModel() {
if (isEscapedModel()) {
return new LiferayFolder(_dlFolder.toUnescapedModel(), true);
}
else {
return this;
}
}
private DLFolder _dlFolder;
private boolean _escapedModel;
}

33
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/repository/liferayrepository/model/LiferayModel.java

@ -0,0 +1,33 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.repository.liferayrepository.model;
import com.liferay.portal.repository.liferayrepository.util.LiferayBase;
import com.liferay.portlet.expando.model.ExpandoBridge;
/**
* @author Alexander Chow
*/
public abstract class LiferayModel extends LiferayBase {
public abstract long getCompanyId();
public abstract ExpandoBridge getExpandoBridge();
public abstract String getModelClassName();
public abstract long getPrimaryKey();
}

128
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/repository/liferayrepository/util/LiferayBase.java

@ -0,0 +1,128 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.repository.liferayrepository.util;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.repository.model.FileVersion;
import com.liferay.portal.kernel.repository.model.Folder;
import com.liferay.portal.kernel.util.UnmodifiableList;
import com.liferay.portal.repository.liferayrepository.model.LiferayFileEntry;
import com.liferay.portal.repository.liferayrepository.model.LiferayFileVersion;
import com.liferay.portal.repository.liferayrepository.model.LiferayFolder;
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.documentlibrary.model.DLFileVersion;
import com.liferay.portlet.documentlibrary.model.DLFolder;
import java.util.ArrayList;
import java.util.List;
/**
* @author Alexander Chow
*/
public abstract class LiferayBase {
/**
* @see com.liferay.portal.portletfilerepository.PortletFileRepositoryImpl#toFileEntries
*/
public List<FileEntry> toFileEntries(List<DLFileEntry> dlFileEntries) {
List<FileEntry> fileEntries = new ArrayList<FileEntry>(
dlFileEntries.size());
for (DLFileEntry dlFileEntry : dlFileEntries) {
FileEntry fileEntry = new LiferayFileEntry(dlFileEntry);
fileEntries.add(fileEntry);
}
if (dlFileEntries instanceof UnmodifiableList) {
return new UnmodifiableList<FileEntry>(fileEntries);
}
else {
return fileEntries;
}
}
public List<Object> toFileEntriesAndFolders(
List<Object> dlFileEntriesAndDLFolders) {
List<Object> fileEntriesAndFolders = new ArrayList<Object>(
dlFileEntriesAndDLFolders.size());
for (Object object : dlFileEntriesAndDLFolders) {
if (object instanceof DLFileEntry) {
DLFileEntry dlFileEntry = (DLFileEntry)object;
FileEntry fileEntry = new LiferayFileEntry(dlFileEntry);
fileEntriesAndFolders.add(fileEntry);
}
else if (object instanceof DLFolder) {
DLFolder dlFolder = (DLFolder)object;
Folder folder = new LiferayFolder(dlFolder);
fileEntriesAndFolders.add(folder);
}
else {
fileEntriesAndFolders.add(object);
}
}
if (dlFileEntriesAndDLFolders instanceof UnmodifiableList) {
return new UnmodifiableList<Object>(fileEntriesAndFolders);
}
else {
return fileEntriesAndFolders;
}
}
public List<FileVersion> toFileVersions(
List<DLFileVersion> dlFileVersions) {
List<FileVersion> fileVersions = new ArrayList<FileVersion>(
dlFileVersions.size());
for (DLFileVersion dlFileVersion : dlFileVersions) {
FileVersion fileVersion = new LiferayFileVersion(dlFileVersion);
fileVersions.add(fileVersion);
}
if (dlFileVersions instanceof UnmodifiableList) {
return new UnmodifiableList<FileVersion>(fileVersions);
}
else {
return fileVersions;
}
}
public List<Folder> toFolders(List<DLFolder> dlFolders) {
List<Folder> folders = new ArrayList<Folder>(dlFolders.size());
for (DLFolder dlFolder : dlFolders) {
Folder folder = new LiferayFolder(dlFolder);
folders.add(folder);
}
if (dlFolders instanceof UnmodifiableList) {
return new UnmodifiableList<Folder>(folders);
}
else {
return folders;
}
}
}

135
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/util/ClassLoaderUtil.java

@ -0,0 +1,135 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.util;
import com.liferay.portal.kernel.util.AggregateClassLoader;
import com.liferay.portal.kernel.util.ClassLoaderPool;
import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
/**
* @author Raymond Augé
* @author Shuyang Zhou
*/
public class ClassLoaderUtil {
public static ClassLoader getAggregatePluginsClassLoader(
String[] servletContextNames, boolean addContextClassLoader) {
return _pacl.getAggregatePluginsClassLoader(
servletContextNames, addContextClassLoader);
}
public static ClassLoader getClassLoader(Class<?> clazz) {
return _pacl.getClassLoader(clazz);
}
public static ClassLoader getContextClassLoader() {
return _pacl.getContextClassLoader();
}
public static ClassLoader getPluginClassLoader(String servletContextName) {
return _pacl.getPluginClassLoader(servletContextName);
}
public static ClassLoader getPortalClassLoader() {
return _pacl.getPortalClassLoader();
}
public static void setContextClassLoader(ClassLoader classLoader) {
_pacl.setContextClassLoader(classLoader);
}
public static class NoPACL implements PACL {
@Override
public ClassLoader getAggregatePluginsClassLoader(
String[] servletContextNames, boolean addContextClassLoader) {
ClassLoader[] classLoaders = null;
int offset = 0;
if (addContextClassLoader) {
classLoaders = new ClassLoader[servletContextNames.length + 1];
Thread currentThread = Thread.currentThread();
classLoaders[0] = currentThread.getContextClassLoader();
offset = 1;
}
else {
classLoaders = new ClassLoader[servletContextNames.length];
}
for (int i = 0; i < servletContextNames.length; i++) {
classLoaders[offset + i] = ClassLoaderPool.getClassLoader(
servletContextNames[i]);
}
return AggregateClassLoader.getAggregateClassLoader(classLoaders);
}
@Override
public ClassLoader getClassLoader(Class<?> clazz) {
return clazz.getClassLoader();
}
@Override
public ClassLoader getContextClassLoader() {
Thread currentThread = Thread.currentThread();
return currentThread.getContextClassLoader();
}
@Override
public ClassLoader getPluginClassLoader(String servletContextName) {
return ClassLoaderPool.getClassLoader(servletContextName);
}
@Override
public ClassLoader getPortalClassLoader() {
return PortalClassLoaderUtil.getClassLoader();
}
@Override
public void setContextClassLoader(ClassLoader classLoader) {
Thread thread = Thread.currentThread();
thread.setContextClassLoader(classLoader);
}
}
public static interface PACL {
public ClassLoader getAggregatePluginsClassLoader(
String[] servletContextNames, boolean addContextClassLoader);
public ClassLoader getClassLoader(Class<?> clazz);
public ClassLoader getContextClassLoader();
public ClassLoader getPluginClassLoader(String servletContextName);
public ClassLoader getPortalClassLoader();
public void setContextClassLoader(ClassLoader classLoader);
}
private static PACL _pacl = new NoPACL();
}

1112
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/util/FileImpl.java

File diff soppresso perché troppo grande Load Diff

572
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/util/PrefsPropsUtil.java

@ -0,0 +1,572 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.util;
import com.liferay.portal.kernel.bean.BeanReference;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.service.PortalPreferencesLocalService;
import com.liferay.portlet.PortalPreferencesWrapper;
import com.liferay.portlet.PortalPreferencesWrapperCacheUtil;
import com.liferay.util.ContentUtil;
import java.util.Enumeration;
import java.util.Properties;
import javax.portlet.PortletPreferences;
/**
* @author Brian Wing Shun Chan
*/
public class PrefsPropsUtil {
public static boolean getBoolean(long companyId, String name)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getBoolean(preferences, companyId, name);
}
public static boolean getBoolean(
long companyId, String name, boolean defaultValue)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getBoolean(preferences, companyId, name, defaultValue);
}
public static boolean getBoolean(
PortletPreferences preferences, long companyId, String name) {
return GetterUtil.getBoolean(getString(preferences, companyId, name));
}
public static boolean getBoolean(
PortletPreferences preferences, long companyId, String name,
boolean defaultValue) {
return GetterUtil.getBoolean(
getString(preferences, companyId, name, defaultValue));
}
public static boolean getBoolean(String name) throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getBoolean(preferences, 0, name);
}
public static boolean getBoolean(String name, boolean defaultValue)
throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getBoolean(preferences, 0, name, defaultValue);
}
public static String getContent(long companyId, String name)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getContent(preferences, companyId, name);
}
public static String getContent(
PortletPreferences preferences, long companyId, String name) {
String value = preferences.getValue(name, StringPool.BLANK);
if (Validator.isNotNull(value)) {
return value;
}
return ContentUtil.get(PropsUtil.get(name));
}
public static String getContent(String name) throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getContent(preferences, 0, name);
}
public static double getDouble(long companyId, String name)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getDouble(preferences, companyId, name);
}
public static double getDouble(
long companyId, String name, double defaultValue)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getDouble(preferences, companyId, name, defaultValue);
}
public static double getDouble(
PortletPreferences preferences, long companyId, String name) {
return GetterUtil.getDouble(getString(preferences, companyId, name));
}
public static double getDouble(
PortletPreferences preferences, long companyId, String name,
double defaultValue) {
return GetterUtil.getDouble(
getString(preferences, companyId, name, defaultValue));
}
public static double getDouble(String name) throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getDouble(preferences, 0, name);
}
public static double getDouble(String name, double defaultValue)
throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getDouble(preferences, 0, name, defaultValue);
}
public static int getInteger(long companyId, String name)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getInteger(preferences, companyId, name);
}
public static int getInteger(long companyId, String name, int defaultValue)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getInteger(preferences, companyId, name, defaultValue);
}
public static int getInteger(
PortletPreferences preferences, long companyId, String name) {
return GetterUtil.getInteger(getString(preferences, companyId, name));
}
public static int getInteger(
PortletPreferences preferences, long companyId, String name,
int defaultValue) {
return GetterUtil.getInteger(
getString(preferences, companyId, name, defaultValue));
}
public static int getInteger(String name) throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getInteger(preferences, 0, name);
}
public static int getInteger(String name, int defaultValue)
throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getInteger(preferences, 0, name, defaultValue);
}
public static long getLong(long companyId, String name)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getLong(preferences, companyId, name);
}
public static long getLong(long companyId, String name, long defaultValue)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getLong(preferences, companyId, name, defaultValue);
}
public static long getLong(
PortletPreferences preferences, long companyId, String name) {
return GetterUtil.getLong(getString(preferences, companyId, name));
}
public static long getLong(
PortletPreferences preferences, long companyId, String name,
long defaultValue) {
return GetterUtil.getLong(
getString(preferences, companyId, name, defaultValue));
}
public static long getLong(String name) throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getLong(preferences, 0, name);
}
public static long getLong(String name, long defaultValue)
throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getLong(preferences, 0, name, defaultValue);
}
public static PortletPreferences getPreferences() throws SystemException {
return getPreferences(false);
}
public static PortletPreferences getPreferences(boolean readOnly)
throws SystemException {
PortalPreferencesWrapper portalPreferencesWrapper =
PortalPreferencesWrapperCacheUtil.get(
PortletKeys.PREFS_OWNER_ID_DEFAULT,
PortletKeys.PREFS_OWNER_TYPE_COMPANY);
if (portalPreferencesWrapper != null) {
if (!readOnly) {
portalPreferencesWrapper = portalPreferencesWrapper.clone();
}
return portalPreferencesWrapper;
}
return _portalPreferencesLocalService.getPreferences(
PortletKeys.PREFS_OWNER_ID_DEFAULT,
PortletKeys.PREFS_OWNER_TYPE_COMPANY);
}
public static PortletPreferences getPreferences(long companyId)
throws SystemException {
return getPreferences(companyId, false);
}
public static PortletPreferences getPreferences(
long companyId, boolean readOnly)
throws SystemException {
long ownerId = companyId;
int ownerType = PortletKeys.PREFS_OWNER_TYPE_COMPANY;
PortalPreferencesWrapper portalPreferencesWrapper =
PortalPreferencesWrapperCacheUtil.get(ownerId, ownerType);
if (portalPreferencesWrapper != null) {
if (!readOnly) {
portalPreferencesWrapper = portalPreferencesWrapper.clone();
}
return portalPreferencesWrapper;
}
return _portalPreferencesLocalService.getPreferences(
ownerId, ownerType);
}
public static Properties getProperties(
PortletPreferences preferences, long companyId, String prefix,
boolean removePrefix) {
Properties newProperties = new Properties();
Enumeration<String> enu = preferences.getNames();
while (enu.hasMoreElements()) {
String key = enu.nextElement();
if (key.startsWith(prefix)) {
String value = preferences.getValue(key, StringPool.BLANK);
if (removePrefix) {
key = key.substring(prefix.length());
}
newProperties.setProperty(key, value);
}
}
return newProperties;
}
public static Properties getProperties(String prefix, boolean removePrefix)
throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getProperties(preferences, 0, prefix, removePrefix);
}
public static short getShort(long companyId, String name)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getShort(preferences, companyId, name);
}
public static short getShort(
long companyId, String name, short defaultValue)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getShort(preferences, companyId, name, defaultValue);
}
public static short getShort(
PortletPreferences preferences, long companyId, String name) {
return GetterUtil.getShort(getString(preferences, companyId, name));
}
public static short getShort(
PortletPreferences preferences, long companyId, String name,
short defaultValue) {
return GetterUtil.getShort(
getString(preferences, companyId, name, defaultValue));
}
public static short getShort(String name) throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getShort(preferences, 0, name);
}
public static short getShort(String name, short defaultValue)
throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getShort(preferences, 0, name, defaultValue);
}
public static String getString(long companyId, String name)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getString(preferences, companyId, name);
}
public static String getString(
long companyId, String name, String defaultValue)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getString(preferences, companyId, name, defaultValue);
}
public static String getString(
PortletPreferences preferences, long companyId, String name) {
String value = PropsUtil.get(name);
return preferences.getValue(name, value);
}
public static String getString(
PortletPreferences preferences, long companyId, String name,
boolean defaultValue) {
String value = getString(preferences, companyId, name);
if (value != null) {
return value;
}
if (defaultValue) {
return preferences.getValue(name, StringPool.TRUE);
}
return preferences.getValue(name, StringPool.FALSE);
}
public static String getString(
PortletPreferences preferences, long companyId, String name,
double defaultValue) {
String value = getString(preferences, companyId, name);
if (value != null) {
return value;
}
return String.valueOf(defaultValue);
}
public static String getString(
PortletPreferences preferences, long companyId, String name,
int defaultValue) {
String value = getString(preferences, companyId, name);
if (value != null) {
return value;
}
return String.valueOf(defaultValue);
}
public static String getString(
PortletPreferences preferences, long companyId, String name,
long defaultValue) {
String value = getString(preferences, companyId, name);
if (value != null) {
return value;
}
return String.valueOf(defaultValue);
}
public static String getString(
PortletPreferences preferences, long companyId, String name,
short defaultValue) {
String value = getString(preferences, companyId, name);
if (value != null) {
return value;
}
return String.valueOf(defaultValue);
}
public static String getString(
PortletPreferences preferences, long companyId, String name,
String defaultValue) {
String value = getString(preferences, companyId, name);
if (value != null) {
return value;
}
return defaultValue;
}
public static String getString(String name) throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getString(preferences, 0, name);
}
public static String getString(String name, String defaultValue)
throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getString(preferences, 0, name, defaultValue);
}
public static String[] getStringArray(
long companyId, String name, String delimiter)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getStringArray(preferences, companyId, name, delimiter);
}
public static String[] getStringArray(
long companyId, String name, String delimiter,
String[] defaultValue)
throws SystemException {
PortletPreferences preferences = getPreferences(companyId, true);
return getStringArray(
preferences, companyId, name, delimiter, defaultValue);
}
public static String[] getStringArray(
PortletPreferences preferences, long companyId, String name,
String delimiter) {
String value = PropsUtil.get(name);
value = preferences.getValue(name, value);
return StringUtil.split(value, delimiter);
}
public static String[] getStringArray(
PortletPreferences preferences, long companyId, String name,
String delimiter, String[] defaultValue) {
String value = preferences.getValue(name, null);
if (value == null) {
return defaultValue;
}
return StringUtil.split(value, delimiter);
}
public static String[] getStringArray(String name, String delimiter)
throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getStringArray(preferences, 0, name, delimiter);
}
public static String[] getStringArray(
String name, String delimiter, String[] defaultValue)
throws SystemException {
PortletPreferences preferences = getPreferences(true);
return getStringArray(preferences, 0, name, delimiter, defaultValue);
}
public static String getStringFromNames(long companyId, String... names)
throws SystemException {
for (String name : names) {
String value = getString(companyId, name);
if (Validator.isNotNull(value)) {
return value;
}
}
return null;
}
@BeanReference(type = PortalPreferencesLocalService.class)
private static PortalPreferencesLocalService _portalPreferencesLocalService;
}

28
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/util/PropsFiles.java

@ -0,0 +1,28 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.util;
/**
* @author Brian Wing Shun Chan
*/
public class PropsFiles {
public static final String CAPTCHA = "captcha";
public static final String CONTENT_TYPES = "content-types";
public static final String PORTAL = "portal";
}

348
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/util/PropsUtil.java

@ -0,0 +1,348 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.util;
import com.liferay.portal.configuration.ConfigurationImpl;
import com.liferay.portal.kernel.configuration.Configuration;
import com.liferay.portal.kernel.configuration.Filter;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.servlet.WebDirDetector;
import com.liferay.portal.kernel.util.CharPool;
import com.liferay.portal.kernel.util.ClassUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.ReleaseInfo;
import com.liferay.portal.kernel.util.ServerDetector;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.SystemProperties;
import com.liferay.portal.kernel.util.UnicodeProperties;
import com.liferay.portal.model.CompanyConstants;
import com.liferay.portal.security.auth.CompanyThreadLocal;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import javax.servlet.Servlet;
/**
* @author Brian Wing Shun Chan
*/
public class PropsUtil {
public static void addProperties(Properties properties) {
_instance._addProperties(properties);
}
public static void addProperties(UnicodeProperties unicodeProperties) {
_instance._addProperties(unicodeProperties);
}
public static boolean contains(String key) {
return _instance._contains(key);
}
public static String get(String key) {
return _instance._get(key);
}
public static String get(String key, Filter filter) {
return _instance._get(key, filter);
}
public static String[] getArray(String key) {
return _instance._getArray(key);
}
public static String[] getArray(String key, Filter filter) {
return _instance._getArray(key, filter);
}
public static Properties getProperties() {
return _instance._getProperties();
}
public static Properties getProperties(
String prefix, boolean removePrefix) {
return _instance._getProperties(prefix, removePrefix);
}
public static void reload() {
_instance = new PropsUtil();
}
public static void removeProperties(Properties properties) {
_instance._removeProperties(properties);
}
public static void set(String key, String value) {
_instance._set(key, value);
}
private PropsUtil() {
try {
// Default liferay home directory
SystemProperties.set(
PropsKeys.DEFAULT_LIFERAY_HOME, _getDefaultLiferayHome());
// Global shared lib directory
String globalSharedLibDir = _getLibDir(Servlet.class);
if (_log.isInfoEnabled()) {
_log.info("Global shared lib directory " + globalSharedLibDir);
}
SystemProperties.set(
PropsKeys.LIFERAY_LIB_GLOBAL_SHARED_DIR, globalSharedLibDir);
// Global lib directory
String globalLibDir = _getLibDir(ReleaseInfo.class);
if (_log.isInfoEnabled()) {
_log.info("Global lib directory " + globalLibDir);
}
SystemProperties.set(
PropsKeys.LIFERAY_LIB_GLOBAL_DIR, globalLibDir);
// Portal lib directory
Class<?> clazz = getClass();
ClassLoader classLoader = clazz.getClassLoader();
String portalLibDir = WebDirDetector.getLibDir(classLoader);
String portalLibDirProperty = System.getProperty(
PropsKeys.LIFERAY_LIB_PORTAL_DIR);
if (portalLibDirProperty != null) {
if (!portalLibDirProperty.endsWith(StringPool.SLASH)) {
portalLibDirProperty += StringPool.SLASH;
}
portalLibDir = portalLibDirProperty;
}
if (_log.isInfoEnabled()) {
_log.info("Portal lib directory " + portalLibDir);
}
SystemProperties.set(
PropsKeys.LIFERAY_LIB_PORTAL_DIR, portalLibDir);
// Portal web directory
String portalWebDir = WebDirDetector.getRootDir(portalLibDir);
if (_log.isDebugEnabled()) {
_log.debug("Portal web directory " + portalWebDir);
}
SystemProperties.set(
PropsKeys.LIFERAY_WEB_PORTAL_DIR, portalWebDir);
// Liferay home directory
_configuration = new ConfigurationImpl(
PropsUtil.class.getClassLoader(), PropsFiles.PORTAL);
String liferayHome = _get(PropsKeys.LIFERAY_HOME);
if (_log.isDebugEnabled()) {
_log.debug("Configured Liferay home " + liferayHome);
}
SystemProperties.set(PropsKeys.LIFERAY_HOME, liferayHome);
// Ehcache disk directory
SystemProperties.set(
"ehcache.disk.store.dir", liferayHome + "/data/ehcache");
if (GetterUtil.getBoolean(
SystemProperties.get("company-id-properties"))) {
_configurations = new HashMap<Long, Configuration>();
}
}
catch (Exception e) {
if (_log.isErrorEnabled()) {
_log.error("Unable to initialize PropsUtil", e);
}
}
}
private void _addProperties(Properties properties) {
_getConfiguration().addProperties(properties);
}
private void _addProperties(UnicodeProperties unicodeProperties) {
Properties properties = new Properties();
properties.putAll(unicodeProperties);
_addProperties(properties);
}
private boolean _contains(String key) {
return _getConfiguration().contains(key);
}
private String _get(String key) {
return _getConfiguration().get(key);
}
private String _get(String key, Filter filter) {
return _getConfiguration().get(key, filter);
}
private String[] _getArray(String key) {
return _getConfiguration().getArray(key);
}
private String[] _getArray(String key, Filter filter) {
return _getConfiguration().getArray(key, filter);
}
private Configuration _getConfiguration() {
if (_configurations == null) {
return _configuration;
}
Long companyId = CompanyThreadLocal.getCompanyId();
if (companyId > CompanyConstants.SYSTEM) {
Configuration configuration = _configurations.get(companyId);
if (configuration == null) {
configuration = new ConfigurationImpl(
PropsUtil.class.getClassLoader(), PropsFiles.PORTAL,
companyId);
_configurations.put(companyId, configuration);
}
return configuration;
}
else {
return _configuration;
}
}
private String _getDefaultLiferayHome() {
String defaultLiferayHome = null;
if (ServerDetector.isGeronimo()) {
defaultLiferayHome =
SystemProperties.get("org.apache.geronimo.home.dir") + "/..";
}
else if (ServerDetector.isGlassfish()) {
defaultLiferayHome =
SystemProperties.get("com.sun.aas.installRoot") + "/..";
}
else if (ServerDetector.isJBoss()) {
defaultLiferayHome = SystemProperties.get("jboss.home.dir") + "/..";
}
else if (ServerDetector.isJOnAS()) {
defaultLiferayHome = SystemProperties.get("jonas.base") + "/..";
}
else if (ServerDetector.isWebLogic()) {
defaultLiferayHome =
SystemProperties.get("env.DOMAIN_HOME") + "/..";
}
else if (ServerDetector.isJetty()) {
defaultLiferayHome = SystemProperties.get("jetty.home") + "/..";
}
else if (ServerDetector.isResin()) {
defaultLiferayHome = SystemProperties.get("resin.home") + "/..";
}
else if (ServerDetector.isTomcat()) {
defaultLiferayHome = SystemProperties.get("catalina.base") + "/..";
}
else {
defaultLiferayHome = SystemProperties.get("user.dir") + "/liferay";
}
defaultLiferayHome = StringUtil.replace(
defaultLiferayHome, CharPool.BACK_SLASH, CharPool.SLASH);
defaultLiferayHome = StringUtil.replace(
defaultLiferayHome, StringPool.DOUBLE_SLASH, StringPool.SLASH);
if (defaultLiferayHome.endsWith("/..")) {
int pos = defaultLiferayHome.lastIndexOf(
CharPool.SLASH, defaultLiferayHome.length() - 4);
if (pos != -1) {
defaultLiferayHome = defaultLiferayHome.substring(0, pos);
}
}
if (_log.isDebugEnabled()) {
_log.debug("Default Liferay home " + defaultLiferayHome);
}
return defaultLiferayHome;
}
private String _getLibDir(Class<?> clazz) {
String path = ClassUtil.getParentPath(
clazz.getClassLoader(), clazz.getName());
int pos = path.lastIndexOf(".jar!");
if (pos == -1) {
pos = path.lastIndexOf(".jar/");
}
pos = path.lastIndexOf(CharPool.SLASH, pos);
path = path.substring(0, pos + 1);
return path;
}
private Properties _getProperties() {
return _getConfiguration().getProperties();
}
private Properties _getProperties(String prefix, boolean removePrefix) {
return _getConfiguration().getProperties(prefix, removePrefix);
}
private void _removeProperties(Properties properties) {
_getConfiguration().removeProperties(properties);
}
private void _set(String key, String value) {
_getConfiguration().set(key, value);
}
private static Log _log = LogFactoryUtil.getLog(PropsUtil.class);
private static PropsUtil _instance = new PropsUtil();
private Configuration _configuration;
private Map<Long, Configuration> _configurations;
}

2156
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portal/util/PropsValues.java

File diff soppresso perché troppo grande Load Diff

357
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/BasePreferencesImpl.java

@ -0,0 +1,357 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portlet;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.xml.simple.Element;
import com.liferay.util.xml.XMLFormatter;
import java.io.IOException;
import java.io.Serializable;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.portlet.ReadOnlyException;
import javax.portlet.ValidatorException;
/**
* @author Alexander Chow
* @author Shuyang Zhou
*/
public abstract class BasePreferencesImpl implements Serializable {
public BasePreferencesImpl(
long ownerId, int ownerType, String xml,
Map<String, Preference> preferences) {
_ownerId = ownerId;
_ownerType = ownerType;
_originalXML = xml;
_originalPreferences = preferences;
}
public Map<String, String[]> getMap() {
Map<String, String[]> map = new HashMap<String, String[]>();
Map<String, Preference> preferences = getPreferences();
for (Map.Entry<String, Preference> entry : preferences.entrySet()) {
String key = entry.getKey();
Preference preference = entry.getValue();
String[] actualValues = getActualValues(preference.getValues());
map.put(key, actualValues);
}
return Collections.unmodifiableMap(map);
}
public Enumeration<String> getNames() {
Map<String, Preference> preferences = getPreferences();
return Collections.enumeration(preferences.keySet());
}
public long getOwnerId() {
return _ownerId;
}
public int getOwnerType() {
return _ownerType;
}
public String getValue(String key, String def) {
if (key == null) {
throw new IllegalArgumentException();
}
Map<String, Preference> preferences = getPreferences();
Preference preference = preferences.get(key);
String[] values = null;
if (preference != null) {
values = preference.getValues();
}
if (!isNull(values)) {
return getActualValue(values[0]);
}
else {
return getActualValue(def);
}
}
public String[] getValues(String key, String[] def) {
if (key == null) {
throw new IllegalArgumentException();
}
Map<String, Preference> preferences = getPreferences();
Preference preference = preferences.get(key);
String[] values = null;
if (preference != null) {
values = preference.getValues();
}
if (!isNull(values)) {
return getActualValues(values);
}
else {
return getActualValues(def);
}
}
public boolean isReadOnly(String key) {
if (key == null) {
throw new IllegalArgumentException();
}
Map<String, Preference> preferences = getPreferences();
Preference preference = preferences.get(key);
if ((preference != null) && preference.isReadOnly()) {
return true;
}
else {
return false;
}
}
public void reset() {
_modifiedPreferences = null;
}
public abstract void reset(String key) throws ReadOnlyException;
public void setValue(String key, String value) throws ReadOnlyException {
if (key == null) {
throw new IllegalArgumentException();
}
value = getXMLSafeValue(value);
Map<String, Preference> modifiedPreferences = getModifiedPreferences();
Preference preference = modifiedPreferences.get(key);
if (preference == null) {
preference = new Preference(key, value);
modifiedPreferences.put(key, preference);
}
if (preference.isReadOnly()) {
throw new ReadOnlyException(key);
}
else {
preference = (Preference)preference.clone();
modifiedPreferences.put(key, preference);
preference.setValues(new String[] {value});
}
}
public void setValues(String key, String[] values)
throws ReadOnlyException {
if (key == null) {
throw new IllegalArgumentException();
}
values = getXMLSafeValues(values);
Map<String, Preference> modifiedPreferences = getModifiedPreferences();
Preference preference = modifiedPreferences.get(key);
if (preference == null) {
preference = new Preference(key, values);
modifiedPreferences.put(key, preference);
}
if (preference.isReadOnly()) {
throw new ReadOnlyException(key);
}
else {
preference = (Preference)preference.clone();
modifiedPreferences.put(key, preference);
preference.setValues(values);
}
}
public int size() {
Map<String, Preference> preferences = getPreferences();
return preferences.size();
}
public abstract void store() throws IOException, ValidatorException;
protected String getActualValue(String value) {
if ((value == null) || value.equals(_NULL_VALUE)) {
return null;
}
else {
return XMLFormatter.fromCompactSafe(value);
}
}
protected String[] getActualValues(String[] values) {
if (values == null) {
return null;
}
if (values.length == 1) {
String actualValue = getActualValue(values[0]);
if (actualValue == null) {
return null;
}
else {
return new String[] {actualValue};
}
}
String[] actualValues = new String[values.length];
for (int i = 0; i < actualValues.length; i++) {
actualValues[i] = getActualValue(values[i]);
}
return actualValues;
}
protected Map<String, Preference> getModifiedPreferences() {
if (_modifiedPreferences == null) {
_modifiedPreferences = new ConcurrentHashMap<String, Preference>(
_originalPreferences);
}
return _modifiedPreferences;
}
protected Map<String, Preference> getOriginalPreferences() {
return _originalPreferences;
}
protected String getOriginalXML() {
return _originalXML;
}
protected Map<String, Preference> getPreferences() {
if (_modifiedPreferences != null) {
return _modifiedPreferences;
}
return _originalPreferences;
}
protected String getXMLSafeValue(String value) {
if (value == null) {
return _NULL_VALUE;
}
else {
return XMLFormatter.toCompactSafe(value);
}
}
protected String[] getXMLSafeValues(String[] values) {
if (values == null) {
return new String[] {_NULL_VALUE};
}
String[] xmlSafeValues = new String[values.length];
for (int i = 0; i < xmlSafeValues.length; i++) {
xmlSafeValues[i] = getXMLSafeValue(values[i]);
}
return xmlSafeValues;
}
protected boolean isNull(String[] values) {
if (ArrayUtil.isEmpty(values) ||
((values.length == 1) && (getActualValue(values[0]) == null))) {
return true;
}
return false;
}
protected void setOriginalPreferences(
Map<String, Preference> originalPreferences) {
_originalPreferences = originalPreferences;
}
protected void setOriginalXML(String originalXML) {
_originalXML = originalXML;
}
protected String toXML() {
if ((_modifiedPreferences == null) && (_originalXML != null)) {
return _originalXML;
}
Map<String, Preference> preferences = getPreferences();
Element portletPreferencesElement = new Element(
"portlet-preferences", false);
for (Map.Entry<String, Preference> entry : preferences.entrySet()) {
Preference preference = entry.getValue();
Element preferenceElement = portletPreferencesElement.addElement(
"preference");
preferenceElement.addElement("name", preference.getName());
for (String value : preference.getValues()) {
preferenceElement.addElement("value", value);
}
if (preference.isReadOnly()) {
preferenceElement.addElement("read-only", Boolean.TRUE);
}
}
return portletPreferencesElement.toXMLString();
}
private static final String _NULL_VALUE = "NULL_VALUE";
private Map<String, Preference> _modifiedPreferences;
private Map<String, Preference> _originalPreferences;
private String _originalXML;
private long _ownerId;
private int _ownerType;
}

414
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/PortalPreferencesImpl.java

@ -0,0 +1,414 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portlet;
import com.liferay.portal.kernel.dao.orm.LockMode;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.transaction.TransactionAttribute;
import com.liferay.portal.kernel.transaction.TransactionInvokerUtil;
import com.liferay.portal.kernel.util.HashUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.service.PortalPreferencesLocalServiceUtil;
import com.liferay.portal.service.persistence.PortalPreferencesPersistence;
import com.liferay.portal.service.persistence.PortalPreferencesUtil;
import java.io.IOException;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.ConcurrentModificationException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import javax.portlet.ReadOnlyException;
/**
* @author Brian Wing Shun Chan
* @author Alexander Chow
*/
public class PortalPreferencesImpl
extends BasePreferencesImpl
implements Cloneable, PortalPreferences, Serializable {
public static final TransactionAttribute TRANSACTION_ATTRIBUTE;
static {
TransactionAttribute.Builder builder =
new TransactionAttribute.Builder();
builder.setRollbackForClasses(
PortalException.class, SystemException.class);
TRANSACTION_ATTRIBUTE = builder.build();
}
public PortalPreferencesImpl() {
this(0, 0, null, Collections.<String, Preference>emptyMap(), false);
}
public PortalPreferencesImpl(
long ownerId, int ownerType, String xml,
Map<String, Preference> preferences, boolean signedIn) {
super(ownerId, ownerType, xml, preferences);
_signedIn = signedIn;
}
@Override
public PortalPreferencesImpl clone() {
return new PortalPreferencesImpl(
getOwnerId(), getOwnerType(), getOriginalXML(),
new HashMap<String, Preference>(
getOriginalPreferences()), isSignedIn());
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof PortalPreferencesImpl)) {
return false;
}
PortalPreferencesImpl portalPreferences = (PortalPreferencesImpl)obj;
if ((getOwnerId() == portalPreferences.getOwnerId()) &&
(getOwnerType() == portalPreferences.getOwnerType()) &&
getPreferences().equals(portalPreferences.getPreferences())) {
return true;
}
else {
return false;
}
}
@Override
public long getUserId() {
return _userId;
}
@Override
public String getValue(String namespace, String key) {
return getValue(namespace, key, null);
}
@Override
public String getValue(String namespace, String key, String defaultValue) {
key = _encodeKey(namespace, key);
return super.getValue(key, defaultValue);
}
@Override
public String[] getValues(String namespace, String key) {
return getValues(namespace, key, null);
}
@Override
public String[] getValues(
String namespace, String key, String[] defaultValue) {
key = _encodeKey(namespace, key);
return super.getValues(key, defaultValue);
}
@Override
public int hashCode() {
int hashCode = HashUtil.hash(0, getOwnerId());
hashCode = HashUtil.hash(hashCode, getOwnerType());
hashCode = HashUtil.hash(hashCode, getPreferences());
return hashCode;
}
@Override
public boolean isSignedIn() {
return _signedIn;
}
@Override
public void reset(final String key) throws ReadOnlyException {
if (isReadOnly(key)) {
throw new ReadOnlyException(key);
}
try {
validateStore(
new Callable<Void>() {
@Override
public Void call() {
Map<String, Preference> modifiedPreferences =
getModifiedPreferences();
modifiedPreferences.remove(key);
return null;
}
}, key);
}
catch (ConcurrentModificationException cme) {
throw cme;
}
catch (Throwable t) {
_log.error(t, t);
}
}
@Override
public void resetValues(String namespace) {
Map<String, Preference> preferences = getPreferences();
try {
for (Map.Entry<String, Preference> entry : preferences.entrySet()) {
String key = entry.getKey();
if (key.startsWith(namespace) && !isReadOnly(key)) {
reset(key);
}
}
}
catch (ConcurrentModificationException cme) {
throw cme;
}
catch (Exception e) {
_log.error(e, e);
}
}
@Override
public void setSignedIn(boolean signedIn) {
_signedIn = signedIn;
}
@Override
public void setUserId(long userId) {
_userId = userId;
}
@Override
public void setValue(
final String namespace, final String key, final String value) {
if (Validator.isNull(key) || key.equals(_RANDOM_KEY)) {
return;
}
try {
Callable<Void> callable = new Callable<Void>() {
@Override
public Void call() throws ReadOnlyException {
String encodedKey = _encodeKey(namespace, key);
if (value == null) {
reset(encodedKey);
}
else {
PortalPreferencesImpl.super.setValue(encodedKey, value);
}
return null;
}
};
if (_signedIn) {
validateStore(callable, _encodeKey(namespace, key));
}
else {
callable.call();
}
}
catch (ConcurrentModificationException cme) {
throw cme;
}
catch (Throwable t) {
_log.error(t, t);
}
}
@Override
public void setValues(
final String namespace, final String key, final String[] values) {
if (Validator.isNull(key) || key.equals(_RANDOM_KEY)) {
return;
}
try {
Callable<Void> callable = new Callable<Void>() {
@Override
public Void call() throws ReadOnlyException {
String encodedKey = _encodeKey(namespace, key);
if (values == null) {
reset(encodedKey);
}
else {
PortalPreferencesImpl.super.setValues(
encodedKey, values);
}
return null;
}
};
if (_signedIn) {
validateStore(callable, _encodeKey(namespace, key));
}
else {
callable.call();
}
}
catch (ConcurrentModificationException cme) {
throw cme;
}
catch (Throwable t) {
_log.error(t, t);
}
}
private Callable<Boolean> _createValidateCallable(
final String[] originalValues, final String key) {
return new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
com.liferay.portal.model.PortalPreferences
preferences = PortalPreferencesUtil.fetchByO_O(
getOwnerId(), getOwnerType(), false);
PortalPreferencesPersistence portalPreferencesPersistence =
PortalPreferencesUtil.getPersistence();
Session session =
portalPreferencesPersistence.getCurrentSession();
session.evict(preferences);
preferences = (com.liferay.portal.model.PortalPreferences)
session.get(
com.liferay.portal.model.impl.
PortalPreferencesImpl.class,
preferences.getPrimaryKey(), LockMode.UPGRADE);
PortalPreferencesImpl portalPreferencesImpl =
(PortalPreferencesImpl)
PortletPreferencesFactoryUtil.fromXML(
getOwnerId(), getOwnerType(),
preferences.getPreferences());
String originalXML = getOriginalXML();
if (originalXML.equals(preferences.getPreferences())) {
store();
return true;
}
if (!Arrays.equals(
originalValues,
portalPreferencesImpl.getValues(key, (String[])null))) {
return false;
}
reset();
setOriginalPreferences(
portalPreferencesImpl.getOriginalPreferences());
setOriginalXML(preferences.getPreferences());
return null;
}
};
}
protected void validateStore(final Callable<?> callable, final String key)
throws Throwable {
while (true) {
String[] originalValues = super.getValues(key, null);
callable.call();
Boolean result = TransactionInvokerUtil.invoke(
TRANSACTION_ATTRIBUTE,
_createValidateCallable(originalValues, key));
if (result == null) {
continue;
}
if (!result) {
PortalPreferencesWrapperCacheUtil.remove(
getOwnerId(), getOwnerType());
throw new ConcurrentModificationException();
}
break;
}
}
@Override
public void store() throws IOException {
try {
PortalPreferencesLocalServiceUtil.updatePreferences(
getOwnerId(), getOwnerType(), this);
}
catch (SystemException se) {
throw new IOException(se.getMessage());
}
}
private String _encodeKey(String namespace, String key) {
if (Validator.isNull(namespace)) {
return key;
}
else {
return namespace.concat(StringPool.POUND).concat(key);
}
}
private static final String _RANDOM_KEY = "r";
private static Log _log = LogFactoryUtil.getLog(
PortalPreferencesImpl.class);
private boolean _signedIn;
private long _userId;
}

96
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/PortalPreferencesWrapper.java

@ -0,0 +1,96 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portlet;
import java.io.IOException;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.Map;
import javax.portlet.PortletPreferences;
import javax.portlet.ReadOnlyException;
/**
* @author Alexander Chow
*/
public class PortalPreferencesWrapper
implements Cloneable, PortletPreferences, Serializable {
public PortalPreferencesWrapper(
PortalPreferencesImpl portalPreferencesImpl) {
_portalPreferencesImpl = portalPreferencesImpl;
}
@Override
public PortalPreferencesWrapper clone() {
return new PortalPreferencesWrapper(_portalPreferencesImpl.clone());
}
@Override
public Map<String, String[]> getMap() {
return _portalPreferencesImpl.getMap();
}
@Override
public Enumeration<String> getNames() {
return _portalPreferencesImpl.getNames();
}
public PortalPreferencesImpl getPortalPreferencesImpl() {
return _portalPreferencesImpl;
}
@Override
public String getValue(String key, String def) {
return _portalPreferencesImpl.getValue(null, key, def);
}
@Override
public String[] getValues(String key, String[] def) {
return _portalPreferencesImpl.getValues(null, key, def);
}
@Override
public boolean isReadOnly(String key) {
return _portalPreferencesImpl.isReadOnly(key);
}
@Override
public void reset(String key) throws ReadOnlyException {
_portalPreferencesImpl.reset(key);
}
@Override
public void setValue(String key, String value) throws ReadOnlyException {
_portalPreferencesImpl.setValue(key, value);
}
@Override
public void setValues(String key, String[] values)
throws ReadOnlyException {
_portalPreferencesImpl.setValues(key, values);
}
@Override
public void store() throws IOException {
_portalPreferencesImpl.store();
}
private PortalPreferencesImpl _portalPreferencesImpl;
}

58
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/PortalPreferencesWrapperCacheUtil.java

@ -0,0 +1,58 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portlet;
import com.liferay.portal.kernel.cache.MultiVMPoolUtil;
import com.liferay.portal.kernel.cache.PortalCache;
import com.liferay.portal.kernel.util.StringUtil;
/**
* @author Shuyang Zhou
*/
public class PortalPreferencesWrapperCacheUtil {
public static final String CACHE_NAME =
PortalPreferencesWrapperCacheUtil.class.getName();
public static PortalPreferencesWrapper get(long ownerId, int ownerType) {
String cacheKey = StringUtil.toHexString(ownerId).concat(
StringUtil.toHexString(ownerType));
return _portalPreferencesWrapperPortalCache.get(cacheKey);
}
public static void put(
long ownerId, int ownerType,
PortalPreferencesWrapper portalPreferencesWrapper) {
String cacheKey = StringUtil.toHexString(ownerId).concat(
StringUtil.toHexString(ownerType));
_portalPreferencesWrapperPortalCache.put(
cacheKey, portalPreferencesWrapper);
}
public static void remove(long ownerId, int ownerType) {
String cacheKey = StringUtil.toHexString(ownerId).concat(
StringUtil.toHexString(ownerType));
_portalPreferencesWrapperPortalCache.remove(cacheKey);
}
private static PortalCache<String, PortalPreferencesWrapper>
_portalPreferencesWrapperPortalCache = MultiVMPoolUtil.getCache(
CACHE_NAME);
}

97
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/Preference.java

@ -0,0 +1,97 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portlet;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import java.io.Serializable;
/**
* @author Brian Wing Shun Chan
*/
public class Preference implements Cloneable, Serializable {
public Preference(String name, String value) {
this(name, new String[] {value});
}
public Preference(String name, String value, boolean readOnly) {
this(name, new String[] {value}, readOnly);
}
public Preference(String name, String[] values) {
this(name, values, false);
}
public Preference(String name, String[] values, boolean readOnly) {
_name = name;
_values = values;
_readOnly = readOnly;
}
@Override
public Object clone() {
return new Preference(_name, _values, _readOnly);
}
public String getName() {
return _name;
}
public boolean getReadOnly() {
return _readOnly;
}
public String[] getValues() {
return _values;
}
public boolean isReadOnly() {
return _readOnly;
}
public void setValues(String[] values) {
_values = values;
}
@Override
public String toString() {
StringBundler sb = new StringBundler(6 + (_values.length * 2 - 1));
sb.append("{name=");
sb.append(getName());
sb.append(", readOnly=");
sb.append(_readOnly);
sb.append(", values=[");
for (int i = 0; i < _values.length; i++) {
sb.append(_values[i]);
if (i < (_values.length - 1)) {
sb.append(StringPool.COMMA);
}
}
sb.append("]}");
return sb.toString();
}
private String _name;
private boolean _readOnly;
private String[] _values;
}

164
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/documentlibrary/service/permission/DLFileEntryPermission.java

@ -0,0 +1,164 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portlet.documentlibrary.service.permission;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.staging.permission.StagingPermissionUtil;
import com.liferay.portal.kernel.workflow.permission.WorkflowPermissionUtil;
import com.liferay.portal.security.auth.PrincipalException;
import com.liferay.portal.security.permission.ActionKeys;
import com.liferay.portal.security.permission.PermissionChecker;
import com.liferay.portal.util.PortletKeys;
import com.liferay.portal.util.PropsValues;
import com.liferay.portlet.documentlibrary.NoSuchFolderException;
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.documentlibrary.model.DLFileVersion;
import com.liferay.portlet.documentlibrary.model.DLFolder;
import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
/**
* @author Brian Wing Shun Chan
* @author Charles May
*/
public class DLFileEntryPermission {
public static void check(
PermissionChecker permissionChecker, DLFileEntry dlFileEntry,
String actionId)
throws PortalException, SystemException {
if (!contains(permissionChecker, dlFileEntry, actionId)) {
throw new PrincipalException();
}
}
public static void check(
PermissionChecker permissionChecker, FileEntry fileEntry,
String actionId)
throws PortalException, SystemException {
if (!fileEntry.containsPermission(permissionChecker, actionId)) {
throw new PrincipalException();
}
}
public static void check(
PermissionChecker permissionChecker, long fileEntryId,
String actionId)
throws PortalException, SystemException {
if (!contains(permissionChecker, fileEntryId, actionId)) {
throw new PrincipalException();
}
}
public static boolean contains(
PermissionChecker permissionChecker, DLFileEntry dlFileEntry,
String actionId)
throws PortalException, SystemException {
Boolean hasPermission = StagingPermissionUtil.hasPermission(
permissionChecker, dlFileEntry.getGroupId(),
DLFileEntry.class.getName(), dlFileEntry.getFileEntryId(),
PortletKeys.DOCUMENT_LIBRARY, actionId);
if (hasPermission != null) {
return hasPermission.booleanValue();
}
DLFileVersion latestDLFileVersion = dlFileEntry.getLatestFileVersion(
true);
if (latestDLFileVersion.isPending()) {
hasPermission = WorkflowPermissionUtil.hasPermission(
permissionChecker, dlFileEntry.getGroupId(),
DLFileEntry.class.getName(), dlFileEntry.getFileEntryId(),
actionId);
if (hasPermission != null) {
return hasPermission.booleanValue();
}
}
if (actionId.equals(ActionKeys.VIEW) &&
PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE) {
long dlFolderId = dlFileEntry.getFolderId();
if (dlFolderId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
if (!DLPermission.contains(
permissionChecker, dlFileEntry.getGroupId(),
actionId)) {
return false;
}
}
else {
try {
DLFolder dlFolder = DLFolderLocalServiceUtil.getFolder(
dlFolderId);
if (!DLFolderPermission.contains(
permissionChecker, dlFolder, ActionKeys.ACCESS) &&
!DLFolderPermission.contains(
permissionChecker, dlFolder, ActionKeys.VIEW)) {
return false;
}
}
catch (NoSuchFolderException nsfe) {
if (!dlFileEntry.isInTrash()) {
throw nsfe;
}
}
}
}
if (permissionChecker.hasOwnerPermission(
dlFileEntry.getCompanyId(), DLFileEntry.class.getName(),
dlFileEntry.getFileEntryId(), dlFileEntry.getUserId(),
actionId)) {
return true;
}
return permissionChecker.hasPermission(
dlFileEntry.getGroupId(), DLFileEntry.class.getName(),
dlFileEntry.getFileEntryId(), actionId);
}
public static boolean contains(
PermissionChecker permissionChecker, FileEntry fileEntry,
String actionId)
throws PortalException, SystemException {
return fileEntry.containsPermission(permissionChecker, actionId);
}
public static boolean contains(
PermissionChecker permissionChecker, long fileEntryId,
String actionId)
throws PortalException, SystemException {
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(fileEntryId);
return fileEntry.containsPermission(permissionChecker, actionId);
}
}

165
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/documentlibrary/service/permission/DLFolderPermission.java

@ -0,0 +1,165 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portlet.documentlibrary.service.permission;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.repository.model.Folder;
import com.liferay.portal.kernel.staging.permission.StagingPermissionUtil;
import com.liferay.portal.security.auth.PrincipalException;
import com.liferay.portal.security.permission.ActionKeys;
import com.liferay.portal.security.permission.PermissionChecker;
import com.liferay.portal.util.PortletKeys;
import com.liferay.portal.util.PropsValues;
import com.liferay.portlet.documentlibrary.NoSuchFolderException;
import com.liferay.portlet.documentlibrary.model.DLFolder;
import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
/**
* @author Brian Wing Shun Chan
*/
public class DLFolderPermission {
public static void check(
PermissionChecker permissionChecker, DLFolder dlFolder,
String actionId)
throws PortalException, SystemException {
if (!contains(permissionChecker, dlFolder, actionId)) {
throw new PrincipalException();
}
}
public static void check(
PermissionChecker permissionChecker, Folder folder, String actionId)
throws PortalException, SystemException {
if (!folder.containsPermission(permissionChecker, actionId)) {
throw new PrincipalException();
}
}
public static void check(
PermissionChecker permissionChecker, long groupId, long folderId,
String actionId)
throws PortalException, SystemException {
if (!contains(permissionChecker, groupId, folderId, actionId)) {
throw new PrincipalException();
}
}
public static boolean contains(
PermissionChecker permissionChecker, DLFolder dlFolder,
String actionId)
throws PortalException, SystemException {
if (actionId.equals(ActionKeys.ADD_FOLDER)) {
actionId = ActionKeys.ADD_SUBFOLDER;
}
Boolean hasPermission = StagingPermissionUtil.hasPermission(
permissionChecker, dlFolder.getGroupId(), DLFolder.class.getName(),
dlFolder.getFolderId(), PortletKeys.DOCUMENT_LIBRARY, actionId);
if (hasPermission != null) {
return hasPermission.booleanValue();
}
if (actionId.equals(ActionKeys.VIEW) &&
PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE) {
try {
long dlFolderId = dlFolder.getFolderId();
while (dlFolderId !=
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
dlFolder = DLFolderLocalServiceUtil.getFolder(dlFolderId);
if (!_hasPermission(
permissionChecker, dlFolder, actionId)) {
return false;
}
dlFolderId = dlFolder.getParentFolderId();
}
}
catch (NoSuchFolderException nsfe) {
if (!dlFolder.isInTrash()) {
throw nsfe;
}
}
return DLPermission.contains(
permissionChecker, dlFolder.getGroupId(), actionId);
}
return _hasPermission(permissionChecker, dlFolder, actionId);
}
public static boolean contains(
PermissionChecker permissionChecker, Folder folder, String actionId)
throws PortalException, SystemException {
return folder.containsPermission(permissionChecker, actionId);
}
public static boolean contains(
PermissionChecker permissionChecker, long groupId, long folderId,
String actionId)
throws PortalException, SystemException {
if (folderId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
// Prevent the propagation of checks for actions that are not
// supported at the application resource level. See LPS-24245.
if (actionId.equals(ActionKeys.ACCESS) ||
actionId.equals(ActionKeys.ADD_SUBFOLDER) ||
actionId.equals(ActionKeys.DELETE)) {
return false;
}
return DLPermission.contains(permissionChecker, groupId, actionId);
}
Folder folder = DLAppLocalServiceUtil.getFolder(folderId);
return folder.containsPermission(permissionChecker, actionId);
}
private static boolean _hasPermission(
PermissionChecker permissionChecker, DLFolder dlFolder,
String actionId) {
if (permissionChecker.hasOwnerPermission(
dlFolder.getCompanyId(), DLFolder.class.getName(),
dlFolder.getFolderId(), dlFolder.getUserId(), actionId) ||
permissionChecker.hasPermission(
dlFolder.getGroupId(), DLFolder.class.getName(),
dlFolder.getFolderId(), actionId)) {
return true;
}
return false;
}
}

81
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/documentlibrary/service/permission/DLPermission.java

@ -0,0 +1,81 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portlet.documentlibrary.service.permission;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.staging.permission.StagingPermissionUtil;
import com.liferay.portal.model.ResourceConstants;
import com.liferay.portal.security.auth.PrincipalException;
import com.liferay.portal.security.permission.PermissionChecker;
import com.liferay.portal.service.ResourceLocalServiceUtil;
import com.liferay.portal.service.ResourcePermissionLocalServiceUtil;
import com.liferay.portal.util.PortletKeys;
/**
* @author Jorge Ferrer
*/
public class DLPermission {
public static final String RESOURCE_NAME =
"com.liferay.portlet.documentlibrary";
public static void check(
PermissionChecker permissionChecker, long groupId, String actionId)
throws PortalException {
if (!contains(permissionChecker, groupId, actionId)) {
throw new PrincipalException();
}
}
public static boolean contains(
PermissionChecker permissionChecker, long groupId, String actionId) {
Boolean hasPermission = StagingPermissionUtil.hasPermission(
permissionChecker, groupId, RESOURCE_NAME, groupId,
PortletKeys.DOCUMENT_LIBRARY, actionId);
if (hasPermission != null) {
return hasPermission.booleanValue();
}
try {
int count =
ResourcePermissionLocalServiceUtil.getResourcePermissionsCount(
permissionChecker.getCompanyId(), RESOURCE_NAME,
ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(groupId));
if (count == 0) {
ResourceLocalServiceUtil.addResources(
permissionChecker.getCompanyId(), groupId, 0, RESOURCE_NAME,
groupId, false, true, true);
}
}
catch (Exception e) {
if (_log.isWarnEnabled()) {
_log.warn(e, e);
}
}
return permissionChecker.hasPermission(
groupId, RESOURCE_NAME, groupId, actionId);
}
private static Log _log = LogFactoryUtil.getLog(DLPermission.class);
}

406
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/documentlibrary/util/DocumentConversionUtil.java

@ -0,0 +1,406 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portlet.documentlibrary.util;
import com.artofsolving.jodconverter.DefaultDocumentFormatRegistry;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.DocumentFormat;
import com.artofsolving.jodconverter.DocumentFormatRegistry;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
import com.artofsolving.jodconverter.openoffice.converter.StreamOpenOfficeDocumentConverter;
import com.liferay.portal.kernel.configuration.Filter;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.io.unsync.UnsyncByteArrayOutputStream;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.util.FileUtil;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.SortedArrayList;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.SystemProperties;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.util.PrefsPropsUtil;
import com.liferay.portal.util.PropsUtil;
import com.liferay.portal.util.PropsValues;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Bruno Farache
* @author Alexander Chow
*/
public class DocumentConversionUtil {
public static File convert(
String id, InputStream inputStream, String sourceExtension,
String targetExtension)
throws IOException, SystemException {
return _instance._convert(
id, inputStream, sourceExtension, targetExtension);
}
public static void disconnect() {
_instance._disconnect();
}
public static String[] getConversions(String extension) {
return _instance._getConversions(extension);
}
public static String getFilePath(String id, String targetExtension) {
StringBundler sb = new StringBundler(5);
sb.append(SystemProperties.get(SystemProperties.TMP_DIR));
sb.append("/liferay/document_conversion/");
sb.append(id);
sb.append(StringPool.PERIOD);
sb.append(targetExtension);
return sb.toString();
}
public static boolean isComparableVersion(String extension) {
boolean enabled = false;
String periodAndExtension = StringPool.PERIOD.concat(extension);
for (int i = 0; i < _COMPARABLE_FILE_EXTENSIONS.length; i++) {
if (StringPool.STAR.equals(_COMPARABLE_FILE_EXTENSIONS[i]) ||
periodAndExtension.equals(_COMPARABLE_FILE_EXTENSIONS[i])) {
enabled = true;
break;
}
}
if (!enabled) {
return false;
}
if (extension.equals("css") || extension.equals("htm") ||
extension.equals("html") || extension.equals("js") ||
extension.equals("txt") || extension.equals("xml")) {
return true;
}
try {
if (isEnabled() && isConvertBeforeCompare(extension)) {
return true;
}
}
catch (Exception e) {
if (_log.isErrorEnabled()) {
_log.error(e, e);
}
}
return false;
}
public static boolean isConvertBeforeCompare(String extension) {
if (extension.equals("txt")) {
return false;
}
String[] conversions = getConversions(extension);
for (int i = 0; i < conversions.length; i++) {
if (conversions[i].equals("txt")) {
return true;
}
}
return false;
}
public static boolean isEnabled() {
try {
return PrefsPropsUtil.getBoolean(
PropsKeys.OPENOFFICE_SERVER_ENABLED,
PropsValues.OPENOFFICE_SERVER_ENABLED);
}
catch (Exception e) {
}
return false;
}
private DocumentConversionUtil() {
_populateConversionsMap("drawing");
_populateConversionsMap("presentation");
_populateConversionsMap("spreadsheet");
_populateConversionsMap("text");
}
private File _convert(
String id, InputStream inputStream, String sourceExtension,
String targetExtension)
throws IOException, SystemException {
if (!isEnabled()) {
return null;
}
sourceExtension = _fixExtension(sourceExtension);
targetExtension = _fixExtension(targetExtension);
_validate(targetExtension, id);
String fileName = getFilePath(id, targetExtension);
File file = new File(fileName);
if (PropsValues.OPENOFFICE_CACHE_ENABLED && file.exists()) {
return file;
}
DocumentFormatRegistry documentFormatRegistry =
new DefaultDocumentFormatRegistry();
DocumentFormat inputDocumentFormat =
documentFormatRegistry.getFormatByFileExtension(sourceExtension);
DocumentFormat outputDocumentFormat =
documentFormatRegistry.getFormatByFileExtension(targetExtension);
if (inputDocumentFormat == null) {
throw new SystemException(
"Conversion is not supported from ." + sourceExtension);
}
else if (!inputDocumentFormat.isImportable()) {
throw new SystemException(
"Conversion is not supported from " +
inputDocumentFormat.getName());
}
else if (outputDocumentFormat == null) {
throw new SystemException(
"Conversion is not supported from " +
inputDocumentFormat.getName() + " to ." +
targetExtension);
}
else if (!inputDocumentFormat.isExportableTo(outputDocumentFormat)) {
throw new SystemException(
"Conversion is not supported from " +
inputDocumentFormat.getName() + " to " +
outputDocumentFormat.getName());
}
UnsyncByteArrayOutputStream unsyncByteArrayOutputStream =
new UnsyncByteArrayOutputStream();
DocumentConverter documentConverter = _getDocumentConverter();
documentConverter.convert(
inputStream, inputDocumentFormat, unsyncByteArrayOutputStream,
outputDocumentFormat);
FileUtil.write(
file, unsyncByteArrayOutputStream.unsafeGetByteArray(), 0,
unsyncByteArrayOutputStream.size());
return file;
}
private void _disconnect() {
if (_openOfficeConnection != null) {
_openOfficeConnection.disconnect();
}
}
private String _fixExtension(String extension) {
if (extension.equals("htm")) {
extension = "html";
}
return extension;
}
private String[] _getConversions(String extension) {
extension = _fixExtension(extension);
String[] conversions = _conversionsMap.get(extension);
if (conversions == null) {
conversions = _DEFAULT_CONVERSIONS;
}
else {
if (ArrayUtil.contains(conversions, extension)) {
List<String> conversionsList = new ArrayList<String>();
for (int i = 0; i < conversions.length; i++) {
String conversion = conversions[i];
if (!conversion.equals(extension)) {
conversionsList.add(conversion);
}
}
conversions = conversionsList.toArray(
new String[conversionsList.size()]);
}
}
return conversions;
}
private DocumentConverter _getDocumentConverter() throws SystemException {
if ((_openOfficeConnection != null) && (_documentConverter != null)) {
return _documentConverter;
}
String host = PrefsPropsUtil.getString(
PropsKeys.OPENOFFICE_SERVER_HOST);
int port = PrefsPropsUtil.getInteger(
PropsKeys.OPENOFFICE_SERVER_PORT,
PropsValues.OPENOFFICE_SERVER_PORT);
if (_isRemoteOpenOfficeHost(host)) {
_openOfficeConnection = new SocketOpenOfficeConnection(host, port);
_documentConverter = new StreamOpenOfficeDocumentConverter(
_openOfficeConnection);
}
else {
_openOfficeConnection = new SocketOpenOfficeConnection(port);
_documentConverter = new OpenOfficeDocumentConverter(
_openOfficeConnection);
}
return _documentConverter;
}
private boolean _isRemoteOpenOfficeHost(String host) {
if (Validator.isNotNull(host) && !host.equals(_LOCALHOST_IP) &&
!host.startsWith(_LOCALHOST)) {
return true;
}
else {
return false;
}
}
private void _populateConversionsMap(String documentFamily) {
Filter filter = new Filter(documentFamily);
DocumentFormatRegistry documentFormatRegistry =
new DefaultDocumentFormatRegistry();
String[] sourceExtensions = PropsUtil.getArray(
PropsKeys.OPENOFFICE_CONVERSION_SOURCE_EXTENSIONS, filter);
String[] targetExtensions = PropsUtil.getArray(
PropsKeys.OPENOFFICE_CONVERSION_TARGET_EXTENSIONS, filter);
for (String sourceExtension : sourceExtensions) {
List<String> conversions = new SortedArrayList<String>();
DocumentFormat sourceDocumentFormat =
documentFormatRegistry.getFormatByFileExtension(
sourceExtension);
if (sourceDocumentFormat == null) {
if (_log.isWarnEnabled()) {
_log.warn("Invalid source extension " + sourceExtension);
}
continue;
}
for (String targetExtension : targetExtensions) {
DocumentFormat targetDocumentFormat =
documentFormatRegistry.getFormatByFileExtension(
targetExtension);
if (targetDocumentFormat == null) {
if (_log.isWarnEnabled()) {
_log.warn(
"Invalid target extension " + targetDocumentFormat);
}
continue;
}
if (sourceDocumentFormat.isExportableTo(targetDocumentFormat)) {
conversions.add(targetExtension);
}
}
if (conversions.isEmpty()) {
if (_log.isInfoEnabled()) {
_log.info(
"There are no conversions supported from " +
sourceExtension);
}
}
else {
if (_log.isInfoEnabled()) {
_log.info(
"Conversions supported from " + sourceExtension +
" to " + conversions);
}
_conversionsMap.put(
sourceExtension,
conversions.toArray(new String[conversions.size()]));
}
}
}
private void _validate(String targetExtension, String id)
throws SystemException {
if (!Validator.isFileExtension(targetExtension)) {
throw new SystemException("Invalid extension: " + targetExtension);
}
if (!Validator.isFileName(id)) {
throw new SystemException("Invalid file name: " + id);
}
}
private static final String[] _COMPARABLE_FILE_EXTENSIONS =
PropsValues.DL_COMPARABLE_FILE_EXTENSIONS;
private static final String[] _DEFAULT_CONVERSIONS = new String[0];
private static final String _LOCALHOST = "localhost";
private static final String _LOCALHOST_IP = "127.0.0.1";
private static Log _log = LogFactoryUtil.getLog(
DocumentConversionUtil.class);
private static DocumentConversionUtil _instance =
new DocumentConversionUtil();
private Map<String, String[]> _conversionsMap =
new HashMap<String, String[]>();
private DocumentConverter _documentConverter;
private OpenOfficeConnection _openOfficeConnection;
}

118
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/com/liferay/portlet/documentlibrary/util/LiferayPDFBoxConverter.java

@ -0,0 +1,118 @@
/**
* Copyright (c) 2000-2013 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
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portlet.documentlibrary.util;
import com.liferay.portal.image.ImageToolImpl;
import com.liferay.portal.kernel.image.ImageTool;
import java.awt.image.RenderedImage;
import java.io.File;
import javax.imageio.ImageIO;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPageTree;
import org.apache.pdfbox.rendering.ImageType;
import org.apache.pdfbox.rendering.PDFRenderer;
/**
* @author Juan Gonzalez
*/
public class LiferayPDFBoxConverter {
public LiferayPDFBoxConverter(
File inputFile, File thumbnailFile, File[] previewFiles,
String extension, String thumbnailExtension, int dpi, int height,
int width, boolean generatePreview, boolean generateThumbnail) {
_inputFile = inputFile;
_thumbnailFile = thumbnailFile;
_previewFiles = previewFiles;
_extension = extension;
_thumbnailExtension = thumbnailExtension;
_dpi = dpi;
_height = height;
_width = width;
_generatePreview = generatePreview;
_generateThumbnail = generateThumbnail;
}
public void generateImagesPB() throws Exception {
PDDocument pdDocument = null;
try {
pdDocument = PDDocument.load(_inputFile);
PDFRenderer pdfRenderer = new PDFRenderer(pdDocument);
PDPageTree pdPageTree = pdDocument.getPages();
int count = pdPageTree.getCount();
for (int i = 0; i < count; i++) {
if (_generateThumbnail && (i == 0)) {
_generateImagesPB(
pdfRenderer, i, _thumbnailFile, _thumbnailExtension);
}
if (!_generatePreview) {
break;
}
_generateImagesPB(pdfRenderer, i, _previewFiles[i], _extension);
}
}
finally {
if (pdDocument != null) {
pdDocument.close();
}
}
}
private void _generateImagesPB(
PDFRenderer pdfRenderer, int pageIndex, File outputFile,
String extension)
throws Exception {
RenderedImage renderedImage = pdfRenderer.renderImageWithDPI(
pageIndex, _dpi, ImageType.RGB);
ImageTool imageTool = ImageToolImpl.getInstance();
if (_height != 0) {
renderedImage = imageTool.scale(renderedImage, _width, _height);
}
else {
renderedImage = imageTool.scale(renderedImage, _width);
}
outputFile.createNewFile();
ImageIO.write(renderedImage, extension, outputFile);
}
private int _dpi;
private String _extension;
private boolean _generatePreview;
private boolean _generateThumbnail;
private int _height;
private File _inputFile;
private File[] _previewFiles;
private String _thumbnailExtension;
private File _thumbnailFile;
private int _width;
}

636
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/it/mwg/sicilia/preview/SiciliaP7MProcessor.java

@ -0,0 +1,636 @@
/**
* Copyright (c) 2000-2013 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 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*/
package it.mwg.sicilia.preview;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
import java.util.concurrent.Future;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.time.StopWatch;
import org.apache.pdfbox.pdmodel.PDDocument;
import com.liferay.portal.kernel.image.GhostscriptUtil;
import com.liferay.portal.kernel.lar.PortletDataContext;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.messaging.DestinationNames;
import com.liferay.portal.kernel.process.ClassPathUtil;
import com.liferay.portal.kernel.process.ProcessCallable;
import com.liferay.portal.kernel.process.ProcessException;
import com.liferay.portal.kernel.process.ProcessExecutor;
import com.liferay.portal.kernel.process.ProcessUtil;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.repository.model.FileVersion;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.FileUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.MimeTypesUtil;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.ServerDetector;
import com.liferay.portal.kernel.util.StreamUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.SystemEnv;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.xml.Element;
import com.liferay.portal.log.Log4jLogFactoryImpl;
import com.liferay.portal.repository.liferayrepository.model.LiferayFileVersion;
import com.liferay.portal.util.PropsUtil;
import com.liferay.portal.util.PropsValues;
import com.liferay.portlet.documentlibrary.NoSuchFileEntryException;
import com.liferay.portlet.documentlibrary.store.DLStoreUtil;
import com.liferay.portlet.documentlibrary.util.DLPreviewableProcessor;
import com.liferay.portlet.documentlibrary.util.DLUtil;
import com.liferay.portlet.documentlibrary.util.DocumentConversionUtil;
import com.liferay.portlet.documentlibrary.util.LiferayPDFBoxConverter;
import com.liferay.portlet.documentlibrary.util.PDFProcessor;
import com.liferay.util.log4j.Log4JUtil;
/**
* @author Alexander Chow
* @author Mika Koivisto
* @author Juan González
* @author Sergio González
* @author Ivica Cardic
* @author Manifattura Web Group Srl
*/
public class SiciliaP7MProcessor extends DLPreviewableProcessor implements PDFProcessor {
@Override
public void afterPropertiesSet() throws Exception {
FileUtil.mkdirs(PREVIEW_TMP_PATH);
FileUtil.mkdirs(THUMBNAIL_TMP_PATH);
}
@Override
public void generateImages(FileVersion sourceFileVersion, FileVersion destinationFileVersion) throws Exception {
_generateImages(sourceFileVersion, destinationFileVersion);
}
@Override
public InputStream getPreviewAsStream(FileVersion fileVersion, int index) throws Exception {
return doGetPreviewAsStream(fileVersion, index, PREVIEW_TYPE);
}
@Override
public int getPreviewFileCount(FileVersion fileVersion) {
try {
return doGetPreviewFileCount(fileVersion);
} catch (Exception e) {
_log.error(e, e);
}
return 0;
}
@Override
public long getPreviewFileSize(FileVersion fileVersion, int index) throws Exception {
return doGetPreviewFileSize(fileVersion, index);
}
@Override
public InputStream getThumbnailAsStream(FileVersion fileVersion, int index) throws Exception {
return doGetThumbnailAsStream(fileVersion, index);
}
@Override
public long getThumbnailFileSize(FileVersion fileVersion, int index) throws Exception {
return doGetThumbnailFileSize(fileVersion, index);
}
@Override
public boolean hasImages(FileVersion fileVersion) {
boolean hasImages = false;
try {
hasImages = _hasImages(fileVersion);
if (!hasImages && isSupported(fileVersion)) {
_queueGeneration(null, fileVersion);
}
} catch (Exception e) {
_log.error(e, e);
}
return hasImages;
}
@Override
public boolean isDocumentSupported(FileVersion fileVersion) {
return isSupported(fileVersion);
}
@Override
public boolean isDocumentSupported(String mimeType) {
return isSupported(mimeType);
}
@Override
public boolean isSupported(String mimeType) {
if (Validator.isNull(mimeType)) {
return false;
}
if (mimeType.equals(ContentTypes.APPLICATION_PDF) || mimeType.equals(ContentTypes.APPLICATION_X_PDF)
|| mimeType.equals("application/pkcs7-mime")) {
return true;
}
if (DocumentConversionUtil.isEnabled()) {
Set<String> extensions = MimeTypesUtil.getExtensions(mimeType);
for (String extension : extensions) {
extension = extension.substring(1);
String[] targetExtensions = DocumentConversionUtil.getConversions(extension);
if (Arrays.binarySearch(targetExtensions, "pdf") >= 0) {
return true;
}
}
}
return false;
}
@Override
public void trigger(FileVersion sourceFileVersion, FileVersion destinationFileVersion) {
super.trigger(sourceFileVersion, destinationFileVersion);
_queueGeneration(sourceFileVersion, destinationFileVersion);
}
@Override
protected void copyPreviews(FileVersion sourceFileVersion, FileVersion destinationFileVersion) {
if (!PropsValues.DL_FILE_ENTRY_PREVIEW_ENABLED) {
return;
}
try {
if (hasPreview(sourceFileVersion) && !hasPreview(destinationFileVersion)) {
int count = getPreviewFileCount(sourceFileVersion);
for (int i = 0; i < count; i++) {
String previewFilePath = getPreviewFilePath(destinationFileVersion, i + 1);
InputStream is = doGetPreviewAsStream(sourceFileVersion, i + 1, PREVIEW_TYPE);
addFileToStore(destinationFileVersion.getCompanyId(), PREVIEW_PATH, previewFilePath, is);
}
}
} catch (Exception e) {
_log.error(e, e);
}
}
@Override
protected void doExportGeneratedFiles(PortletDataContext portletDataContext, FileEntry fileEntry,
Element fileEntryElement) throws Exception {
exportThumbnails(portletDataContext, fileEntry, fileEntryElement, "pdf");
exportPreviews(portletDataContext, fileEntry, fileEntryElement);
}
@Override
protected void doImportGeneratedFiles(PortletDataContext portletDataContext, FileEntry fileEntry,
FileEntry importedFileEntry, Element fileEntryElement) throws Exception {
importThumbnails(portletDataContext, fileEntry, importedFileEntry, fileEntryElement, "pdf");
importPreviews(portletDataContext, fileEntry, importedFileEntry, fileEntryElement);
}
protected void exportPreviews(PortletDataContext portletDataContext, FileEntry fileEntry, Element fileEntryElement)
throws Exception {
FileVersion fileVersion = fileEntry.getFileVersion();
if (!isSupported(fileVersion) || !_hasImages(fileVersion)) {
return;
}
if (!portletDataContext.isPerformDirectBinaryImport()) {
int previewFileCount = getPreviewFileCount(fileVersion);
fileEntryElement.addAttribute("bin-path-pdf-preview-count", String.valueOf(previewFileCount));
for (int i = 0; i < previewFileCount; i++) {
exportPreview(portletDataContext, fileEntry, fileEntryElement, "pdf", PREVIEW_TYPE, i);
}
}
}
@Override
protected List<Long> getFileVersionIds() {
return _fileVersionIds;
}
@Override
protected String getPreviewType(FileVersion fileVersion) {
return PREVIEW_TYPE;
}
@Override
protected String getThumbnailType(FileVersion fileVersion) {
return THUMBNAIL_TYPE;
}
protected boolean hasPreview(FileVersion fileVersion) throws Exception {
return hasPreview(fileVersion, null);
}
@Override
protected boolean hasPreview(FileVersion fileVersion, String type) throws Exception {
String previewFilePath = getPreviewFilePath(fileVersion, 1);
return DLStoreUtil.hasFile(fileVersion.getCompanyId(), REPOSITORY_ID, previewFilePath);
}
protected void importPreviews(PortletDataContext portletDataContext, FileEntry fileEntry,
FileEntry importedFileEntry, Element fileEntryElement) throws Exception {
int previewFileCount = GetterUtil.getInteger(fileEntryElement.attributeValue("bin-path-pdf-preview-count"));
for (int i = 0; i < previewFileCount; i++) {
importPreview(portletDataContext, fileEntry, importedFileEntry, fileEntryElement, "pdf", PREVIEW_TYPE, i);
}
}
private void _generateImages(FileVersion fileVersion, File file) throws Exception {
if (GhostscriptUtil.isEnabled()) {
if (!_ghostscriptInitialized) {
GhostscriptUtil.reset();
_ghostscriptInitialized = true;
}
_generateImagesGS(fileVersion, file);
} else {
_generateImagesPB(fileVersion, file);
}
}
private void _generateImages(FileVersion sourceFileVersion, FileVersion destinationFileVersion) throws Exception {
InputStream inputStream = null;
try {
if (sourceFileVersion != null) {
copy(sourceFileVersion, destinationFileVersion);
return;
}
if (_hasImages(destinationFileVersion)) {
return;
}
String extension = destinationFileVersion.getExtension();
if (extension.equalsIgnoreCase("p7m")) {
inputStream = destinationFileVersion.getContentStream(false);
File p7m = File.createTempFile("p7m-input", ".p7m");
FileUtils.copyInputStreamToFile(inputStream, p7m);
File pdf = _extractPdfFromP7m(p7m);
_generateImages(destinationFileVersion, pdf);
pdf.delete();
p7m.delete();
} else if (extension.equalsIgnoreCase("pdf")) {
if (destinationFileVersion instanceof LiferayFileVersion) {
try {
LiferayFileVersion liferayFileVersion = (LiferayFileVersion) destinationFileVersion;
File file = liferayFileVersion.getFile(false);
_generateImages(destinationFileVersion, file);
return;
} catch (UnsupportedOperationException uoe) {}
}
inputStream = destinationFileVersion.getContentStream(false);
_generateImages(destinationFileVersion, inputStream);
} else if (DocumentConversionUtil.isEnabled()) {
inputStream = destinationFileVersion.getContentStream(false);
String tempFileId = DLUtil.getTempFileId(destinationFileVersion.getFileEntryId(),
destinationFileVersion.getVersion());
File file = DocumentConversionUtil.convert(tempFileId, inputStream, extension, "pdf");
_generateImages(destinationFileVersion, file);
}
} catch (NoSuchFileEntryException nsfee) {} finally {
StreamUtil.cleanUp(inputStream);
_fileVersionIds.remove(destinationFileVersion.getFileVersionId());
}
}
private File _extractPdfFromP7m(File p7m) throws Exception {
// openssl smime -verify -noverify -in document.pdf.p7m -inform DER -out document.pdf
File pdf = File.createTempFile("p7m-output", ".pdf");
List<String> arguments = new LinkedList<>();
arguments.add("openssl");
arguments.add("smime");
arguments.add("-verify");
arguments.add("-noverify");
arguments.add("-in");
arguments.add(p7m.getAbsolutePath());
arguments.add("-inform");
arguments.add("DER");
arguments.add("-out");
arguments.add(pdf.getAbsolutePath());
Future<?> future = ProcessUtil.execute(ProcessUtil.LOGGING_OUTPUT_PROCESSOR, arguments);
while (!future.isCancelled()) {
if (future.isDone()) {
futures.put(pdf.getAbsolutePath(), future);
break;
}
Thread.sleep(1000);
}
future.get();
return pdf;
}
private void _generateImages(FileVersion fileVersion, InputStream inputStream) throws Exception {
if (GhostscriptUtil.isEnabled()) {
_generateImagesGS(fileVersion, inputStream);
} else {
_generateImagesPB(fileVersion, inputStream);
}
}
private void _generateImagesGS(FileVersion fileVersion, File file) throws Exception {
if (_isGeneratePreview(fileVersion)) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
_generateImagesGS(fileVersion, file, false);
if (_log.isDebugEnabled()) {
int previewFileCount = getPreviewFileCount(fileVersion);
_log.debug("Ghostscript generated " + previewFileCount + " preview pages for " + fileVersion.getTitle()
+ " in " + stopWatch.getTime() + " ms");
}
}
if (_isGenerateThumbnail(fileVersion)) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
_generateImagesGS(fileVersion, file, true);
if (_log.isDebugEnabled()) {
_log.debug("Ghostscript generated a thumbnail for " + fileVersion.getTitle() + " in "
+ stopWatch.getTime() + " ms");
}
}
}
private void _generateImagesGS(FileVersion fileVersion, File file, boolean thumbnail) throws Exception {
// Generate images
String tempFileId = DLUtil.getTempFileId(fileVersion.getFileEntryId(), fileVersion.getVersion());
List<String> arguments = new ArrayList<String>();
arguments.add("-sDEVICE=png16m");
if (thumbnail) {
arguments.add("-sOutputFile=" + getThumbnailTempFilePath(tempFileId));
arguments.add("-dFirstPage=1");
arguments.add("-dLastPage=1");
} else {
arguments.add("-sOutputFile=" + getPreviewTempFilePath(tempFileId, -1));
}
arguments.add("-dPDFFitPage");
arguments.add("-dTextAlphaBits=4");
arguments.add("-dGraphicsAlphaBits=4");
arguments.add("-r" + PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_DPI);
if (PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_WIDTH != 0) {
arguments.add("-dDEVICEWIDTH=" + PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_WIDTH);
}
if (PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_HEIGHT != 0) {
arguments.add("-dDEVICEHEIGHT=" + PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_HEIGHT);
}
arguments.add(file.getPath());
Future<?> future = GhostscriptUtil.execute(arguments);
String processIdentity = String.valueOf(fileVersion.getFileVersionId());
while (!future.isCancelled()) {
if (future.isDone()) {
futures.put(processIdentity, future);
break;
}
Thread.sleep(1000);
}
future.get();
// Store images
if (thumbnail) {
File thumbnailTempFile = getThumbnailTempFile(tempFileId);
try {
storeThumbnailImages(fileVersion, thumbnailTempFile);
} finally {
FileUtil.delete(thumbnailTempFile);
}
} else {
int total = getPreviewTempFileCount(fileVersion);
for (int i = 0; i < total; i++) {
File previewTempFile = getPreviewTempFile(tempFileId, i + 2);
try {
addFileToStore(fileVersion.getCompanyId(), PREVIEW_PATH, getPreviewFilePath(fileVersion, i + 1),
previewTempFile);
} finally {
FileUtil.delete(previewTempFile);
}
}
}
}
private void _generateImagesGS(FileVersion fileVersion, InputStream inputStream) throws Exception {
File file = null;
try {
file = FileUtil.createTempFile(inputStream);
_generateImagesGS(fileVersion, file);
} finally {
FileUtil.delete(file);
}
}
private void _generateImagesPB(FileVersion fileVersion, File file) throws Exception {
String tempFileId = DLUtil.getTempFileId(fileVersion.getFileEntryId(), fileVersion.getVersion());
File thumbnailFile = getThumbnailTempFile(tempFileId);
int previewFilesCount = 0;
PDDocument pdDocument = null;
try {
pdDocument = PDDocument.load(file);
previewFilesCount = pdDocument.getNumberOfPages();
} finally {
if (pdDocument != null) {
pdDocument.close();
}
}
File[] previewFiles = new File[previewFilesCount];
for (int i = 0; i < previewFilesCount; i++) {
previewFiles[i] = getPreviewTempFile(tempFileId, i);
}
boolean generatePreview = _isGeneratePreview(fileVersion);
boolean generateThumbnail = _isGenerateThumbnail(fileVersion);
if (PropsValues.DL_FILE_ENTRY_PREVIEW_FORK_PROCESS_ENABLED) {
ProcessCallable<String> processCallable = new LiferayPDFBoxProcessCallable(ServerDetector.getServerId(),
PropsUtil.get(PropsKeys.LIFERAY_HOME), Log4JUtil.getCustomLogSettings(), file, thumbnailFile,
previewFiles, getThumbnailType(fileVersion), getPreviewType(fileVersion),
PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_DPI,
PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_HEIGHT,
PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_WIDTH, generatePreview, generateThumbnail);
Future<String> future = ProcessExecutor.execute(ClassPathUtil.getPortalClassPath(), processCallable);
String processIdentity = String.valueOf(fileVersion.getFileVersionId());
futures.put(processIdentity, future);
future.get();
} else {
LiferayPDFBoxConverter liferayConverter = new LiferayPDFBoxConverter(file, thumbnailFile, previewFiles,
getPreviewType(fileVersion), getThumbnailType(fileVersion),
PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_DPI,
PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_HEIGHT,
PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_WIDTH, generatePreview, generateThumbnail);
liferayConverter.generateImagesPB();
}
if (generateThumbnail) {
try {
storeThumbnailImages(fileVersion, thumbnailFile);
} finally {
FileUtil.delete(thumbnailFile);
}
if (_log.isDebugEnabled()) {
_log.debug("PDFBox generated a thumbnail for " + fileVersion.getFileVersionId());
}
}
if (generatePreview) {
int index = 0;
for (File previewFile : previewFiles) {
try {
addFileToStore(fileVersion.getCompanyId(), PREVIEW_PATH,
getPreviewFilePath(fileVersion, index + 1), previewFile);
} finally {
FileUtil.delete(previewFile);
}
index++;
}
if (_log.isDebugEnabled()) {
_log.debug("PDFBox generated " + getPreviewFileCount(fileVersion) + " preview pages for "
+ fileVersion.getFileVersionId());
}
}
}
private void _generateImagesPB(FileVersion fileVersion, InputStream inputStream) throws Exception {
File file = null;
try {
file = FileUtil.createTempFile(inputStream);
_generateImagesPB(fileVersion, file);
} finally {
FileUtil.delete(file);
}
}
private boolean _hasImages(FileVersion fileVersion) throws Exception {
if (PropsValues.DL_FILE_ENTRY_PREVIEW_ENABLED) {
if (!hasPreview(fileVersion)) {
return false;
}
}
return hasThumbnails(fileVersion);
}
private boolean _isGeneratePreview(FileVersion fileVersion) throws Exception {
return PropsValues.DL_FILE_ENTRY_PREVIEW_ENABLED && !hasPreview(fileVersion);
}
private boolean _isGenerateThumbnail(FileVersion fileVersion) throws Exception {
return PropsValues.DL_FILE_ENTRY_THUMBNAIL_ENABLED && !hasThumbnail(fileVersion, THUMBNAIL_INDEX_DEFAULT);
}
private void _queueGeneration(FileVersion sourceFileVersion, FileVersion destinationFileVersion) {
if (_fileVersionIds.contains(destinationFileVersion.getFileVersionId())) {
return;
}
boolean generateImages = false;
String extension = destinationFileVersion.getExtension();
if (extension.equalsIgnoreCase("pdf") || extension.equalsIgnoreCase("p7m")) {
generateImages = true;
} else if (DocumentConversionUtil.isEnabled()) {
String[] conversions = DocumentConversionUtil.getConversions(extension);
for (String conversion : conversions) {
if (conversion.equals("pdf")) {
generateImages = true;
break;
}
}
}
if (generateImages) {
_fileVersionIds.add(destinationFileVersion.getFileVersionId());
sendGenerationMessage(DestinationNames.DOCUMENT_LIBRARY_PDF_PROCESSOR, sourceFileVersion,
destinationFileVersion);
}
}
private static Log _log = LogFactoryUtil.getLog(SiciliaP7MProcessor.class);
private List<Long> _fileVersionIds = new Vector<Long>();
private boolean _ghostscriptInitialized = false;
private static class LiferayPDFBoxProcessCallable implements ProcessCallable<String> {
public LiferayPDFBoxProcessCallable(String serverId, String liferayHome, Map<String, String> customLogSettings,
File inputFile, File thumbnailFile, File[] previewFiles, String extension, String thumbnailExtension,
int dpi, int height, int width, boolean generatePreview, boolean generateThumbnail) {
_serverId = serverId;
_liferayHome = liferayHome;
_customLogSettings = customLogSettings;
_inputFile = inputFile;
_thumbnailFile = thumbnailFile;
_previewFiles = previewFiles;
_extension = extension;
_thumbnailExtension = thumbnailExtension;
_dpi = dpi;
_height = height;
_width = width;
_generatePreview = generatePreview;
_generateThumbnail = generateThumbnail;
}
@Override
public String call() throws ProcessException {
Properties systemProperties = System.getProperties();
SystemEnv.setProperties(systemProperties);
Class<?> clazz = getClass();
ClassLoader classLoader = clazz.getClassLoader();
Log4JUtil.initLog4J(_serverId, _liferayHome, classLoader, new Log4jLogFactoryImpl(), _customLogSettings);
try {
LiferayPDFBoxConverter liferayConverter = new LiferayPDFBoxConverter(_inputFile, _thumbnailFile,
_previewFiles, _extension, _thumbnailExtension, _dpi, _height, _width, _generatePreview,
_generateThumbnail);
liferayConverter.generateImagesPB();
} catch (Exception e) {
throw new ProcessException(e);
}
return StringPool.BLANK;
}
private static final long serialVersionUID = 1L;
private Map<String, String> _customLogSettings;
private int _dpi;
private String _extension;
private boolean _generatePreview;
private boolean _generateThumbnail;
private int _height;
private File _inputFile;
private String _liferayHome;
private File[] _previewFiles;
private String _serverId;
private String _thumbnailExtension;
private File _thumbnailFile;
private int _width;
}
}

7
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/portal-ext.properties

@ -0,0 +1,7 @@
dl.file.entry.processors= \
it.mwg.sicilia.preview.SiciliaP7MProcessor
dl.file.entry.processors2= \
com.liferay.portlet.documentlibrary.util.ImageProcessorImpl, \
it.mwg.sicilia.preview.SiciliaP7MProcessor, \
com.liferay.portlet.documentlibrary.util.RawMetadataProcessorImpl

1
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/src/portal.properties

@ -0,0 +1 @@
dummy=off

3
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/docroot/WEB-INF/web.xml

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
</web-app>

18
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/ivy.xml

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<ivy-module
version="2.0"
xmlns:m2="http://ant.apache.org/ivy/maven"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"
>
<info module="sicilia-p7m-preview-hook" organisation="com.liferay">
<extends extendType="configurations,description,info" location="../../ivy.xml" module="com.liferay.sdk" organisation="com.liferay" revision="latest.integration" />
</info>
<dependencies defaultconf="default">
<dependency conf="test->default" name="arquillian-junit-container" org="org.jboss.arquillian.junit" rev="1.1.6.Final" />
<dependency conf="test->default" name="arquillian-tomcat-remote-7" org="org.jboss.arquillian.container" rev="1.0.0.CR6" />
<dependency conf="test->default" name="com.liferay.ant.arquillian" org="com.liferay" rev="1.0.0" />
</dependencies>
</ivy-module>

1
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/ivy.xml.MD5

@ -0,0 +1 @@
9127728e0d6e6ef2db51aa670a9da3b8

15
liferay-plugins-sdk-6.2/hooks/sicilia-p7m-preview-hook/test/integration/arquillian.xml

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<arquillian
xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"
>
<container default="true" qualifier="tomcat">
<configuration>
<property name="jmxPort">8099</property>
<property name="pass">tomcat</property>
<property name="user">tomcat</property>
</configuration>
</container>
</arquillian>

BIN
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/bcprov-ext-jdk15to18.jar

File binario non mostrato.

BIN
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/bcprov-jdk15to18.jar

File binario non mostrato.

15
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/AsseverazioniUtil.java

@ -362,12 +362,7 @@ public class AsseverazioniUtil {
return soggettiPrincipali && soggetti && delegati;
}
} else {
for (String tipoSoggetto : REQUIRED.get(ASSEVERAZIONI_DOMANDA)) {
// Se committente e c'è delega => true
if (TipoSoggettoUtil.COMMITTENTE.equalsIgnoreCase(tipoSoggetto)
&& ValidazionePraticaUtil.isA98Required(dettPratica)) {
continue;
}
for (String tipoSoggetto : dettPratica.getTipiSoggettiAsseveranti()) {
if (isAsseverazioneDomandaRequiredByTipoSoggetto(dettPraticaId, tipoSoggetto)) {
List<Asseverazione> asseverazioniEseguite = AsseverazioneLocalServiceUtil
.findByDettPratica_Tipologia_InEsito(dettPraticaId, tipoSoggetto,
@ -445,8 +440,8 @@ public class AsseverazioniUtil {
case DIRETTORE_LAVORI:
params = new Object[] {
soggetto.getDescrizioneCompleta(),
(SoggettiUtil.isSoggettoPrincipale(soggetto.getSoggettoId(), dettPratica.getDettPraticaId()) ? "Principale"
: StringPool.BLANK)
(SoggettiUtil.isSoggettoPrincipale(soggetto.getSoggettoId(), dettPratica.getDettPraticaId())
? "Principale" : StringPool.BLANK)
+ (Validator.isNull(soggetto.getAmbitoProfessione()) ? StringPool.BLANK : (soggetto
.getAmbitoProfessione().equalsIgnoreCase("ambitoProf-altro") ? soggetto
.getAmbitoAttivita() : LanguageUtil.get(Locale.ITALIAN, "label-ambito-"
@ -474,8 +469,8 @@ public class AsseverazioniUtil {
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
params = new Object[] {
soggetto.getDescrizioneCompleta(),
(SoggettiUtil.isSoggettoPrincipale(soggetto.getSoggettoId(), dettPratica.getDettPraticaId()) ? "Principale"
: StringPool.BLANK)
(SoggettiUtil.isSoggettoPrincipale(soggetto.getSoggettoId(), dettPratica.getDettPraticaId())
? "Principale" : StringPool.BLANK)
+ (Validator.isNull(soggetto.getAmbitoProfessione()) ? StringPool.BLANK : (soggetto
.getAmbitoProfessione().equalsIgnoreCase("ambitoProf-altro") ? soggetto
.getAmbitoAttivita() : LanguageUtil.get(Locale.ITALIAN, "label-ambito-"

6
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/SorteggioPraticaUtil.java

@ -41,6 +41,8 @@ import org.apache.commons.lang.time.DateUtils;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.repository.model.Folder;
import com.liferay.portal.kernel.util.StringPool;
@ -68,6 +70,8 @@ public class SorteggioPraticaUtil {
private static final String FILE_ENTRY_TEMPLATE_SORTEGGIO = "Sorteggio";
private static final Log _log = LogFactoryUtil.getLog(SorteggioPraticaUtil.class);
/**
* Implementazione della procedura di sorteggio secondo i requisiti della Regione Siciliana.
*
@ -116,6 +120,8 @@ public class SorteggioPraticaUtil {
IntPratica pratica = m.getValue();
long intPraticaId = pratica.getIntPraticaId();
DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPraticaId);
_log.info("Pratica " + pratica.getNumeroProgetto() + " id " + pratica.getIntPraticaId()
+ " dettPratica " + (dettPratica == null ? 0 : dettPratica.getDettPraticaId()));
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(dettPratica.getCompanyId());
serviceContext.setScopeGroupId(dettPratica.getGroupId());

4
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties

@ -13,8 +13,8 @@
##
build.namespace=portos_bo
build.number=2759
build.date=1642600956690
build.number=2772
build.date=1646228476610
build.auto.upgrade=true
##

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/common/preview_file_entry.jsp

@ -1,3 +1,4 @@
<%@page import="com.liferay.portal.kernel.util.ContentTypes"%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.liferay.portlet.documentlibrary.util.RawMetadataProcessor"%>

13
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/page_desc_edificio.jsp

@ -1,3 +1,4 @@
<%@page import="com.liferay.portal.kernel.util.HtmlUtil"%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.liferay.portal.kernel.bean.BeanPropertiesUtil"%>
<%@ include file="/html/fascicolo/init.jsp" %>
@ -266,7 +267,7 @@
<div class="col-sm-6 col-md-6" >
<strong><span class='<%=BeanPropertiesUtil.getBoolean(dettPratica, "dccStruttureEleAltro") ? "fa fa-check-circle-o txt-green" : "fa fa-circle-o" %>'></span></strong>
<%= LanguageUtil.get(pageContext, "dcc-strutture-ele-misto-altro") %>
<span style="margin-left:20px"><strong><%=BeanPropertiesUtil.getString(dettPratica, "dccStruttureEleAltroDescrizione") %></strong></span>
<span style="margin-left:20px"><strong><%= HtmlUtil.escape(BeanPropertiesUtil.getString(dettPratica, "dccStruttureEleAltroDescrizione")) %></strong></span>
</div>
</div>
@ -299,7 +300,7 @@
<div class="col-sm-6 col-md-6" >
<strong><span class='<%=BeanPropertiesUtil.getBoolean(dettPratica, "dccOrizzontamentiAltro") ? "fa fa-check-circle-o txt-green" : "fa fa-circle-o" %>'></span></strong>
<%= LanguageUtil.get(pageContext, "dcc-orizzontamenti-altro") %>
<span style="margin-left:20px"><strong><%=BeanPropertiesUtil.getString(dettPratica, "dccOrizzontamentiAltroDescrizione") %></strong></span>
<span style="margin-left:20px"><strong><%= HtmlUtil.escape(BeanPropertiesUtil.getString(dettPratica, "dccOrizzontamentiAltroDescrizione")) %></strong></span>
</div>
</div>
@ -349,7 +350,7 @@
<div class="col-sm-6 col-md-6" >
<strong><span class='<%=BeanPropertiesUtil.getBoolean(dettPratica, "dccCoperturaAltro") ? "fa fa-check-circle-o txt-green" : "fa fa-circle-o" %>'></span></strong>
<%= LanguageUtil.get(pageContext, "dcc-copertura-altro") %>
<span style="margin-left:20px"><strong><%=BeanPropertiesUtil.getString(dettPratica, "dccCoperturaAltroDesrizione") %></strong></span>
<span style="margin-left:20px"><strong><%= HtmlUtil.escape(BeanPropertiesUtil.getString(dettPratica, "dccCoperturaAltroDesrizione")) %></strong></span>
</div>
</div>
@ -378,7 +379,7 @@
<div class="col-sm-12 col-md-12" >
<strong><span class='<%=BeanPropertiesUtil.getBoolean(dettPratica, "dccElemNonStrutAltro") ? "fa fa-check-circle-o txt-green" : "fa fa-circle-o" %>'></span></strong>
<%= LanguageUtil.get(pageContext, "dcc-elem-non-strut-altro") %>
<span style="margin-left:20px"><strong><%=BeanPropertiesUtil.getString(dettPratica, "dccElemNonStrutAltroDescrizione") %></strong></span>
<span style="margin-left:20px"><strong><%= HtmlUtil.escape(BeanPropertiesUtil.getString(dettPratica, "dccElemNonStrutAltroDescrizione")) %></strong></span>
</div>
</div>
@ -423,7 +424,7 @@
<div class="col-sm-12 col-md-12" >
<strong><span class='<%=BeanPropertiesUtil.getBoolean(dettPratica, "dccOpereDiRinforzoAltro") ? "fa fa-check-circle-o txt-green" : "fa fa-circle-o" %>'></span></strong>
<%= LanguageUtil.get(pageContext, "dcc-opere-di-rinforzo-altro") %>
<span style="margin-left:20px"><strong><%=BeanPropertiesUtil.getString(dettPratica, "dccOpereDiRinforzoAltroDescrizione") %></strong></span>
<span style="margin-left:20px"><strong><%= HtmlUtil.escape(BeanPropertiesUtil.getString(dettPratica, "dccOpereDiRinforzoAltroDescrizione")) %></strong></span>
</div>
</div>
</div>
@ -511,7 +512,7 @@
<div class="col-xs-12 col-sm-8 col-md-9 col-lg-9">
<strong><span class='<%=BeanPropertiesUtil.getBoolean(dettPratica, "deInfAltro") ? "fa fa-check-circle-o txt-green" : "fa fa-circle-o" %>'></span></strong>
<%= LanguageUtil.get(pageContext, "de-inf-altro") %>
<span style="margin-left:20px"><strong><%=BeanPropertiesUtil.getString(dettPratica, "deInfAltroDesc") %></strong></span>
<span style="margin-left:20px"><strong><%= HtmlUtil.escape(BeanPropertiesUtil.getString(dettPratica, "deInfAltroDesc")) %></strong></span>
</div>
</div>
</div>

5
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/page_dettagli_principali.jsp

@ -1,3 +1,4 @@
<%@page import="com.liferay.portal.kernel.util.HtmlUtil"%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="it.mwg.sismica.bo.shared.util.Generics"%>
<%@page import="it.mwg.sismica.bo.util.MappeUtil"%>
@ -264,7 +265,7 @@ String urlIframeMappe = MappeUtil.getUrlBo(request, dettPratica, comune, true);
<%= LanguageUtil.get(pageContext, "interv-fin-pub-desc") %>:
</div>
<div class="col-sm-6 col-md-2">
<strong><%= BeanPropertiesUtil.getString(dettPratica, "intervFinPubDesc") %></strong>
<strong><%= HtmlUtil.escape(BeanPropertiesUtil.getString(dettPratica, "intervFinPubDesc")) %></strong>
</div>
</div>
</div>
@ -520,7 +521,7 @@ String urlIframeMappe = MappeUtil.getUrlBo(request, dettPratica, comune, true);
<%= LanguageUtil.get(pageContext, "tc-altro") %>
</div>
<div class="col-sm-9 col-md-9">
<span><strong><%=BeanPropertiesUtil.getString(dettPratica, "tcAltroDescrizione") %></strong></span>
<span><strong><%= HtmlUtil.escape(BeanPropertiesUtil.getString(dettPratica, "tcAltroDescrizione")) %></strong></span>
</div>
</div>
<div class="row">

13
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/gestionefirme/avvisi_actions.jsp

@ -48,6 +48,19 @@
<portlet:param name="tabs1" value="<%=tabs1%>" />
</portlet:actionURL>
<c:if test="<%= ConfigurazioneLocalServiceUtil.isDeveloper(user)
&& avviso.getUserCodiceFiscalePrimaFirma().equalsIgnoreCase(user.getScreenName()) %>">
<portlet:actionURL name="simulaFirma" var="simulaFirmaURL">
<portlet:param name="mvcPath" value="/html/gestionefirme/view.jsp" />
<portlet:param name="avvisoId" value="<%= String.valueOf(avviso.getAvvisoId()) %>" />
<portlet:param name="backURL" value="<%= redirect %>" />
<portlet:param name="tabs1" value="<%= tabs1 %>" />
</portlet:actionURL>
<span class="tooltip-info" title="Simula la firma">
<liferay-ui:icon iconCssClass="fa fa-user-secret" url="<%= simulaFirmaURL %>"
linkCssClass="btn btn-action" />
</span>
</c:if>
<c:if test="<%=avviso.getUserCodiceFiscalePrimaFirma().equalsIgnoreCase(user.getScreenName()) %>">
<span class="tooltip-info" title="Assegna al Ruolo">
<liferay-ui:icon iconCssClass="fa fa-user-times" url="<%=rilasciaFirmaURL%>" linkCssClass="btn btn-action"/>

2
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/verify_fascicolo.jsp

@ -1,3 +1,4 @@
<%@page import="it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants"%>
<%@page import="java.util.HashSet"%>
<%@page import="java.util.Set"%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
@ -29,6 +30,7 @@ if (dettPratica == null) {
if (dettPratica == null) {
dettPratica = DettPraticaServiceUtil.getLastCompletedByIntPratica(intPraticaId);
}
dettPraticaId = dettPratica.getDettPraticaId();
}
%>
<liferay-portlet:renderURL var="verifyURL" windowState="<%= LiferayWindowState.POP_UP.toString() %>">

8
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/soggettipratica/view.jsp

@ -404,7 +404,8 @@ dataMap.put("id", PortletKeys.SOGGETTI + "_dialogEditSoggetto");
url="<%= detailsURL.toString() %>" useDialog="true" />
<%
if (soggetto.getFileVariazioneId() != 0) {
DocPratica pratica = DocPraticaLocalServiceUtil.getDocPratica(soggetto.getFileVariazioneId());
DocPratica pratica = DocPraticaLocalServiceUtil.fetchDocPratica(
soggetto.getFileVariazioneId());
if (pratica != null) {
//ADT BUG BO ID = 37 - AGGIUNTA FIRMATARI FILE BACK OFFICE
FirmeBean firme = FirmeUtil.deserialize(pratica.getJsonFirmatari());
@ -412,8 +413,9 @@ dataMap.put("id", PortletKeys.SOGGETTI + "_dialogEditSoggetto");
if (!firme.getFirmeDigitali().isEmpty()) {
title.append("Firme sul file:<ul>");
for (FirmeDetail firma : firme.getFirmeDigitali()) {
List<Soggetto> soggetti = SoggettoLocalServiceUtil.findByIntPratica_CodiceFiscale(
pratica.getIntPraticaId(), firma.getCfFirmatario());
List<Soggetto> soggetti = SoggettoLocalServiceUtil
.findByIntPratica_CodiceFiscale(pratica.getIntPraticaId(),
firma.getCfFirmatario());
if (soggetti.size() > 0) {
title.append("<li>").append(soggetti.get(0).getNome())
.append(StringPool.SPACE).append(soggetti.get(0).getCognome())

Caricamento…
Annulla
Salva