cancel
Showing results for 
Search instead for 
Did you mean: 

Max size of 255 when create a node

spilby
Confirmed Champ
Confirmed Champ
Hi everybody,

I have a doubt with the max size when I try to create a node.

I'm using the getNodeService().createNode. When I set the title and the name properties, and the size exceeds 255 characters, my java webscript returns me a java.lang.IllegalArgumentException "Localname is too long".

I decompile the DbNodeServiceImpl class and I can see the code of this exception:


if(assocQName.getLocalName().length() > QName.MAX_LENGTH) {
            throw new IllegalArgumentException("Localname is too long. Length of " +
                 assocQName.getLocalName().length() + " exceeds the maximum of " + QName.MAX_LENGTH);
        }


QName.MAX_LENGTH value is 255.

But when I create a new folder with the Alfresco share, and put on the name and title properties a string with 500 characters, it could be created ok, without size limit problems. How is possible?? How can I create a longest name with the API like the Alfresco share does? Is possible to change this max_length?

Thanks a lot!

4 REPLIES 4

s_palyukh
Star Contributor
Star Contributor
Hi,

I think the default Alfresco API uses FileFolderServiceImpl instead of DbNodeService… Thy the following:


FileInfo fileInfo = getFileFolderService().create(parentNodeRef,"someName", ContentModel.TYPE_CONTENT);  

Thanks, I try with FileFolderService. But the Map of properties, how can I create the node with a property list?

I do this now:


nodeRef = getNodeService().createNode(
                           parent,
                           ContentModel.ASSOC_CONTAINS,
                           QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name),
                           type,
                           properties).getChildRef();


where properties is a
Map<QName, Serializable>


And then I do an addAspect.

mrogers
Star Contributor
Star Contributor
There should be a limit.   If you have found some way around that then its a bug.   Please be aware that some interfaces will truncate the name to fit.

spilby
Confirmed Champ
Confirmed Champ
Well, I found it on the alfresco class, the if that I wrote before. Is a limitation of the class, not a bug, or not? Everybody have this limit when call the create node method? I imagine a lot of people needs a name with more than 255 characters