mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merging /BRANCHES/DEV/BELARUS/HEAD-2010_03_09/ to HEAD:
19193: CMIS WS transaction atomicity problem was resolved. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19196 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -285,13 +285,14 @@
|
||||
</property>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref local="dmAbstractServiceTx" />
|
||||
<idref local="exceptionPointcutAdvisor" />
|
||||
<idref local="dmTransactionWrappingInterceptor" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="dmAbstractServiceTx" class="org.springframework.transaction.interceptor.TransactionInterceptor">
|
||||
<bean id="dmTransactionWrappingInterceptor" class="org.alfresco.repo.cmis.ws.DMTransactionWrappingInterceptor">
|
||||
<property name="transactionService" ref="TransactionService" />
|
||||
<property name="transactionManager">
|
||||
<ref bean="transactionManager" />
|
||||
</property>
|
||||
|
@@ -40,18 +40,21 @@ public class DMServicePortThrowsAdvice implements ThrowsAdvice
|
||||
{
|
||||
LOGGER.error(e.toString(), e);
|
||||
}
|
||||
|
||||
throw ExceptionUtil.createCmisException(("Access denied. Message: " + e.toString()), e);
|
||||
}
|
||||
|
||||
public void afterThrowing(java.lang.RuntimeException e) throws CmisException
|
||||
{
|
||||
Throwable result = e;
|
||||
if (null != e.getCause())
|
||||
{
|
||||
result = e.getCause();
|
||||
}
|
||||
if (LOGGER.isErrorEnabled())
|
||||
{
|
||||
LOGGER.error(e.toString(), e);
|
||||
LOGGER.error(result.toString(), result);
|
||||
}
|
||||
|
||||
throw ExceptionUtil.createCmisException(("Runtime error. Message: " + e.toString()), e);
|
||||
throw (result instanceof CmisException) ? ((CmisException) result) : (ExceptionUtil.createCmisException(("Runtime error. Message: " + result.toString()), result));
|
||||
}
|
||||
|
||||
public void afterThrowing(java.lang.Exception e) throws CmisException
|
||||
@@ -60,7 +63,6 @@ public class DMServicePortThrowsAdvice implements ThrowsAdvice
|
||||
{
|
||||
LOGGER.error(e.toString(), e);
|
||||
}
|
||||
|
||||
if (!(e instanceof CmisException))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(("Some error occured during last service invokation. Message: " + e.toString()), e);
|
||||
|
89
source/java/org/alfresco/repo/cmis/ws/DMTransactionWrappingInterceptor.java
Executable file
89
source/java/org/alfresco/repo/cmis/ws/DMTransactionWrappingInterceptor.java
Executable file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.repo.cmis.ws;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import org.springframework.transaction.interceptor.TransactionAttribute;
|
||||
|
||||
/**
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public class DMTransactionWrappingInterceptor extends TransactionAspectSupport implements MethodInterceptor
|
||||
{
|
||||
private TransactionService transactionService;
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
public Object invoke(final MethodInvocation target) throws Throwable
|
||||
{
|
||||
if ((null != target) && (null != target.getThis()) && (null != target.getMethod()))
|
||||
{
|
||||
final Method method = target.getMethod();
|
||||
final TransactionAttribute transactionAttribute = getTransactionAttributeSource().getTransactionAttribute(method, target.getThis().getClass());
|
||||
if (null != transactionAttribute)
|
||||
{
|
||||
return AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
return transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object execute() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
return method.invoke(target.getThis(), target.getArguments());
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
if (null != e.getTargetException())
|
||||
{
|
||||
throw e.getTargetException();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, transactionAttribute.isReadOnly(), (TransactionAttribute.PROPAGATION_REQUIRES_NEW == transactionAttribute.getPropagationBehavior()));
|
||||
}
|
||||
}, AuthenticationUtil.getFullyAuthenticatedUser());
|
||||
}
|
||||
else
|
||||
{
|
||||
return method.invoke(target.getThis(), target.getArguments());
|
||||
}
|
||||
}
|
||||
throw new AlfrescoRuntimeException("Invalid undefined MethodInvocation instance");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user