Further fix for ACE-2932 to allow the UI to post pseudo-qname strings like "Site" or "Tag".

Without this fix, strings with no leading "{}" are rejected as not being recognised as QNames.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@86035 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Neil McErlean
2014-09-30 15:21:08 +00:00
parent e2dded6a18
commit 5d1fc74367
2 changed files with 17 additions and 2 deletions

View File

@@ -24,7 +24,8 @@ import org.alfresco.service.namespace.QName;
/**
* This class provides some simple utility methods for dealing with {@link QName QNames}
* within the faceted search feature.
* within the faceted search feature. The whole thing should be considered a hack to handle 'special cases'.
* <p/>
* These are not intended for general use, or else they'd be in the {@link QName} class.
* @since 5.0
*/
@@ -58,6 +59,13 @@ public abstract class FacetQNameUtils
// Assume it's a short-form qname.
result = QName.createQName(s, resolver);
}
else if (!s.contains(Character.toString(QName.NAMESPACE_BEGIN)) &&
!s.contains(Character.toString(QName.NAMESPACE_END)) &&
!s.contains(Character.toString(QName.NAMESPACE_PREFIX)))
{
// No '{', '}' or ':' means it's a prefixless QName (SITE or TAG, in our case).
result = QName.createQName(null, s);
}
else
{
// We're not sure what sort of qname this is supposed to be.

View File

@@ -74,7 +74,14 @@ public class FacetQNameUtilsTest
FacetQNameUtils.createQName("{http://www.alfresco.org/model/foo/1.0}localName", resolver));
}
// Note: it doesn't really make sense to have a short-form qname with no prefix.
@Test public void canCreateFromShortFormWithNoPrefix() throws Exception
{
// The sensibleness of this from an Alfresco perspective is questionable.
// But this is what we must do to support 'QName' strings like "Site" or "Tag" in the REST API.
assertEquals(QName.createQName(null, "localName"),
FacetQNameUtils.createQName("localName", resolver));
}
@Test public void canCreateFromLongFormWithNoPrefix() throws Exception
{
assertEquals(QName.createQName(null, "localName"),