mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merge V1.4 to HEAD
- Ignored Enterprise-specific changes svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3701 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3703 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3704 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3705 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3707 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3876 . svn revert root\projects\web-client\source\web\jsp\admin\admin-console.jsp git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3879 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -109,7 +109,7 @@ public abstract class AbstractContentStore implements ContentStore
|
||||
// extract the relative part of the URL
|
||||
String path = contentUrl.substring(index);
|
||||
// more extensive checks can be added in, but it seems overkill
|
||||
if (path.length() < 10)
|
||||
if (path.length() < 8)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(
|
||||
"The content URL is invalid: \n" +
|
||||
|
@@ -56,6 +56,7 @@ public class MimetypeMap implements MimetypeService
|
||||
public static final String MIMETYPE_IMAGE_GIF = "image/gif";
|
||||
public static final String MIMETYPE_IMAGE_JPEG = "image/jpeg";
|
||||
public static final String MIMETYPE_IMAGE_RGB = "image/x-rgb";
|
||||
public static final String MIMETYPE_IMAGE_SVG = "image/svg";
|
||||
public static final String MIMETYPE_JAVASCRIPT = "application/x-javascript";
|
||||
public static final String MIMETYPE_ZIP = "application/zip";
|
||||
// Open Document
|
||||
|
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.alfresco.repo.content.cleanup;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
@@ -27,10 +28,12 @@ import org.alfresco.repo.content.ContentStore;
|
||||
import org.alfresco.repo.node.db.NodeDaoService;
|
||||
import org.alfresco.repo.transaction.TransactionUtil;
|
||||
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -116,26 +119,10 @@ public class ContentStoreCleaner
|
||||
*/
|
||||
private void checkProperties()
|
||||
{
|
||||
if (dictionaryService == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Property 'dictionaryService' not set");
|
||||
}
|
||||
if (nodeDaoService == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Property 'nodeDaoService' not set");
|
||||
}
|
||||
if (transactionService == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Property 'transactionService' not set");
|
||||
}
|
||||
if (stores == null || stores.size() == 0)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Property 'stores' not set");
|
||||
}
|
||||
if (listeners == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Property 'listeners' not set");
|
||||
}
|
||||
PropertyCheck.mandatory(this, "dictionaryService", dictionaryService);
|
||||
PropertyCheck.mandatory(this, "nodeDaoService", nodeDaoService);
|
||||
PropertyCheck.mandatory(this, "transactionService", transactionService);
|
||||
PropertyCheck.mandatory(this, "listeners", listeners);
|
||||
|
||||
// check the protect days
|
||||
if (protectDays < 0)
|
||||
@@ -152,26 +139,27 @@ public class ContentStoreCleaner
|
||||
|
||||
private Set<String> getValidUrls()
|
||||
{
|
||||
final DataTypeDefinition contentDataType = dictionaryService.getDataType(DataTypeDefinition.CONTENT);
|
||||
// wrap to make the request in a transaction
|
||||
TransactionWork<List<String>> getUrlsWork = new TransactionWork<List<String>>()
|
||||
TransactionWork<List<Serializable>> getUrlsWork = new TransactionWork<List<Serializable>>()
|
||||
{
|
||||
public List<String> doWork() throws Exception
|
||||
public List<Serializable> doWork() throws Exception
|
||||
{
|
||||
return nodeDaoService.getContentDataStrings();
|
||||
return nodeDaoService.getPropertyValuesByActualType(contentDataType);
|
||||
};
|
||||
};
|
||||
// execute in READ-ONLY txn
|
||||
List<String> contentDataStrings = TransactionUtil.executeInUserTransaction(
|
||||
List<Serializable> values = TransactionUtil.executeInUserTransaction(
|
||||
transactionService,
|
||||
getUrlsWork,
|
||||
true);
|
||||
|
||||
// get all valid URLs
|
||||
Set<String> validUrls = new HashSet<String>(contentDataStrings.size());
|
||||
Set<String> validUrls = new HashSet<String>(values.size());
|
||||
// convert the strings to objects and extract the URL
|
||||
for (String contentDataString : contentDataStrings)
|
||||
for (Serializable value : values)
|
||||
{
|
||||
ContentData contentData = ContentData.createContentProperty(contentDataString);
|
||||
ContentData contentData = (ContentData) value;
|
||||
if (contentData.getContentUrl() != null)
|
||||
{
|
||||
// a URL was present
|
||||
|
@@ -19,7 +19,10 @@ package org.alfresco.repo.content.transform;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.content.filestore.FileContentReader;
|
||||
@@ -120,45 +123,71 @@ public abstract class AbstractContentTransformerTest extends BaseSpringTest
|
||||
* case where optimizations are being done around the selection of the most
|
||||
* appropriate transformer, different transformers could be used during the iteration
|
||||
* process.
|
||||
* <p>
|
||||
* Results for the transformations are dumped to a temporary file named
|
||||
* <b>AbstractContentTransformerTest-results-1234.txt</b>.
|
||||
*/
|
||||
public void testAllConversions() throws Exception
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(2048);
|
||||
sb.append("Mimetype Conversion Tests \n")
|
||||
.append("========================= \n")
|
||||
.append(" Date: ").append(new Date()).append("\n")
|
||||
.append("\n");
|
||||
|
||||
// get all mimetypes
|
||||
List<String> mimetypes = mimetypeMap.getMimetypes();
|
||||
Set<String> mimetypes = new TreeSet<String>(mimetypeMap.getMimetypes());
|
||||
for (String sourceMimetype : mimetypes)
|
||||
{
|
||||
// attempt to get a source file for each mimetype
|
||||
String sourceExtension = mimetypeMap.getExtension(sourceMimetype);
|
||||
File sourceFile = AbstractContentTransformerTest.loadQuickTestFile(sourceExtension);
|
||||
if (sourceFile == null)
|
||||
{
|
||||
continue; // no test file available for that extension
|
||||
}
|
||||
|
||||
sb.append(" Source Extension: ").append(sourceExtension).append("\n");
|
||||
|
||||
// attempt to convert to every other mimetype
|
||||
for (String targetMimetype : mimetypes)
|
||||
{
|
||||
ContentWriter targetWriter = null;
|
||||
// construct a reader onto the source file
|
||||
String targetExtension = mimetypeMap.getExtension(targetMimetype);
|
||||
|
||||
// must we test the transformation?
|
||||
ContentTransformer transformer = getTransformer(sourceMimetype, targetMimetype);
|
||||
if (transformer == null || transformer.getReliability(sourceMimetype, targetMimetype) <= 0.0)
|
||||
{
|
||||
// no transformer
|
||||
continue;
|
||||
}
|
||||
|
||||
// dump
|
||||
sb.append(" Target Extension: ").append(targetExtension);
|
||||
sb.append(" <").append(transformer.getClass().getSimpleName()).append(">");
|
||||
|
||||
// is there a test file for this conversion?
|
||||
File sourceFile = AbstractContentTransformerTest.loadQuickTestFile(sourceExtension);
|
||||
if (sourceFile == null)
|
||||
{
|
||||
sb.append(" <no source test file>\n");
|
||||
continue; // no test file available for that extension
|
||||
}
|
||||
ContentReader sourceReader = new FileContentReader(sourceFile);
|
||||
|
||||
// perform the transformation several times so that we get a good idea of performance
|
||||
int count = 0;
|
||||
long before = System.currentTimeMillis();
|
||||
Set<String> transformerClasses = new HashSet<String>(2);
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
// must we test the transformation?
|
||||
ContentTransformer transformer = getTransformer(sourceMimetype, targetMimetype);
|
||||
if (transformer == null)
|
||||
// get the transformer repeatedly as it might be different each time around
|
||||
transformer = getTransformer(sourceMimetype, targetMimetype);
|
||||
// must we report on this class?
|
||||
if (!transformerClasses.contains(transformer.getClass().getName()))
|
||||
{
|
||||
break; // test is not required
|
||||
transformerClasses.add(transformer.getClass().getName());
|
||||
sb.append(" <").append(transformer.getClass().getSimpleName()).append(">");
|
||||
}
|
||||
else if (transformer.getReliability(sourceMimetype, targetMimetype) <= 0.0)
|
||||
{
|
||||
break; // not reliable for this transformation
|
||||
}
|
||||
|
||||
|
||||
// make a writer for the target file
|
||||
String targetExtension = mimetypeMap.getExtension(targetMimetype);
|
||||
File targetFile = TempFileProvider.createTempFile(
|
||||
getClass().getSimpleName() + "_" + getName() + "_" + sourceExtension + "_",
|
||||
"." + targetExtension);
|
||||
@@ -198,6 +227,11 @@ public abstract class AbstractContentTransformerTest extends BaseSpringTest
|
||||
// increment count
|
||||
count++;
|
||||
}
|
||||
long after = System.currentTimeMillis();
|
||||
double average = (double) (after - before) / (double) count;
|
||||
|
||||
// dump
|
||||
sb.append(String.format(" average %10.0f ms", average)).append("\n");
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
@@ -209,5 +243,11 @@ public abstract class AbstractContentTransformerTest extends BaseSpringTest
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dump to file
|
||||
File outputFile = TempFileProvider.createTempFile("AbstractContentTransformerTest-results-", ".txt");
|
||||
ContentWriter outputWriter = new FileContentWriter(outputFile);
|
||||
outputWriter.setEncoding("UTF8");
|
||||
outputWriter.putContent(sb.toString());
|
||||
}
|
||||
}
|
||||
|
@@ -16,9 +16,16 @@
|
||||
*/
|
||||
package org.alfresco.repo.content.transform;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.sf.jooreports.openoffice.connection.OpenOfficeConnection;
|
||||
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.content.filestore.FileContentReader;
|
||||
import org.alfresco.repo.content.filestore.FileContentWriter;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.content.transform.OpenOfficeContentTransformer
|
||||
@@ -75,4 +82,24 @@ public class OpenOfficeContentTransformerTest extends AbstractContentTransformer
|
||||
reliability = transformer.getReliability(MimetypeMap.MIMETYPE_WORD, MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
assertEquals("Mimetype should be supported", 1.0, reliability);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test what is up with HTML to PDF
|
||||
*/
|
||||
public void testHtmlToPdf() throws Exception
|
||||
{
|
||||
if (!transformer.isConnected())
|
||||
{
|
||||
// no connection
|
||||
return;
|
||||
}
|
||||
File htmlSourceFile = loadQuickTestFile("html");
|
||||
File pdfTargetFile = TempFileProvider.createTempFile(getName() + "-target-", ".pdf");
|
||||
ContentReader reader = new FileContentReader(htmlSourceFile);
|
||||
reader.setMimetype(MimetypeMap.MIMETYPE_HTML);
|
||||
ContentWriter writer = new FileContentWriter(pdfTargetFile);
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_PDF);
|
||||
|
||||
transformer.transform(reader, writer);
|
||||
}
|
||||
}
|
||||
|
@@ -145,6 +145,10 @@ public abstract class AbstractImageMagickContentTransformer extends AbstractCont
|
||||
{
|
||||
return false; // rgb extension doesn't work
|
||||
}
|
||||
else if (mimetype.equals(MimetypeMap.MIMETYPE_IMAGE_SVG))
|
||||
{
|
||||
return false; // svg extension doesn't work
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user