cancel
Showing results for 
Search instead for 
Did you mean: 

Get prefix from the namespace!

mjuarez
Champ in-the-making
Champ in-the-making
I need get the prefix of the content type. I'm work in WebService (JAVA). I try with "NamespacePrefixResolver" and "DynamicNamespacePrefixResolver", but not work.. Smiley Sad

Please Help!
5 REPLIES 5

janv
Employee
Employee
Here's an example snippet:


        …
        String myQNameString = "{http://www.alfresco.org/model/content/1.0}content"; // in format "{namespaceURI}localName"
        QName myQNameResolved = QName.createQName(myQNameString).getPrefixedQName(namespaceService);
        String prefixLocal[] = QName.splitPrefixedQName(myQNameResolved.toPrefixString());
        System.out.println("Prefix: "+prefixLocal[0]);
        …
Hope it helps.

Regards,
Jan

mjuarez
Champ in-the-making
Champ in-the-making
Thanks for your help janv, but don't working this… "namespaceService" is a NamespacePrefixResolver, how initialize this object? 
I try with:

NamespacePrefixResolver namespaceService = new DynamicNamespacePrefixResolver();

This is the error:

org.alfresco.service.namespace.InvalidQNameException: QName '{http://www.alfresco.org/model/content/1.0}' must consist of a local name
   at org.alfresco.service.namespace.QName.createQName(QName.java:175)

Regards!

mjuarez
Champ in-the-making
Champ in-the-making
i still can't get the prefix of custom models.. Smiley Sad

Please help to mee!!

hyperation
Champ on-the-rise
Champ on-the-rise

serviceRegistry.getNamespaceService();

mwildam
Champ in-the-making
Champ in-the-making

serviceRegistry.getNamespaceService();
What is "serviceRegistry" your case?

Under WebServiceFactory I don't have a getNamespaceService();  Smiley Surprised