cancel
Showing results for 
Search instead for 
Did you mean: 

Can't create folder(space) with name starting with a number

tuxetuxe
Champ in-the-making
Champ in-the-making
Hi!

Using the WS I can not create a folder which name starts with a number [0-9] as in "2007"…

Is this a known limitation or i'm doing some thing wrong?
I've blantely ripped off the method code from this forum (very thks to the original author!  :wink: )




Store store = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
Reference reference = new Reference(store, null, path);

ParentReference parentReference = new ParentReference(store,
   reference.getUuid(),
   reference.getPath(),
   Constants.ASSOC_CONTAINS,
   Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, name));

NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, name)};
CMLCreate create = new CMLCreate("1", parentReference, null, null,null, Constants.TYPE_FOLDER, properties);
CML cml = new CML();
cml.setCreate(new CMLCreate[]{create});


repositoryService.update(cml);

the exception i get is this one:

faultDetail:
   {http://www.alfresco.org/ws/service/repository/1.0}RepositoryFault:<ns1:errorCode>0</ns1:errorCode><ns1:message>Error executing xpath:
xpath: /app:company_home/cm:yyy/cm:zzz/cm:ttt/cm:rrr/cm:2007</ns1:message>
{http://xml.apache.org/axis/}exceptionNameSmiley Surprisedrg.alfresco.repo.webservice.repository.RepositoryFault
{http://xml.apache.org/axis/}stackTrace:
at org.alfresco.repo.webservice.repository.RepositoryWebService.update(RepositoryWebService.java:509)
at sun.reflect.GeneratedMethodAccessor534.invoke(Unknown Source)

Does anybody have any idea how to solve this? :?:
2 REPLIES 2

kevinr
Star Contributor
Star Contributor
Looks like an issue, I have created a JIRA item for it:
http://issues.alfresco.com/browse/AR-1182

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

I have investigated the issue, adding the following code to the unit test for the Repository Web Service.


    public void testFolderCreate()
        throws Exception
    {
        Reference newFolder = createFolder(BaseWebServiceSystemTest.rootReference, "123TestFolder");
        assertNotNull(newFolder);
        Reference newFolder2 = createFolder(BaseWebServiceSystemTest.rootReference, "2007");
        assertNotNull(newFolder2);
    }
   
    private Reference createFolder(Reference parent, String folderName)
        throws Exception
    {
        ParentReference parentReference = new ParentReference();
        parentReference.setAssociationType(Constants.ASSOC_CHILDREN);
        parentReference.setChildName(Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, folderName));
        parentReference.setStore(parent.getStore());
        parentReference.setUuid(parent.getUuid());
       
        NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, folderName)};
        CMLCreate create = new CMLCreate("1", parentReference, null, null, null, Constants.TYPE_FOLDER, properties);
        CML cml = new CML();
        cml.setCreate(new CMLCreate[]{create});
       
        UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cml);
       
        return results[0].getDestination();
    }

It all seems to be working against the current 2.0 HEAD.  I suggest you try your code using the provided createFolder method and see how you get on.

For now I'll close the issue, feel free to re-open/edit it with any further details should the problem persist.

Cheers,
Roy