diff --git a/config/alfresco/public-rest-context.xml b/config/alfresco/public-rest-context.xml
index e4602e6d8c..fe7ef4f68e 100644
--- a/config/alfresco/public-rest-context.xml
+++ b/config/alfresco/public-rest-context.xml
@@ -44,7 +44,7 @@
-
+
Public Api
diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml
index e11b6ec737..44b46b1fef 100644
--- a/config/alfresco/web-scripts-application-context.xml
+++ b/config/alfresco/web-scripts-application-context.xml
@@ -134,7 +134,16 @@
js
-
+
+
+
+ java.sql.SQLException
+ org.alfresco.service.cmr.repository.ContentIOException
+
+
+
+
+
Repository
diff --git a/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java b/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java
index 2cf5baffaa..5246eeb180 100644
--- a/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java
+++ b/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java
@@ -21,8 +21,8 @@ package org.alfresco.repo.web.scripts;
import java.io.File;
import java.io.IOException;
import java.net.SocketException;
-import java.sql.SQLException;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
@@ -90,7 +90,7 @@ public class RepositoryContainer extends AbstractRuntimeContainer
private long maxContentSize = (long) 4 * 1024 * 1024 * 1024; // 4gb
private ThresholdOutputStreamFactory streamFactory = null;
- private final static Class>[] HIDE_EXCEPTIONS = new Class[] { SQLException.class };
+ private Class>[] notPublicExceptions = new Class>[] {};
/*
* Shame init is already used (by TenantRepositoryContainer).
@@ -178,6 +178,25 @@ public class RepositoryContainer extends AbstractRuntimeContainer
this.authorityService = authorityService;
}
+ /**
+ * Exceptions which may contain information that cannot be displayed in UI
+ *
+ * @param notPublicExceptions - {@link Class}<?>[] instance which contains list of not public exceptions
+ */
+ public void setNotPublicExceptions(List> notPublicExceptions)
+ {
+ this.notPublicExceptions = new Class>[] {};
+ if((null != notPublicExceptions) && !notPublicExceptions.isEmpty())
+ {
+ this.notPublicExceptions = notPublicExceptions.toArray(this.notPublicExceptions);
+ }
+ }
+
+ public Class>[] getNotPublicExceptions()
+ {
+ return notPublicExceptions;
+ }
+
/* (non-Javadoc)
* @see org.alfresco.web.scripts.Container#getDescription()
*/
@@ -262,7 +281,7 @@ public class RepositoryContainer extends AbstractRuntimeContainer
}
catch (RuntimeException e)
{
- Throwable hideCause = ExceptionStackUtil.getCause(e, HIDE_EXCEPTIONS);
+ Throwable hideCause = ExceptionStackUtil.getCause(e, notPublicExceptions);
if (hideCause != null)
{
AlfrescoRuntimeException alf = null;
diff --git a/source/test-java/org/alfresco/repo/web/scripts/RepositoryContainerTest.java b/source/test-java/org/alfresco/repo/web/scripts/RepositoryContainerTest.java
index b6967f6284..04ef309aaf 100644
--- a/source/test-java/org/alfresco/repo/web/scripts/RepositoryContainerTest.java
+++ b/source/test-java/org/alfresco/repo/web/scripts/RepositoryContainerTest.java
@@ -18,9 +18,15 @@
*/
package org.alfresco.repo.web.scripts;
+import static org.mockito.Matchers.any;
+import static org.springframework.extensions.webscripts.Status.STATUS_OK;
+
import java.sql.SQLException;
-import java.util.regex.Pattern;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.regex.Pattern;
import javax.servlet.http.HttpServletResponse;
@@ -30,6 +36,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.repo.forms.FormException;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
+import org.alfresco.service.cmr.repository.ContentIOException;
import org.alfresco.service.cmr.security.MutableAuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.CronTriggerBean;
@@ -37,18 +44,14 @@ import org.alfresco.util.PropertyMap;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import org.springframework.extensions.webscripts.Authenticator;
import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest;
import org.springframework.extensions.webscripts.TestWebScriptServer.Response;
-import org.springframework.extensions.webscripts.Authenticator;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
-import static org.springframework.extensions.webscripts.Status.*;
-
-import static org.mockito.Matchers.any;
-
/**
* Unit test to test runas function
*
@@ -56,6 +59,8 @@ import static org.mockito.Matchers.any;
*/
public class RepositoryContainerTest extends BaseWebScriptTest
{
+ private static final Pattern HIDDEN_EXCEPTION_PATTERN = Pattern.compile("Server error \\(\\d{8}\\)\\. Details can be found in the server logs\\.");
+
private MutableAuthenticationService authenticationService;
private PersonService personService;
private AuthenticationComponent authenticationComponent;
@@ -162,106 +167,273 @@ public class RepositoryContainerTest extends BaseWebScriptTest
assertEquals(SUCCESS, response.getContentAsString());
}
-
public void testHideExceptions() throws Exception
{
- final Pattern patternHiddenException = Pattern.compile("Server error \\(\\d{8}\\)\\. Details can be found in the server logs\\.");
final String messageFormException = "Failed to persist field 'prop_cm_name'";
final String messageAuthenticationException = "Authentication failed for Web Script";
-
+
RepositoryContainer repoContainer = (RepositoryContainer) getServer().getApplicationContext().getBean("webscripts.container");
RepositoryContainer repoContainerMock = Mockito.spy(repoContainer);
- // case: AlfrescoRuntimeException with SQLException cause
- Mockito.doAnswer(new Answer