diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml index 52e1eab896..ba60e10c57 100644 --- a/config/alfresco/core-services-context.xml +++ b/config/alfresco/core-services-context.xml @@ -86,8 +86,6 @@ - - @@ -130,9 +128,6 @@ - - - diff --git a/source/java/org/alfresco/repo/security/authentication/AuthenticationUtil.java b/source/java/org/alfresco/repo/security/authentication/AuthenticationUtil.java index d909195a8e..cd0c67cb42 100644 --- a/source/java/org/alfresco/repo/security/authentication/AuthenticationUtil.java +++ b/source/java/org/alfresco/repo/security/authentication/AuthenticationUtil.java @@ -38,10 +38,13 @@ import net.sf.acegisecurity.providers.dao.User; import org.alfresco.repo.tenant.TenantService; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.util.EqualsHelper; +import org.alfresco.util.log.NDC; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.NDC; +/** + * Utility helper methods to change the authenticated context for threads. + */ public abstract class AuthenticationUtil { static Log s_logger = LogFactory.getLog(AuthenticationUtil.class); @@ -59,7 +62,7 @@ public abstract class AuthenticationUtil public static final String SYSTEM_USER_NAME = "System"; private static boolean mtEnabled = false; - + public static void setMtEnabled(boolean mtEnabled) { if (!AuthenticationUtil.mtEnabled) @@ -523,23 +526,23 @@ public abstract class AuthenticationUtil public static void logNDC(String userName) { - NDC.remove(); - - if (isMtEnabled()) + NDC.remove(); + + if (isMtEnabled()) { - int idx = userName.indexOf(TenantService.SEPARATOR); - if ((idx != -1) && (idx < (userName.length() - 1))) + int idx = userName.indexOf(TenantService.SEPARATOR); + if ((idx != -1) && (idx < (userName.length() - 1))) { - NDC.push("Tenant:" + userName.substring(idx + 1) + " User:" + userName.substring(0, idx)); + NDC.push("Tenant:" + userName.substring(idx + 1) + " User:" + userName.substring(0, idx)); } else { - NDC.push("User:" + userName); + NDC.push("User:" + userName); } } - else + else { - NDC.push("User:" + userName); + NDC.push("User:" + userName); } } } diff --git a/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java b/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java index 4b01c47b8f..adc6c6b6f7 100644 --- a/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java +++ b/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java @@ -48,6 +48,7 @@ import org.hibernate.StaleStateException; import org.hibernate.cache.CacheException; import org.hibernate.exception.ConstraintViolationException; import org.hibernate.exception.LockAcquisitionException; +import org.hibernate.exception.SQLGrammarException; import org.springframework.aop.MethodBeforeAdvice; import org.springframework.aop.framework.ProxyFactory; import org.springframework.dao.ConcurrencyFailureException; @@ -101,7 +102,8 @@ public class RetryingTransactionHelper StaleStateException.class, ObjectNotFoundException.class, CacheException.class, // Usually a cache replication issue - RemoteCacheException.class // A cache replication issue + RemoteCacheException.class, // A cache replication issue + SQLGrammarException.class // Actually specific to MS SQL Server 2005 - we check for this }; } @@ -456,15 +458,13 @@ public class RetryingTransactionHelper public static Throwable extractRetryCause(Throwable cause) { Throwable retryCause = ExceptionStackUtil.getCause(cause, RETRY_EXCEPTIONS); - if (retryCause == null) + if (retryCause == null || retryCause instanceof SQLGrammarException + && ((SQLGrammarException) retryCause).getErrorCode() != 3960) { return null; } - else - { - // A simple match - return retryCause; - } + // A simple match + return retryCause; } /** diff --git a/source/java/org/alfresco/util/schemadump/Main.java b/source/java/org/alfresco/util/schemadump/Main.java index 8af7f47848..2a263c06ea 100644 --- a/source/java/org/alfresco/util/schemadump/Main.java +++ b/source/java/org/alfresco/util/schemadump/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2008 Alfresco Software Limited. + * Copyright (C) 2005-2009 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -80,6 +80,8 @@ public class Main /** * Creates a new instance of this tool.. * + * @param contextPath + * path to the context xml file * @throws SQLException * the SQL exception * @throws IOException @@ -94,12 +96,12 @@ public class Main * the no such field exception */ @SuppressWarnings("unchecked") - public Main() throws SQLException, IOException, InstantiationException, IllegalAccessException, + public Main(final String contextPath) throws SQLException, IOException, InstantiationException, IllegalAccessException, ClassNotFoundException, NoSuchFieldException { final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] { - "classpath:/org/alfresco/extension/dump-context.xml" + "file:" + contextPath }); final DataSource datasource = (DataSource) context.getBean("dataSource"); this.con = datasource.getConnection(); @@ -142,7 +144,13 @@ public class Main */ public static void main(final String[] args) throws Exception { - final NamedElementCollection result = new Main().execute(); + if (args.length != 2) + { + System.out.println("Usage:"); + System.out.println("java " + Main.class.getName() + " "); + System.exit(1); + } + final NamedElementCollection result = new Main(args[0]).execute(); // Set up a SAX TransformerHandler for outputting XML final SAXTransformerFactory stf = (SAXTransformerFactory) TransformerFactory.newInstance(); @@ -157,7 +165,7 @@ public class Main // It was worth a try } t.setOutputProperty(OutputKeys.INDENT, "yes"); - xmlOut.setResult(new StreamResult(args[0])); + xmlOut.setResult(new StreamResult(args[1])); xmlOut.startDocument(); result.output(xmlOut);