Merged HEAD (5.2) to 5.2.N (5.2.1)

126554 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
      124208 gjames: RA-892: Improved the error message handling


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126900 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ancuta Morarasu
2016-05-11 12:08:05 +00:00
parent e8cd9542c3
commit 0779769e84
5 changed files with 35 additions and 14 deletions

View File

@@ -3,7 +3,7 @@ framework.exception.ApiDefault=Unknown error calling the Rest API
framework.exception.ConstraintViolated=A constraint was violated framework.exception.ConstraintViolated=A constraint was violated
framework.exception.InvalidArgument=An invalid argument was received {0} framework.exception.InvalidArgument=An invalid argument was received {0}
framework.exception.InvalidQuery=An invalid WHERE query was received. {0} framework.exception.InvalidQuery=An invalid WHERE query was received. {0}
framework.exception.InvalidSelect=An invalid SELECT query was received. {0} framework.exception.InvalidSelect=An invalid {1} query was received. {0}
framework.exception.NotFound={0} was not found framework.exception.NotFound={0} was not found
framework.exception.EntityNotFound=The entity with id: {0} was not found framework.exception.EntityNotFound=The entity with id: {0} was not found
framework.exception.RelationshipNotFound=The relationship resource was not found for the entity with id: {0} and a relationship id of {1} framework.exception.RelationshipNotFound=The relationship resource was not found for the entity with id: {0} and a relationship id of {1}

View File

@@ -38,8 +38,8 @@ public class InvalidSelectException extends InvalidArgumentException
public static String DEFAULT_MESSAGE_ID = "framework.exception.InvalidSelect"; public static String DEFAULT_MESSAGE_ID = "framework.exception.InvalidSelect";
public InvalidSelectException(Object queryParam) public InvalidSelectException(String paramName, Object queryParam)
{ {
super(DEFAULT_MESSAGE_ID, new Object[] {queryParam}); super(DEFAULT_MESSAGE_ID, new Object[] {queryParam, paramName});
} }
} }

View File

@@ -36,6 +36,7 @@ public class InvalidQueryException extends InvalidArgumentException
{ {
private static final long serialVersionUID = 8825573452685077660L; private static final long serialVersionUID = 8825573452685077660L;
public static String DEFAULT_MESSAGE_ID = "framework.exception.InvalidQuery"; public static String DEFAULT_MESSAGE_ID = "framework.exception.InvalidQuery";
private Object queryParam;
public InvalidQueryException() { public InvalidQueryException() {
super(DEFAULT_MESSAGE_ID); super(DEFAULT_MESSAGE_ID);
@@ -44,5 +45,12 @@ public class InvalidQueryException extends InvalidArgumentException
public InvalidQueryException(Object queryParam) public InvalidQueryException(Object queryParam)
{ {
super(DEFAULT_MESSAGE_ID, new Object[] {queryParam}); super(DEFAULT_MESSAGE_ID, new Object[] {queryParam});
this.queryParam = queryParam;
} }
public Object getQueryParam()
{
return queryParam;
}
} }

View File

@@ -267,7 +267,7 @@ public class ResourceWebScriptHelper
if (selectedPropsTree instanceof CommonErrorNode) if (selectedPropsTree instanceof CommonErrorNode)
{ {
logger.debug("Error parsing the "+paramName+" clause "+selectedPropsTree); logger.debug("Error parsing the "+paramName+" clause "+selectedPropsTree);
throw new InvalidSelectException(selectedPropsTree); throw new InvalidSelectException(paramName, selectedPropsTree);
} }
if (selectedPropsTree.getChildCount() == 0 && !selectedPropsTree.getText().isEmpty()) if (selectedPropsTree.getChildCount() == 0 && !selectedPropsTree.getText().isEmpty())
{ {
@@ -292,9 +292,12 @@ public class ResourceWebScriptHelper
{ {
logger.debug("Error parsing the \"+paramName+\" clause: "+param); logger.debug("Error parsing the \"+paramName+\" clause: "+param);
} }
catch (InvalidQueryException iqe)
{
throw new InvalidSelectException(paramName, iqe.getQueryParam());
}
//Default to throw out an invalid query //Default to throw out an invalid query
throw new InvalidSelectException(param); throw new InvalidSelectException(paramName, param);
} }
/** /**

View File

@@ -225,7 +225,7 @@ public class ResourceWebScriptHelperTests
theClause = getClause(paramName, "x/,z"); theClause = getClause(paramName, "x/,z");
fail("Should throw an InvalidSelectException"); fail("Should throw an InvalidSelectException");
} }
catch (InvalidArgumentException error) catch (InvalidSelectException error)
{ {
//this is correct //this is correct
} }
@@ -235,7 +235,7 @@ public class ResourceWebScriptHelperTests
theClause = getClause(paramName, "/x'n,/z"); theClause = getClause(paramName, "/x'n,/z");
fail("Should throw an InvalidSelectException"); fail("Should throw an InvalidSelectException");
} }
catch (InvalidArgumentException error) catch (InvalidSelectException error)
{ {
//this is correct //this is correct
} }
@@ -245,7 +245,7 @@ public class ResourceWebScriptHelperTests
theClause = getClause(paramName, "/foo/0"); theClause = getClause(paramName, "/foo/0");
fail("Should throw an InvalidSelectException. Legal identifiers must start with a letter not zero"); fail("Should throw an InvalidSelectException. Legal identifiers must start with a letter not zero");
} }
catch (InvalidArgumentException error) catch (InvalidSelectException error)
{ {
//this is correct //this is correct
} }
@@ -255,7 +255,17 @@ public class ResourceWebScriptHelperTests
theClause = getClause(paramName, "/"); theClause = getClause(paramName, "/");
fail("Should throw an InvalidSelectException. No identifier specified."); fail("Should throw an InvalidSelectException. No identifier specified.");
} }
catch (InvalidArgumentException error) catch (InvalidSelectException error)
{
//this is correct
}
try
{
theClause = getClause(paramName, "path, isLink");
fail("Should throw an InvalidSelectException. No identifier specified.");
}
catch (InvalidSelectException error)
{ {
//this is correct //this is correct
} }