mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-30 18:15:39 +00:00
36152: ALF-13904: Can we code round the malformed Lock-Token reported in OOo/LibreOffice in ALF-7916 36169: ALF-8755: After renaming content / space by Contributor via WebDAV new items are created 36174: Reversed revisions 35090 and 35107. Reinstating Kofax in service packs for now until universal build is ready. 36191: Fixed inconsistencies in the application of index control aspect and guessMimetype in ADMRemoteStore and AVMToADMRemoteStorePath since hidden aspect additions. Tested with large site migration. 36193: Pull out the Thread-local HttpClient creation from RemoteClient, and expose. Will go back into Surf at some point 36194: Convert to using the ThreadLocal HttpClient instances, and some extra steps to ensure we always tidy up after ourselves now the instance is shared 36196: ALF-13915: Inline edit is possible on someone else's working copy in Share - possible data loss with no warning - Fix by MF 36197: Chinese: First files translated into Chinese 36202: ALF-13483: Japanese: Incorrect date handle in a date Input filed - Reviewed by DWe 36203: ALF-11463: Corrected localized email template naming format - Fix by Pavel, reviewed by DWe 36204: Fixes: ALF-13777, adjusts the sort order so that the calendar entries are displayed in a consistent order 36223: Remove old module code from core * removed DOD module code (now found in separate RM archive) * removed proff of concept RM module (long since deprecated) * removed blog integration module (migrated into the core product many moons past) * updated build scripts, removing all DOD module related tasks and properties 36226: ALF-5285: Workflow: Setting default value to data type <default>0</default>, value is not retained. - Customer bug from 2008! Reviewed by Frederik 36228: ALF-12742: Fix Websphere classpath to allow OpenCMIS to work! - Changes researched by Dmitry - ALF-14023 logged for doc impact 36235: More for ALF-13723 SOLR does not include the same query unit tests as lucene - first half of embedded CMIS tests 36236: Fixes: ALF-13777. Fix tweaked for aesthetics. 36245: ALF-13244 SOLR Multi-threaded tracking is required for performance - simultaneous document transformations - multi-threaded tracking is now the default 36248: Fixed ALF-13705 "Could not load properties"/InvalidQNameException while trying to open/edit rule in Share 36255: ALF-13088: Upgrade to OpenCMIS 0.7.0 to solve Alfresco CMIS extension issues 36256: ALF-13088: Fix compilation error 36259: ALF-13933 Alfresco needs to be able to support LibreOffice for transformations << Developed on Windows 7. Might need more work on Linux to get LibreOffice to shut down, but should be okay with OpenOffice 3.2 which was used in the previous release. >> - Updated jodconverter to latest version jodconverter-core-3.0-SNAPSHOT-patched.jar 28/4/2012 which is newer than 3.0 beta-4 - Applied patch for http://code.google.com/p/jodconverter/issues/detail?id=103 to handle setting the env for LibreOffice 3.5 - Modified code to use partial GNU style options (not used for -env!) when using LibreOffice - Added OpenOfficeCommandLine to dynamically supply OpenOffice or LibreOffice command line args for OOoDirect - Tested to work with OpenOffice 3.4 and 3.2 on Windows 7 36263: Merged V4.0 to V4.0-BUG-FIX 36247: ALF-11027: temporarily remove import of maven.xml, since it makes ant calls fail from enterpriseprojects 36264: ALF-13933 Alfresco needs to be able to support LibreOffice for transformations - remove old jodconverter-core-3.0-beta-3.diff 36265: ALF-14025: Updated Surf libs to stop application context being added to non-checksum requested dependencies to allow relative paths to be requested. 36266: Merged V3.4-BUG-FIX to V4.0-BUG-FIX 36147: Removed nonsense comments from method information 36187: Merged DEV to V3.4-BUG-FIX 36121: ALF-234: There is no field restriction at the New Rule form in Share 'maxlength="1024"' parameter has been added to title and description fields in 'rule-edit.get.html.ftl' 36229: Merged DEV to V3.4-BUG-FIX 35115: ALF-13181:Stack Specific: Script error occurs when try to exute Task Done/Approve/Reject action on My Tasks (My Tasks WebScript) dashlet Dellay for 500 miliseconds was added to MyTasks.transitionTask() method. 36242: Fixed ALF-12287 "Share - metadataRefresh event removes version history" - The javascript component was listening to "metaDataRefresh" which made it refresh itself. However it also listened to dopcumentDetailsAvailable to enhance its dom (i.e. show itself). Meaning that if timing was bad and the "documentDetailsAvailable" was fired before the refresh had been performed it nwever showed itself. 36260: ALF-13936: Enabling IMAP can interfere with folder versioning 36262: ALF-13718: Reverting ORDER BY changes to child assoc query as they had more impact than expected and we turned out to be compensating for out of date SQL Server statistics 36269: Merged V3.4-BUG-FIX to V4.0-BUG-FIX 36268: ALF-14031: Merged PATCHES/V3.4.6 to V3.4-BUG-FIX 36176: ALF-13981: Fix registerReferenceCountingIndexReader() so that it works in a doWithFileLock() retry loop (whatever that means!) 36273: ALF-13933 Alfresco needs to be able to support LibreOffice for transformations - Return a dummy OpenOffice command even when there is no OpenOffice/LibreOffice installed or on the path. 36275: ALF-14029: Updating single-valued association (no List<NodeRef>) fixed. 36283: Translation updates to: DE, ES, FR, IT, JA, NL. Based on EN rev36165. 36284: ALF-13723 SOLR does not include the same query unit tests as lucene - InTree, InFolder, FTS, Access, DateFormatting, AspectJoin, FTSConnectives, LikeEscaping 36306: ALF-13672: Workflow Notification Emails are partially localized into other languages git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@36324 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
317 lines
11 KiB
Java
317 lines
11 KiB
Java
/*
|
|
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
|
*
|
|
* This file is part of Alfresco
|
|
*
|
|
* Alfresco is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Alfresco is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package org.alfresco.util;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.concurrent.locks.ReadWriteLock;
|
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|
|
|
import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
|
|
import org.apache.commons.httpclient.HttpClient;
|
|
import org.apache.commons.httpclient.HttpVersion;
|
|
import org.apache.commons.httpclient.SimpleHttpConnectionManager;
|
|
import org.apache.commons.httpclient.cookie.CookiePolicy;
|
|
import org.apache.commons.httpclient.params.DefaultHttpParamsFactory;
|
|
import org.apache.commons.httpclient.params.HttpClientParams;
|
|
import org.apache.commons.httpclient.params.HttpMethodParams;
|
|
import org.apache.commons.httpclient.params.HttpParams;
|
|
import org.apache.commons.httpclient.util.DateUtil;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.springframework.context.ApplicationContext;
|
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|
import org.springframework.extensions.webscripts.connector.RemoteClient;
|
|
|
|
/**
|
|
* Helper class to provide access to Thread Local instances of HttpClient.
|
|
* These instances will have been set up in a way that optimises the
|
|
* performance for one thread doing a fetch and then using the result.
|
|
* You must call releaseConnection() when you're done with the request,
|
|
* otherwise things will break for the next request in this thread!
|
|
*
|
|
* TODO Merge me back to Spring Surf, which is where this code has been
|
|
* pulled out from (was in {@link RemoteClient} but not available externally)
|
|
*/
|
|
public class HttpClientHelper
|
|
{
|
|
private static Log logger = LogFactory.getLog(HttpClientHelper.class);
|
|
|
|
// HTTP Client instance - per thread
|
|
private static ThreadLocal<HttpClient> httpClient = new ThreadLocal<HttpClient>()
|
|
{
|
|
@Override
|
|
protected HttpClient initialValue()
|
|
{
|
|
logger.debug("Creating HttpClient instance for thread: " + Thread.currentThread().getName());
|
|
return new HttpClient(new NonBlockingHttpParams());
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Returns an initialised HttpClient instance for the current thread, which
|
|
* will have been configured for optimal settings
|
|
*/
|
|
public static HttpClient getHttpClient()
|
|
{
|
|
return httpClient.get();
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
// Helper classes
|
|
|
|
/**
|
|
* An extension of the DefaultHttpParamsFactory that uses a RRW lock pattern rather than
|
|
* full synchronization around the parameter CRUD - to avoid locking on many reads.
|
|
*
|
|
* @author Kevin Roast
|
|
*/
|
|
public static class NonBlockingHttpParamsFactory extends DefaultHttpParamsFactory
|
|
{
|
|
private volatile HttpParams httpParams;
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.apache.commons.httpclient.params.DefaultHttpParamsFactory#getDefaultParams()
|
|
*/
|
|
@Override
|
|
public HttpParams getDefaultParams()
|
|
{
|
|
if (httpParams == null)
|
|
{
|
|
synchronized (this)
|
|
{
|
|
if (httpParams == null)
|
|
{
|
|
httpParams = createParams();
|
|
}
|
|
}
|
|
}
|
|
|
|
return httpParams;
|
|
}
|
|
|
|
/**
|
|
* NOTE: This is a copy of the code in {@link DefaultHttpParamsFactory}
|
|
* Unfortunately this is required because although the factory pattern allows the
|
|
* override of the default param creation, it does not allow the class of the actual
|
|
* HttpParam implementation to be changed.
|
|
*/
|
|
@Override
|
|
protected HttpParams createParams()
|
|
{
|
|
HttpClientParams params = new NonBlockingHttpParams(null);
|
|
|
|
params.setParameter(HttpMethodParams.USER_AGENT, "Spring Surf via Apache HttpClient/3.1");
|
|
params.setVersion(HttpVersion.HTTP_1_1);
|
|
params.setConnectionManagerClass(SimpleHttpConnectionManager.class);
|
|
params.setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
|
|
params.setHttpElementCharset("US-ASCII");
|
|
params.setContentCharset("ISO-8859-1");
|
|
params.setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler());
|
|
|
|
List<String> datePatterns = Arrays.asList(
|
|
new String[] {
|
|
DateUtil.PATTERN_RFC1123,
|
|
DateUtil.PATTERN_RFC1036,
|
|
DateUtil.PATTERN_ASCTIME,
|
|
"EEE, dd-MMM-yyyy HH:mm:ss z",
|
|
"EEE, dd-MMM-yyyy HH-mm-ss z",
|
|
"EEE, dd MMM yy HH:mm:ss z",
|
|
"EEE dd-MMM-yyyy HH:mm:ss z",
|
|
"EEE dd MMM yyyy HH:mm:ss z",
|
|
"EEE dd-MMM-yyyy HH-mm-ss z",
|
|
"EEE dd-MMM-yy HH:mm:ss z",
|
|
"EEE dd MMM yy HH:mm:ss z",
|
|
"EEE,dd-MMM-yy HH:mm:ss z",
|
|
"EEE,dd-MMM-yyyy HH:mm:ss z",
|
|
"EEE, dd-MM-yyyy HH:mm:ss z",
|
|
}
|
|
);
|
|
params.setParameter(HttpMethodParams.DATE_PATTERNS, datePatterns);
|
|
|
|
String agent = null;
|
|
try
|
|
{
|
|
agent = System.getProperty("httpclient.useragent");
|
|
}
|
|
catch (SecurityException ignore)
|
|
{
|
|
}
|
|
if (agent != null)
|
|
{
|
|
params.setParameter(HttpMethodParams.USER_AGENT, agent);
|
|
}
|
|
|
|
String preemptiveDefault = null;
|
|
try
|
|
{
|
|
preemptiveDefault = System.getProperty("httpclient.authentication.preemptive");
|
|
}
|
|
catch (SecurityException ignore)
|
|
{
|
|
}
|
|
if (preemptiveDefault != null)
|
|
{
|
|
preemptiveDefault = preemptiveDefault.trim().toLowerCase();
|
|
if (preemptiveDefault.equals("true"))
|
|
{
|
|
params.setParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, Boolean.TRUE);
|
|
}
|
|
else if (preemptiveDefault.equals("false"))
|
|
{
|
|
params.setParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, Boolean.FALSE);
|
|
}
|
|
}
|
|
|
|
String defaultCookiePolicy = null;
|
|
try
|
|
{
|
|
defaultCookiePolicy = System.getProperty("apache.commons.httpclient.cookiespec");
|
|
}
|
|
catch (SecurityException ignore)
|
|
{
|
|
}
|
|
if (defaultCookiePolicy != null)
|
|
{
|
|
if ("COMPATIBILITY".equalsIgnoreCase(defaultCookiePolicy))
|
|
{
|
|
params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
|
|
}
|
|
else if ("NETSCAPE_DRAFT".equalsIgnoreCase(defaultCookiePolicy))
|
|
{
|
|
params.setCookiePolicy(CookiePolicy.NETSCAPE);
|
|
}
|
|
else if ("RFC2109".equalsIgnoreCase(defaultCookiePolicy))
|
|
{
|
|
params.setCookiePolicy(CookiePolicy.RFC_2109);
|
|
}
|
|
}
|
|
|
|
return params;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @author Kevin Roast
|
|
*/
|
|
public static class NonBlockingHttpParams extends HttpClientParams
|
|
{
|
|
private HashMap<String, Object> parameters = new HashMap<String, Object>(8);
|
|
private ReadWriteLock paramLock = new ReentrantReadWriteLock();
|
|
|
|
public NonBlockingHttpParams()
|
|
{
|
|
super();
|
|
}
|
|
|
|
public NonBlockingHttpParams(HttpParams defaults)
|
|
{
|
|
super(defaults);
|
|
}
|
|
|
|
@Override
|
|
public Object getParameter(final String name)
|
|
{
|
|
// See if the parameter has been explicitly defined
|
|
Object param = null;
|
|
paramLock.readLock().lock();
|
|
try
|
|
{
|
|
param = this.parameters.get(name);
|
|
}
|
|
finally
|
|
{
|
|
paramLock.readLock().unlock();
|
|
}
|
|
if (param == null)
|
|
{
|
|
// If not, see if defaults are available
|
|
HttpParams defaults = getDefaults();
|
|
if (defaults != null)
|
|
{
|
|
// Return default parameter value
|
|
param = defaults.getParameter(name);
|
|
}
|
|
}
|
|
return param;
|
|
}
|
|
|
|
@Override
|
|
public void setParameter(final String name, final Object value)
|
|
{
|
|
paramLock.writeLock().lock();
|
|
try
|
|
{
|
|
this.parameters.put(name, value);
|
|
}
|
|
finally
|
|
{
|
|
paramLock.writeLock().unlock();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean isParameterSetLocally(final String name)
|
|
{
|
|
paramLock.readLock().lock();
|
|
try
|
|
{
|
|
return (this.parameters.get(name) != null);
|
|
}
|
|
finally
|
|
{
|
|
paramLock.readLock().unlock();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void clear()
|
|
{
|
|
paramLock.writeLock().lock();
|
|
try
|
|
{
|
|
this.parameters.clear();
|
|
}
|
|
finally
|
|
{
|
|
paramLock.writeLock().unlock();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public Object clone() throws CloneNotSupportedException
|
|
{
|
|
NonBlockingHttpParams clone = (NonBlockingHttpParams)super.clone();
|
|
paramLock.readLock().lock();
|
|
try
|
|
{
|
|
clone.parameters = (HashMap) this.parameters.clone();
|
|
}
|
|
finally
|
|
{
|
|
paramLock.readLock().unlock();
|
|
}
|
|
clone.setDefaults(getDefaults());
|
|
return clone;
|
|
}
|
|
}
|
|
}
|