ACS-2334 improve ArchivedIOException logging (#859)

* ACS-2234: Improving ArchivedIOException logging.

* ACS-2234: Improving ArchivedIOException logging.

* ACS-2234: Throw WebScriptException wit 412 status code when ArchivedIOException caught.

* ACS-2234: Fixing formatting and removing unused import.
This commit is contained in:
mpichura
2022-01-13 10:51:12 +01:00
committed by GitHub
parent 4e9f362482
commit 8278c9ced2

View File

@@ -47,6 +47,7 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TooBusyException;
import org.alfresco.repo.web.scripts.bean.LoginPost;
import org.alfresco.service.cmr.repository.ArchivedIOException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.TemplateService;
import org.alfresco.service.cmr.security.AuthorityService;
@@ -506,6 +507,10 @@ public class RepositoryContainer extends AbstractRuntimeContainer
return;
}
}
catch (ArchivedIOException e) // handle ArchivedIOException to lower log pollution
{
handleArchivedIOException(e);
}
catch (IOException e)
{
handleIOException(e);
@@ -606,6 +611,10 @@ public class RepositoryContainer extends AbstractRuntimeContainer
// Map TooBusyException to a 503 status code
throw new WebScriptException(HttpServletResponse.SC_SERVICE_UNAVAILABLE, e.getMessage(), e);
}
catch (ArchivedIOException e) // handle ArchivedIOException to lower log pollution
{
handleArchivedIOException(e);
}
// Ensure a response is always flushed after successful execution
if (bufferedRes != null)
@@ -615,6 +624,19 @@ public class RepositoryContainer extends AbstractRuntimeContainer
}
}
private void handleArchivedIOException(ArchivedIOException e)
{
if (logger.isDebugEnabled()) // log with stack trace at debug level
{
logger.debug("ArchivedIOException error ", e);
}
else if (logger.isInfoEnabled()) // log without stack trace at info level
{
logger.info("ArchivedIOException error. Message: " + e.getMessage());
}
throw new WebScriptException(HttpServletResponse.SC_PRECONDITION_FAILED, "Content is archived and not accessible.");
}
private static void handleIOException(final IOException ioe) throws IOException
{
Throwable socketException = ExceptionStackUtil.getCause(ioe, SocketException.class);