Merged V3.0 to HEAD

11535: Fix ETHREEOH-519, ETHREEOH-23, ETHREEOH-24, ETHREEOH-58, ETHREEOH-449, ETHREEOH-30, ETHREEOH-19, ETHREEOH-561, ETHREEOH-537, ETHREEOH-567, ETHREEOH-568, ETHREEOH-113, ETHREEOH-130, ETHREEOH-115, ETHREEOH-566, ETHREEOH-572, ETHREEOH-82.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12450 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2008-12-17 14:28:44 +00:00
parent 9cfb7526d7
commit a3ba346406
3 changed files with 63 additions and 39 deletions

View File

@@ -29,6 +29,8 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.transaction.Status;
import javax.transaction.UserTransaction;
import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.model.Repository; import org.alfresco.repo.model.Repository;
@@ -147,7 +149,7 @@ public class RepositoryContainer extends AbstractRuntimeContainer implements Ten
*/ */
public ServerModel getDescription() public ServerModel getDescription()
{ {
return new RepositoryServerModel(descriptorService.getCurrentRepositoryDescriptor()); return new RepositoryServerModel(descriptorService.getCurrentRepositoryDescriptor(), descriptorService.getServerDescriptor());
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -300,14 +302,54 @@ public class RepositoryContainer extends AbstractRuntimeContainer implements Ten
RetryingTransactionCallback<Object> work = new RetryingTransactionCallback<Object>() RetryingTransactionCallback<Object> work = new RetryingTransactionCallback<Object>()
{ {
public Object execute() throws Exception public Object execute() throws Exception
{
try
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Begin transaction: " + description.getRequiredTransaction()); logger.debug("Begin retry transaction block: " + description.getRequiredTransaction());
script.execute(scriptReq, scriptRes); script.execute(scriptReq, scriptRes);
}
catch(Exception e)
{
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("End transaction: " + description.getRequiredTransaction()); {
logger.debug("Transaction exception: " + description.getRequiredTransaction() + ": " + e.getMessage());
// Note: user transaction shouldn't be null, but just in case inside this exception handler
UserTransaction userTrx = RetryingTransactionHelper.getActiveUserTransaction();
if (userTrx != null)
{
logger.debug("Transaction status: " + userTrx.getStatus());
}
}
UserTransaction userTrx = RetryingTransactionHelper.getActiveUserTransaction();
if (userTrx != null)
{
if (userTrx.getStatus() != Status.STATUS_MARKED_ROLLBACK)
{
if (logger.isDebugEnabled())
logger.debug("Marking web script transaction for rollback");
try
{
userTrx.setRollbackOnly();
}
catch(Throwable re)
{
if (logger.isDebugEnabled())
logger.debug("Caught and ignoring exception during marking for rollback: " + re.getMessage());
}
}
}
// re-throw original exception for retry
throw e;
}
finally
{
if (logger.isDebugEnabled())
logger.debug("End retry transaction block: " + description.getRequiredTransaction());
}
return null; return null;
} }

View File

@@ -35,6 +35,7 @@ import org.alfresco.web.scripts.ServerModel;
*/ */
public class RepositoryServerModel implements ServerModel public class RepositoryServerModel implements ServerModel
{ {
private Descriptor currentDescriptor;
private Descriptor serverDescriptor; private Descriptor serverDescriptor;
/** /**
@@ -42,8 +43,9 @@ public class RepositoryServerModel implements ServerModel
* *
* @param serverDescriptor * @param serverDescriptor
*/ */
/*package*/ RepositoryServerModel(Descriptor serverDescriptor) /*package*/ RepositoryServerModel(Descriptor currentDescriptor, Descriptor serverDescriptor)
{ {
this.currentDescriptor = currentDescriptor;
this.serverDescriptor = serverDescriptor; this.serverDescriptor = serverDescriptor;
} }
@@ -60,7 +62,7 @@ public class RepositoryServerModel implements ServerModel
*/ */
public String getId() public String getId()
{ {
return serverDescriptor.getId(); return currentDescriptor.getId();
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -68,7 +70,7 @@ public class RepositoryServerModel implements ServerModel
*/ */
public String getName() public String getName()
{ {
return serverDescriptor.getName(); return currentDescriptor.getName();
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -76,7 +78,7 @@ public class RepositoryServerModel implements ServerModel
*/ */
public String getVersionMajor() public String getVersionMajor()
{ {
return serverDescriptor.getVersionMajor(); return currentDescriptor.getVersionMajor();
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -84,7 +86,7 @@ public class RepositoryServerModel implements ServerModel
*/ */
public String getVersionMinor() public String getVersionMinor()
{ {
return serverDescriptor.getVersionMinor(); return currentDescriptor.getVersionMinor();
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -92,7 +94,7 @@ public class RepositoryServerModel implements ServerModel
*/ */
public String getVersionRevision() public String getVersionRevision()
{ {
return serverDescriptor.getVersionRevision(); return currentDescriptor.getVersionRevision();
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -100,7 +102,7 @@ public class RepositoryServerModel implements ServerModel
*/ */
public String getVersionLabel() public String getVersionLabel()
{ {
return serverDescriptor.getVersionLabel(); return currentDescriptor.getVersionLabel();
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -108,7 +110,7 @@ public class RepositoryServerModel implements ServerModel
*/ */
public String getVersionBuild() public String getVersionBuild()
{ {
return serverDescriptor.getVersionBuild(); return currentDescriptor.getVersionBuild();
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -116,7 +118,7 @@ public class RepositoryServerModel implements ServerModel
*/ */
public String getVersion() public String getVersion()
{ {
return serverDescriptor.getVersion(); return currentDescriptor.getVersion();
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -132,7 +134,7 @@ public class RepositoryServerModel implements ServerModel
*/ */
public int getSchema() public int getSchema()
{ {
return serverDescriptor.getSchema(); return currentDescriptor.getSchema();
} }
} }

View File

@@ -204,27 +204,7 @@ public class StreamContent extends AbstractWebScript
} }
catch(Throwable e) catch(Throwable e)
{ {
if (logger.isInfoEnabled()) throw createStatusException(e, req, res);
logger.info("Caught exception & redirecting to status template: " + e.getMessage());
// extract status code, if specified
int statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
if (e instanceof WebScriptException)
{
statusCode = ((WebScriptException)e).getStatus();
}
// send status
Status status = new Status();
status.setCode(statusCode);
status.setMessage(e.getMessage());
status.setException(e);
Cache cache = new Cache();
cache.setNeverCache(true);
Map<String, Object> customModel = new HashMap<String, Object>(8, 1.0f);
customModel.put("status", status);
Map<String, Object> templateModel = createTemplateParameters(req, res, customModel);
sendStatus(req, res, status, cache, format, templateModel);
} }
} }