mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
57387: If a "quick" file is in a jar then stream it to a temp file and return the File reference, BDE-195 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61814 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -21,6 +21,7 @@ package org.alfresco.repo.content.transform;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
@@ -127,11 +128,30 @@ public abstract class AbstractContentTransformerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public static File loadNamedQuickTestFile(String quickname) throws IOException
|
public static File loadNamedQuickTestFile(String quickname) throws IOException
|
||||||
{
|
{
|
||||||
URL url = AbstractContentTransformerTest.class.getClassLoader().getResource("quick/" + quickname);
|
String quickNameAndPath = "quick/" + quickname;
|
||||||
|
URL url = AbstractContentTransformerTest.class.getClassLoader().getResource(quickNameAndPath);
|
||||||
if (url == null)
|
if (url == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (ResourceUtils.isJarURL(url))
|
||||||
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Using a temp file for quick resource that's in a jar." + quickNameAndPath);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
InputStream is = AbstractContentTransformerTest.class.getClassLoader().getResourceAsStream(quickNameAndPath);
|
||||||
|
File tempFile = TempFileProvider.createTempFile(is, quickname, ".tmp");
|
||||||
|
return tempFile;
|
||||||
|
}
|
||||||
|
catch (Exception error)
|
||||||
|
{
|
||||||
|
logger.equals("Failed to load a quick file from a jar. "+error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
return ResourceUtils.getFile(url);
|
return ResourceUtils.getFile(url);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user