AnsweredAssumed Answered

upload user avatar via webservice

Question asked by hatspeed on May 29, 2013
Hi everybody,

How to update user avatar image from web service. I tried to add child association for the person node directly, but i got the integrity exception. Please help me. This is my code

            Reference reference = new Reference();
            reference.setStore(spacesStore);
            reference.setUuid("cacdd00c-a779-4c24-942f-cc9a66c5d5c8");
            Predicate sourcePredicate = new Predicate(new Reference[]{
            reference}, spacesStore, null);           
            Reference treference = new Reference();
            treference.setStore(spacesStore);
            treference.setPath("/sys:system/sys:people/cm:demouser");                       
            ParentReference targetSpace = new ParentReference();
            //targetSpace.setStore(store);
            targetSpace.setStore(spacesStore);
            targetSpace.setPath(treference.getPath());
            targetSpace.setAssociationType("{http://www.alfresco.org/model/content/1.0}avatar");
            // targetSpace.setAssociationType(Constants.ASSOC_CONTAINS);

            targetSpace.setChildName("scan00011.jpg");
            CMLAddChild addChild = new CMLAddChild();
            addChild.setWhere(sourcePredicate);
            addChild.setTo(targetSpace);

            CML cmlAddChild = new CML();
            cmlAddChild.setAddChild(new CMLAddChild[]{addChild});
            WebServiceFactory.getRepositoryService().update(cmlAddChild);


This is the Exception

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:0org.alfresco.repo.node.integrity.IntegrityException: 01090848 Found 1 integrity violations:
This operation is only relevant to child associations
Trace of possible cause:
org.alfresco.repo.node.integrity.AssocTargetRoleIntegrityEvent.checkIntegrity(AssocTargetRoleIntegrityEvent.java:73)
org.alfresco.repo.node.integrity.IntegrityChecker.processAllEvents(IntegrityChecker.java:704)



Hatspeed

Outcomes