cancel
Showing results for 
Search instead for 
Did you mean: 

Need precisions about CML

sam69
Champ in-the-making
Champ in-the-making
Hello !

I am using the webservices, and I think there is a lack of documentation (even javadoc). Do you know if there is a javadoc somewhere ?

For example, I need to move a file from a space to another (which is a simple task). But I can't find an example to do that, and no documentation about CML. Except this schema : http://wiki.alfresco.com/wiki/CML.

I have just the method signature :
CMLMove(ParentReference to, String to_id, String associationType, String childName, Predicate where, String where_id) {
To means destination ? or is it where ? I am lost 😉
So i tried with the following code :

Store STORE = new Store(StoreEnum.workspace, "SpacesStore");
    Predicate predicatSource = new Predicate(new Reference[]{new Reference(STORE, iDRessourceToMove, null)}, null, null);
    ParentReference parentRefDestination = new ParentReference(ConnecteurGEDAlfresco.STORE, IdDestination, null, Constants.ASSOC_CONTAINS, null);
    CMLMove cmlMove = new CMLMove(parentRefDestination, IdDestination, Constants.ASSOC_CONTAINS, "TEST", predicatSource, iDRessourceToMove);
    CML cml = new CML();
    cml.setMove(new CMLMove[]{cmlMove});
    UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cml);
But it's not working (and it's not throwing any exception)
Any ideas ?

NB : I am waiting for the 1.4 release impatiently (with the much simplier File webservice)
NB2 : Alfresco is a great product 🙂
11 REPLIES 11

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

Yes there is an issue with the move and copy commands in CML.  Details can be found here http://www.alfresco.org/jira/browse/AR-794

I agree we need more documentation and certainly as part of the fix for the above issue further CML samples will be added.

Cheers,
Roy

sam69
Champ in-the-making
Champ in-the-making
Thanks Roy !

I hope the 1.4 version will come soon Smiley Wink

I am waiting also for the CQL, the SQL-based query language. It's sound like a very good and powerfull idea !
CQL will be on the next version, isn't it ?

Cheers,
Samuel

sam69
Champ in-the-making
Champ in-the-making
Please don't forget the bug of CMLMove (http://www.alfresco.org/jira/browse/AR-794 ) for the 1.4 release.
I have tested the 1.4 Preview, and it's still not working…

I am not the only one who need this fonctionality :
http://forums.alfresco.com/viewtopic.php?t=2319&highlight=move
http://forums.alfresco.com/viewtopic.php?t=1625&highlight=move++copy
http://forums.alfresco.com/viewtopic.php?t=2173&highlight=move++copy


Thanks in advance.

Regards,

Samuel

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

Don't worry, this was fixed after the preview release.  I would expect the fix in the next release of 1.4.

Cheers,
Roy

sam69
Champ in-the-making
Champ in-the-making
OK, thanks a lot !

sam69
Champ in-the-making
Champ in-the-making
I have tested with the 1.4 RC1, and it's working now !
Thanks for the correction.

Here is my code for moving an element to a folder, if it can help someone (I added english commentaries, because I develop in French Smiley Wink )
    
/**Create relationship with the destination folder and the element to move */
    ParentReference dossierDestinationParentRef = new ParentReference();
    dossierDestinationParentRef.setStore(ConnecteurGEDAlfresco.STORE);
    dossierDestinationParentRef.setUuid(IDElemDestination);
    dossierDestinationParentRef.setAssociationType(Constants.ASSOC_CONTAINS);
    dossierDestinationParentRef.setChildName(nomElementADeplacer);
    /** Create the ref of the element to move */
    Reference sourceRef = new Reference();
    sourceRef.setStore(ConnecteurGEDAlfresco.STORE);
    sourceRef.setUuid(iDElementADeplacer);
    /** Move */
    CMLMove deplacer = new CMLMove();
    /** destination folder : */
    deplacer.setTo(dossierDestinationParentRef);
    /** element to move */
    deplacer.setWhere(new Predicate(new Reference[]{sourceRef}, null, null));
    /** Execute command */
    CML cmlDeplacer = new CML();
    cmlDeplacer.setMove(new CMLMove[]{deplacer});
    UpdateResult[] results;
    results = this.getWebServiceFactory().getRepositoryService().update(cmlDeplacer);

wsmith323
Champ in-the-making
Champ in-the-making
I have tested with the 1.4 RC1, and it's working now !
Thanks for the correction.

Here is my code for moving an element to a folder, if it can help someone (I added english commentaries, because I develop in French Smiley Wink )
    
/**Create relationship with the destination folder and the element to move */
    ParentReference dossierDestinationParentRef = new ParentReference();
    dossierDestinationParentRef.setStore(ConnecteurGEDAlfresco.STORE);
    dossierDestinationParentRef.setUuid(IDElemDestination);
    dossierDestinationParentRef.setAssociationType(Constants.ASSOC_CONTAINS);
    dossierDestinationParentRef.setChildName(nomElementADeplacer);
    /** Create the ref of the element to move */
    Reference sourceRef = new Reference();
    sourceRef.setStore(ConnecteurGEDAlfresco.STORE);
    sourceRef.setUuid(iDElementADeplacer);
    /** Move */
    CMLMove deplacer = new CMLMove();
    /** destination folder : */
    deplacer.setTo(dossierDestinationParentRef);
    /** element to move */
    deplacer.setWhere(new Predicate(new Reference[]{sourceRef}, null, null));
    /** Execute command */
    CML cmlDeplacer = new CML();
    cmlDeplacer.setMove(new CMLMove[]{deplacer});
    UpdateResult[] results;
    results = this.getWebServiceFactory().getRepositoryService().update(cmlDeplacer);


What should be contained in the String variable "nomElementADeplacer" that is passed to .setChildName()?  Is this a QName?  If so, how do I get it?

sam69
Champ in-the-making
Champ in-the-making
In my case, it's just the name of the file to move, not a QName, and it's working.

footbruce
Champ in-the-making
Champ in-the-making
Hi,

When I try your code I have an error on this line :
results = this.getWebServiceFactory().getRepositoryService().update(cmlDeplacer);

It gives to me the error : null


public static void copy(String nomFichier, String idFichier, String idNouveauFichier,String ciblePath, String depPath) throws Exception
    {
       /**Create relationship with the destination folder and the element to move */
        ParentReference dossierDestinationParentRef = new ParentReference();
        dossierDestinationParentRef.setStore(STORE);
        dossierDestinationParentRef.setPath(ciblePath);
        //dossierDestinationParentRef.setUuid(idNouveauFichier);
        dossierDestinationParentRef.setAssociationType(Constants.ASSOC_CONTAINS);
        dossierDestinationParentRef.setChildName(nomFichier);
       
        /** Create the ref of the element to move */
        Reference sourceRef = new Reference();
        sourceRef.setStore(STORE);
        //sourceRef.setPath(depPath);
        sourceRef.setUuid(idFichier);
       
        /** Move */
        CMLMove deplacer = new CMLMove();
        /** destination folder : */
        deplacer.setTo(dossierDestinationParentRef);
        /** element to move */
        deplacer.setWhere(new Predicate(new Reference[]{sourceRef}, null, null));
        /** Execute command */
        CML cmlDeplacer = new CML();
        cmlDeplacer.setMove(new CMLMove[]{deplacer});
        UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cmlDeplacer);
    }