cancel
Showing results for 
Search instead for 
Did you mean: 

Duplicate Folder Path (allowed) breaks Web Services methods

igor1234
Champ in-the-making
Champ in-the-making
Hi.
I'm evaluating Alfresco Enterprise 3.0 SP1 and Web Services specifically.
I've been using basic functionality (save folder, delete folder, copy folder, save content) following available examples.

The issue I have noticed, and was able to reproduce, related to some of the most basic functionality - Create new Folder (space) - using webservice.

There are two names attributed to a space (folder):
1. Display Name - shown in Web Client and passed with 'CMLCreate' - 'NamedValue' model objects.
2. Name used in a folder(space) path - 'childName' attribute of  'ParentReference' model object.

When I create folder with existing 'Display Name' I get
"Duplicate child name not allowed:"
error (which is good!).

But when I create folder(space) with existing path-name (but different 'Display Name') it is allowed to go through (no errors) !!!

After that,  these duplicated folders displayed  normally in Web Client by their 'Display Name' but from WebService point of view, data became corrupted. Any method call involving Reference to this duplicated path,
something like:
WebServiceFactory.getRepositoryService().get(new Predicate(new Reference[]{reference}, STORE, null) );
generated this error:

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString:
faultActor:
faultNode:
faultDetail:
   {http://www.alfresco.org/ws/service/repository/1.0}RepositoryFault:<ns1:errorCode>0</ns1:errorCode><ns1:message>java.lang.IllegalStateException: Failed to resolve to a single NodeRef with parameters (store=workspace:SpacesStore uuid=null path=/app:company_home/cm:AdPortal2/cm:test_Duplicate), found 2 nodes.</ns1:message>
   {http://xml.apache.org/axis/}exceptionName:org.alfresco.repo.webservice.repository.RepositoryFault
   {http://xml.apache.org/axis/}stackTrace:
   at org.alfresco.repo.webservice.repository.RepositoryWebService.get(RepositoryWebService.java:482)

In fact I'm getting the same error for all other WebServices method-calls that take 'Reference' object as input (I could not delete it for example).

To aggravate that, I've got several 'Fantom' folders created that do not show in Web Client but still recorded somewhere in Alfresco DB tables and when I try to reuse their names (in a folder-path) I get above error. For this second problem I suspect 'shallow copy' issue (described in another thread: http://forums.alfresco.com/en/viewtopic.php?f=27&t=13160) occurring  during  copping (moving) folder(s) with subfolder(s) in WebClient (this is obviously for another topic).

Thanks,
Igor
3 REPLIES 3

rwetherall
Confirmed Champ
Confirmed Champ
Hi Igor,

I'll try and reproduce this with a unit test and let you know how I get on.

Cheers,
Roy

rwetherall
Confirmed Champ
Confirmed Champ
Hi Igor,

The issue here is that the "display name" should be set to the same as the child association name.  This is a feature of the fundamental services, not the web services specifically.

So as a guide, the assoc child name should always be the same as the "cm:name" property.  This is enforced by some of the higher level API's in the repository (eg FileFolderService), but not directly by the NodeService which this web service implementation is using.

The integrity checker looks at the cm:name property and uses that to check uniqueness, not the path, which is why you have seen the situation you have.  When creating a new folder it is important then that the last path of the path (or the primary parent association for the new folder) has the same value as the cm:name property.

Hope this helps,
Roy

igor1234
Champ in-the-making
Champ in-the-making
Unfortunately I can't accept your answer because in Alfresco’s official example files ('SamplesBase.java')
you created your sample folder with

path-name: "sample_folder"
and
display-name: "Web Service Sample Folder"

/**
* @author Roy Wetherall
*/
public class SamplesBase
{
    /** Admin user name and password used to connect to the repository */
    protected static final String USERNAME = "admin";
    protected static final String PASSWORD = "admin";
   
    /** The store used throughout the samples */
    protected static final Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
   
    protected static final Reference SAMPLE_FOLDER = new Reference(STORE, null, "/app:company_home/cm:sample_folder");
   
    protected static void createSampleData() throws Exception
    {
        try
        {
            // Check to see if the sample folder has already been created or not
            WebServiceFactory.getRepositoryService().get(new Predicate(new Reference[]{SAMPLE_FOLDER}, STORE, null));
        }
        catch (Exception exception)
        {
            // Create parent reference to company home
            ParentReference parentReference = new ParentReference(
                    STORE,
                    null,
                    "/app:company_home",
                    Constants.ASSOC_CONTAINS,
                    Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, "sample_folder"));

            // Create folder
            NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, "Web Service Sample Folder")};
            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); 

Also there are a lot of limitations on a string that can be used as a path-name (spaces, special characters, …)
so practically, it would be hard to keep them the same and have readable names displayed in Web Client.

I did see a lot of questions regarding this disconnect between  "display name" and "path name". For example people asking how they could see the path-name while in Web Client. I would ask how you can search by "display name" if you don't know the path. But I did not see any good answer or explanation.

Regards,
Igor