mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix AR-1765 WebScripts clear authentication before commiting transaction
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6843 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -145,39 +145,9 @@ public abstract class WebScriptRuntime
|
|||||||
logger.debug("Format style: " + desc.getFormatStyle() + ", Default format: " + desc.getDefaultFormat());
|
logger.debug("Format style: " + desc.getFormatStyle() + ", Default format: " + desc.getDefaultFormat());
|
||||||
logger.debug("Invoking Web Script " + description.getId() + (user == null ? " (unauthenticated)" : " (authenticated as " + user + ") (format " + format + ") (" + locale + ")"));
|
logger.debug("Invoking Web Script " + description.getId() + (user == null ? " (unauthenticated)" : " (authenticated as " + user + ") (format " + format + ") (" + locale + ")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (description.getRequiredTransaction() == RequiredTransaction.none)
|
// execute script within required level of authentication
|
||||||
{
|
authenticatedExecute(scriptReq, scriptRes);
|
||||||
authenticatedExecute(scriptReq, scriptRes);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// encapsulate script within transaction
|
|
||||||
RetryingTransactionCallback<Object> work = new RetryingTransactionCallback<Object>()
|
|
||||||
{
|
|
||||||
public Object execute() throws Exception
|
|
||||||
{
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
logger.debug("Begin transaction: " + description.getRequiredTransaction());
|
|
||||||
|
|
||||||
authenticatedExecute(scriptReq, scriptRes);
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
logger.debug("End transaction: " + description.getRequiredTransaction());
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (description.getRequiredTransaction() == RequiredTransaction.required)
|
|
||||||
{
|
|
||||||
retryingTransactionHelper.doInTransaction(work);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
retryingTransactionHelper.doInTransaction(work, false, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -277,7 +247,7 @@ public abstract class WebScriptRuntime
|
|||||||
|
|
||||||
if (required == RequiredAuthentication.none)
|
if (required == RequiredAuthentication.none)
|
||||||
{
|
{
|
||||||
wrappedExecute(scriptReq, scriptRes);
|
transactionedExecute(scriptReq, scriptRes);
|
||||||
}
|
}
|
||||||
else if ((required == RequiredAuthentication.user || required == RequiredAuthentication.admin) && isGuest)
|
else if ((required == RequiredAuthentication.user || required == RequiredAuthentication.admin) && isGuest)
|
||||||
{
|
{
|
||||||
@@ -311,7 +281,7 @@ public abstract class WebScriptRuntime
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Execute Web Script
|
// Execute Web Script
|
||||||
wrappedExecute(scriptReq, scriptRes);
|
transactionedExecute(scriptReq, scriptRes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -330,6 +300,52 @@ public abstract class WebScriptRuntime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute script within required level of transaction
|
||||||
|
*
|
||||||
|
* @param scriptReq
|
||||||
|
* @param scriptRes
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
protected void transactionedExecute(final WebScriptRequest scriptReq, final WebScriptResponse scriptRes)
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
final WebScript script = scriptReq.getServiceMatch().getWebScript();
|
||||||
|
final WebScriptDescription description = script.getDescription();
|
||||||
|
if (description.getRequiredTransaction() == RequiredTransaction.none)
|
||||||
|
{
|
||||||
|
wrappedExecute(scriptReq, scriptRes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// encapsulate script within transaction
|
||||||
|
RetryingTransactionCallback<Object> work = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Exception
|
||||||
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Begin transaction: " + description.getRequiredTransaction());
|
||||||
|
|
||||||
|
wrappedExecute(scriptReq, scriptRes);
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("End transaction: " + description.getRequiredTransaction());
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (description.getRequiredTransaction() == RequiredTransaction.required)
|
||||||
|
{
|
||||||
|
retryingTransactionHelper.doInTransaction(work);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retryingTransactionHelper.doInTransaction(work, false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute Web Script with pre & post hooks
|
* Execute Web Script with pre & post hooks
|
||||||
|
Reference in New Issue
Block a user