mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V2.2 to HEAD
10931: Merged V2.1 to V2.2 9931: Fix for https://issues.alfresco.com/jira/browse/ETWOONE-295 10094: Further fix for ETWOONE-241: SAXException - XML parser apparently is not thread safe 10101: Resolve ACT 1282: wcm workflow falling over on Oracle while hitting in clause limit of 1000 expressions. 10188: https://issues.alfresco.com/jira/browse/ETWOONE-74 (Part 1) 10447: ETWOONE-328: performance improvement added to rule trigger code 10455: Fix for ETWOONE-306. 10292: Fix for ETWOONE-92: If two users update the same contents at the same time, you get InvalidNodeRefException 10293: Fix for ETWOONE-116: Send email action does not handle invalid email address 10294: Fix for ETWOONE-164: when a powerpoint 2007 pptx is stored in alfresco ... 10341: Action Evaluator request level cache git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10934 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -22,20 +22,23 @@
|
||||
* http://www.alfresco.com/legal/licensing" */
|
||||
package org.alfresco.web.forms;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.remote.AVMRemoteInputStream;
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
||||
import org.alfresco.service.cmr.remote.AVMRemote;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.*;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.SAXException;
|
||||
import javax.xml.parsers.*;
|
||||
import java.io.*;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Common implementation of functions called in the context of FormDataRenderers.
|
||||
@@ -43,14 +46,15 @@ import java.util.HashMap;
|
||||
* of both the alfresco webapp and the virtualization server.
|
||||
*
|
||||
* @author Ariel Backenroth
|
||||
* @author Arseny Kovalchuk (Fix of the bug reported in https://issues.alfresco.com/jira/browse/ETWOONE-241)
|
||||
*/
|
||||
public class FormDataFunctions
|
||||
{
|
||||
private static final Log LOGGER = LogFactory.getLog(FormDataFunctions.class);
|
||||
|
||||
private static DocumentBuilder documentBuilder;
|
||||
|
||||
private final AVMRemote avmRemote;
|
||||
|
||||
private ThreadLocal<DocumentBuilderFactory> dbf = new ThreadLocal<DocumentBuilderFactory>();
|
||||
|
||||
public FormDataFunctions(final AVMRemote avmRemote)
|
||||
{
|
||||
@@ -70,7 +74,7 @@ public class FormDataFunctions
|
||||
final InputStream istream = this.avmRemote.getFileInputStream(-1, avmPath);
|
||||
try
|
||||
{
|
||||
return XMLUtil.parse(istream);
|
||||
return parseXML(istream);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -123,7 +127,8 @@ public class FormDataFunctions
|
||||
final InputStream istream = this.avmRemote.getFileInputStream(-1, avmPath + '/' + entryName);
|
||||
try
|
||||
{
|
||||
result.put(entryName, XMLUtil.parse(istream));
|
||||
// result.put(entryName, XMLUtil.parse(istream));
|
||||
result.put(entryName, parseXML(istream));
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -133,4 +138,33 @@ public class FormDataFunctions
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* We need an internal method for XML parsing with ThreadLocal DocumentBuilderFactory
|
||||
* to avoid a multithread access to the parser in XMLUtils.
|
||||
* Fix of the bug reported in https://issues.alfresco.com/jira/browse/ETWOONE-241 reported.
|
||||
*/
|
||||
private Document parseXML(InputStream is) throws IOException, SAXException
|
||||
{
|
||||
Document result = null;
|
||||
try
|
||||
{
|
||||
DocumentBuilderFactory localDbf = dbf.get();
|
||||
if (localDbf == null)
|
||||
{
|
||||
localDbf = DocumentBuilderFactory.newInstance();
|
||||
}
|
||||
localDbf.setNamespaceAware(true);
|
||||
localDbf.setValidating(false);
|
||||
dbf.set(localDbf);
|
||||
DocumentBuilder builder = localDbf.newDocumentBuilder();
|
||||
result = builder.parse(is);
|
||||
}
|
||||
catch (ParserConfigurationException pce)
|
||||
{
|
||||
LOGGER.error(pce);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user