From f86cce86d30541c979e0d9a2c95b73911844d219 Mon Sep 17 00:00:00 2001 From: Gabriele Zigurella Date: Thu, 11 May 2023 15:39:51 +0200 Subject: [PATCH] add hook to handle missing filesystems --- .../fake-advanced-filesystem-hook/.classpath | 22 +++ .../fake-advanced-filesystem-hook/.project | 36 +++++ .../fake-advanced-filesystem-hook/build.xml | 6 + .../docroot/META-INF/MANIFEST.MF | 3 + .../docroot/WEB-INF/lib/.gitignore | 5 + .../docroot/WEB-INF/liferay-hook.xml | 9 ++ .../WEB-INF/liferay-plugin-package.properties | 11 ++ .../docroot/WEB-INF/liferay-releng.properties | 9 ++ .../WEB-INF/src/META-INF/javadocs-all.xml | 1 + .../WEB-INF/src/META-INF/javadocs-rt.xml | 2 + .../FakeDLFileEntryLocalServiceImpl.java | 153 ++++++++++++++++++ .../docroot/WEB-INF/web.xml | 3 + 12 files changed, 260 insertions(+) create mode 100644 liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/.classpath create mode 100644 liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/.project create mode 100644 liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/build.xml create mode 100644 liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/META-INF/MANIFEST.MF create mode 100644 liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/lib/.gitignore create mode 100644 liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/liferay-hook.xml create mode 100644 liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/liferay-plugin-package.properties create mode 100644 liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/liferay-releng.properties create mode 100644 liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/src/META-INF/javadocs-all.xml create mode 100644 liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/src/META-INF/javadocs-rt.xml create mode 100644 liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/src/com/liferay/portlet/documentlibrary/service/FakeDLFileEntryLocalServiceImpl.java create mode 100644 liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/web.xml diff --git a/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/.classpath b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/.classpath new file mode 100644 index 00000000..bc080147 --- /dev/null +++ b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/.classpath @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/.project b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/.project new file mode 100644 index 00000000..23dcd620 --- /dev/null +++ b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/.project @@ -0,0 +1,36 @@ + + + fake-advanced-filesystem-hook + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/build.xml b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/build.xml new file mode 100644 index 00000000..9cf1b083 --- /dev/null +++ b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/build.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/META-INF/MANIFEST.MF b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/META-INF/MANIFEST.MF new file mode 100644 index 00000000..254272e1 --- /dev/null +++ b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/lib/.gitignore b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/lib/.gitignore new file mode 100644 index 00000000..21d22fe0 --- /dev/null +++ b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/lib/.gitignore @@ -0,0 +1,5 @@ +/commons-logging.jar +/log4j.jar +/util-bridges.jar +/util-java.jar +/util-taglib.jar \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/liferay-hook.xml b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/liferay-hook.xml new file mode 100644 index 00000000..31684aee --- /dev/null +++ b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/liferay-hook.xml @@ -0,0 +1,9 @@ + + + + + + com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService + com.liferay.portlet.documentlibrary.service.FakeDLFileEntryLocalServiceImpl + + \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/liferay-plugin-package.properties b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/liferay-plugin-package.properties new file mode 100644 index 00000000..995de0f4 --- /dev/null +++ b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/liferay-plugin-package.properties @@ -0,0 +1,11 @@ +name=Sample Wrapper +module-group-id=liferay +module-incremental-version=1 +tags= +short-description=This hook shows how to wrap Liferay's core services and models. +long-description= +change-log= +page-url=http://www.liferay.com +author=Liferay, Inc. +licenses=LGPL +liferay-versions=6.2.0+ \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/liferay-releng.properties b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/liferay-releng.properties new file mode 100644 index 00000000..6dcac40c --- /dev/null +++ b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/liferay-releng.properties @@ -0,0 +1,9 @@ +bundle=false +category= +demo-url= +dependent-apps= +labs=true +marketplace=false +public=true +support-url= +supported=false \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/src/META-INF/javadocs-all.xml b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/src/META-INF/javadocs-all.xml new file mode 100644 index 00000000..2b5d4116 --- /dev/null +++ b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/src/META-INF/javadocs-all.xml @@ -0,0 +1 @@ + diff --git a/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/src/META-INF/javadocs-rt.xml b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/src/META-INF/javadocs-rt.xml new file mode 100644 index 00000000..eb07e2a3 --- /dev/null +++ b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/src/META-INF/javadocs-rt.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/src/com/liferay/portlet/documentlibrary/service/FakeDLFileEntryLocalServiceImpl.java b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/src/com/liferay/portlet/documentlibrary/service/FakeDLFileEntryLocalServiceImpl.java new file mode 100644 index 00000000..c2921c95 --- /dev/null +++ b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/src/com/liferay/portlet/documentlibrary/service/FakeDLFileEntryLocalServiceImpl.java @@ -0,0 +1,153 @@ +package com.liferay.portlet.documentlibrary.service; + +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 java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +public class FakeDLFileEntryLocalServiceImpl extends DLFileEntryLocalServiceWrapper { + + @Override + public File getFile(long userId, long fileEntryId, String version, + boolean incrementCounter, int increment) throws PortalException, + SystemException { + File file = null; + try{ + file = super.getFile(userId, fileEntryId, version, incrementCounter, increment); + } catch (Exception e){ + try { + file = File.createTempFile("fakeFile", ".fake"); + } catch (IOException io) { + _log.error("Fallback fake advanced filesystem failed to create temporary file"); + } + } + return file; + } + + @Override + public File getFile(long userId, long fileEntryId, String version, + boolean incrementCounter) throws PortalException, SystemException { + File file = null; + try{ + file = super.getFile(userId, fileEntryId, version, incrementCounter); + } catch (Exception e){ + try { + file = File.createTempFile("fakeFile", ".fake"); + } catch (IOException io) { + _log.error("Fallback fake advanced filesystem failed to create temporary file"); + } + } + return file; + } + + @Override + public InputStream getFileAsStream(long userId, long fileEntryId, + String version, boolean incrementCounter, int increment) + throws PortalException, SystemException { + InputStream stream = null; + try{ + stream = super.getFileAsStream(userId, fileEntryId, version, incrementCounter, increment); + } catch (Exception e){ + try { + stream = new FileInputStream(File.createTempFile("fakeFile", ".fake")); + } catch (IOException io) { + _log.error("Fallback fake advanced filesystem failed to create temporary file"); + } + } + return stream; + } + + @Override + public InputStream getFileAsStream(long userId, long fileEntryId, + String version, boolean incrementCounter) throws PortalException, + SystemException { + InputStream stream = null; + try{ + stream = super.getFileAsStream(userId, fileEntryId, version, incrementCounter); + } catch (Exception e){ + try { + stream = new FileInputStream(File.createTempFile("fakeFile", ".fake")); + } catch (IOException io) { + _log.error("Fallback fake advanced filesystem failed to create temporary file"); + } + } + return stream; + } + + @Override + public InputStream getFileAsStream(long userId, long fileEntryId, + String version) throws PortalException, SystemException { + InputStream stream = null; + try{ + stream = super.getFileAsStream(userId, fileEntryId, version); + } catch (Exception e){ + try { + stream = new FileInputStream(File.createTempFile("fakeFile", ".fake")); + } catch (IOException io) { + _log.error("Fallback fake advanced filesystem failed to create temporary file"); + } + } + return stream; + } + + @Override + public InputStream getFileAsStream(long fileEntryId, String version, + boolean incrementCounter, int increment) throws PortalException, + SystemException { + InputStream stream = null; + try{ + stream = super.getFileAsStream(fileEntryId, version, incrementCounter, increment); + } catch (Exception e){ + try { + stream = new FileInputStream(File.createTempFile("fakeFile", ".fake")); + } catch (IOException io) { + _log.error("Fallback fake advanced filesystem failed to create temporary file"); + } + } + return stream; + } + + @Override + public InputStream getFileAsStream(long fileEntryId, String version, + boolean incrementCounter) throws PortalException, SystemException { + InputStream stream = null; + try{ + stream = super.getFileAsStream(fileEntryId, version, incrementCounter); + } catch (Exception e){ + try { + stream = new FileInputStream(File.createTempFile("fakeFile", ".fake")); + } catch (IOException io) { + _log.error("Fallback fake advanced filesystem failed to create temporary file"); + } + } + return stream; + } + + @Override + public InputStream getFileAsStream(long fileEntryId, String version) + throws PortalException, SystemException { + InputStream stream = null; + try{ + stream = super.getFileAsStream(fileEntryId, version); + } catch (Exception e){ + try { + stream = new FileInputStream(File.createTempFile("fakeFile", ".fake")); + } catch (IOException io) { + _log.error("Fallback fake advanced filesystem failed to create temporary file"); + } + } + return stream; + } + + public FakeDLFileEntryLocalServiceImpl( + DLFileEntryLocalService dlFileEntryLocalService) { + super(dlFileEntryLocalService); + } + + Log _log = LogFactoryUtil.getLog(this.getClass()); +} diff --git a/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/web.xml b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/web.xml new file mode 100644 index 00000000..1aa8cdb8 --- /dev/null +++ b/liferay-plugins-sdk-6.2/hooks/fake-advanced-filesystem-hook/docroot/WEB-INF/web.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file