mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-07 18:25:23 +00:00
ContentReader and ContentWriter conversions to String now use toString()
- Previously, the ContentReader to String conversion was reading the binary data git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16492 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
6671acb4cd
commit
95b648f165
@ -49,6 +49,7 @@ import org.alfresco.service.cmr.repository.AssociationRef;
|
|||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ContentData;
|
import org.alfresco.service.cmr.repository.ContentData;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
import org.alfresco.service.cmr.repository.EntityRef;
|
import org.alfresco.service.cmr.repository.EntityRef;
|
||||||
import org.alfresco.service.cmr.repository.MLText;
|
import org.alfresco.service.cmr.repository.MLText;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@ -859,31 +860,22 @@ public class DefaultTypeConverter
|
|||||||
{
|
{
|
||||||
public String convert(ContentReader source)
|
public String convert(ContentReader source)
|
||||||
{
|
{
|
||||||
String encoding = source.getEncoding();
|
// Getting the string from the ContentReader binary is meaningless
|
||||||
if (encoding == null || !encoding.equalsIgnoreCase("UTF-8"))
|
return source.toString();
|
||||||
{
|
|
||||||
throw new TypeConversionException("Cannot convert non UTF-8 streams to String.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Throw error on size limit
|
|
||||||
|
|
||||||
return source.getContentString();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
INSTANCE.addDynamicTwoStageConverter(ContentReader.class, String.class, Date.class);
|
//
|
||||||
|
// Content Writer
|
||||||
|
//
|
||||||
|
|
||||||
INSTANCE.addDynamicTwoStageConverter(ContentReader.class, String.class, Double.class);
|
INSTANCE.addConverter(ContentWriter.class, String.class, new TypeConverter.Converter<ContentWriter, String>()
|
||||||
|
{
|
||||||
INSTANCE.addDynamicTwoStageConverter(ContentReader.class, String.class, Long.class);
|
public String convert(ContentWriter source)
|
||||||
|
{
|
||||||
INSTANCE.addDynamicTwoStageConverter(ContentReader.class, String.class, Boolean.class);
|
return source.toString();
|
||||||
|
}
|
||||||
INSTANCE.addDynamicTwoStageConverter(ContentReader.class, String.class, QName.class);
|
});
|
||||||
|
|
||||||
INSTANCE.addDynamicTwoStageConverter(ContentReader.class, String.class, Path.class);
|
|
||||||
|
|
||||||
INSTANCE.addDynamicTwoStageConverter(ContentReader.class, String.class, NodeRef.class);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Input Stream
|
// Input Stream
|
||||||
|
Loading…
x
Reference in New Issue
Block a user