REPO-2516 - MNT-17845: Added a null check on the noderef

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@137796 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ancuta Morarasu
2017-06-25 15:05:22 +00:00
parent f10fa934f5
commit c9806ab898

View File

@@ -116,34 +116,36 @@ public class Reference
*/
public static final Reference fromNodeRef(NodeRef nodeRef)
{
String id = nodeRef.getId();
if (id.startsWith("" + VIRTUAL_TOKEN) && (id.length() > 1)) // belts-and-braces
if (nodeRef != null)
{
char token = id.charAt(1);
Encoding encoding = Encodings.fromToken(token);
if (encoding != null)
String id = nodeRef.getId();
if (id.startsWith("" + VIRTUAL_TOKEN) && (id.length() > 1)) // belts-and-braces
{
try
char token = id.charAt(1);
Encoding encoding = Encodings.fromToken(token);
if (encoding != null)
{
String referenceString = id.substring(2);
if (!encoding.urlNative)
try
{
referenceString = new String(org.apache.commons.codec.binary.Base64.decodeBase64(referenceString));
String referenceString = id.substring(2);
if (!encoding.urlNative)
{
referenceString = new String(org.apache.commons.codec.binary.Base64.decodeBase64(referenceString));
}
Reference reference = encoding.parser.parse(referenceString);
return reference.propagateNodeRefMutations(nodeRef);
}
catch (ReferenceParseException rpe)
{
logger.debug("Parse exception:", rpe);
return null;
}
catch (ReferenceEncodingException ree)
{
logger.debug("Encoding exception:", ree);
return null;
}
Reference reference = encoding.parser.parse(referenceString);
return reference.propagateNodeRefMutations(nodeRef);
}
catch (ReferenceParseException rpe)
{
logger.debug("Parse exception:", rpe);
return null;
}
catch (ReferenceEncodingException ree)
{
logger.debug("Encoding exception:", ree);
return null;
}
}
}
return null;