mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Partial fix for AWC-999: Content upload guesses character encoding and offers the user the chance to change it.
TODO: Fix the "Modify Content Properties" to include the encoding as a changeable option. Modified other entry points of content into the system. All calls to ContentWriter.setEncoding("UTF-8") need some serious examination. It is no longer necessary to assume anything about the encoding. The worst case scenario is that we guess the encoding from the stream without giving the user the chance to change it. This works for most non-interactive scenarios like CIFS, WebDAV and FTP, now. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6113 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -22,7 +22,9 @@
|
||||
* http://www.alfresco.com/legal/licensing" */
|
||||
package org.alfresco.web.bean.repository;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -37,6 +39,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.configuration.ConfigurableService;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.content.encoding.ContentCharsetFinder;
|
||||
import org.alfresco.repo.content.metadata.MetadataExtracter;
|
||||
import org.alfresco.repo.content.metadata.MetadataExtracterRegistry;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
@@ -507,6 +510,21 @@ public final class Repository
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the characterset from the stream
|
||||
*
|
||||
* @param context the Faces Context
|
||||
* @param is the stream of characters or data
|
||||
* @param mimetype the stream's mimetype, or <tt>null</tt> if unknown
|
||||
* @return Returns the guessed characterset and never <tt>null</tt>
|
||||
*/
|
||||
public static String guessEncoding(FacesContext context, InputStream is, String mimetype)
|
||||
{
|
||||
ContentCharsetFinder charsetFinder = getServiceRegistry(context).getMimetypeService().getContentCharsetFinder();
|
||||
Charset charset = charsetFinder.getCharset(is, mimetype);
|
||||
return charset.name();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query a list of Person type nodes from the repo
|
||||
|
Reference in New Issue
Block a user