Hi guys,

in my activation workflow I want to delete users that present an expired token.
As I remember, I cannot delete a user in a workflow step.
Following Francesco's suggestion, I have a "sink" in my workflow where
I put those users.
I wanted to rename them & change the email-address (both unique in my
schema) so they are free for other (or maybe the same) users.

So what I did in my workflow step:
------------
    SyncopeUser user = (SyncopeUser)
execution.getVariable(ActivitiUserWorkflowAdapter.SYNCOPE_USER);
    UserMod userMod=new UserMod();

    userMod.setUsername("delete_"+user.getUsername());
    AttributeMod attMod=new AttributeMod();
    attMod.setSchema("email");
    String email=user.getAttribute("email").getUniqueValue().getValueAsString();

    attMod.addValueToBeRemoved(email);
    attMod.addValueToBeAdded("deleted_"+email);

    userMod.addAttributeToBeUpdated(attMod);

    PropagationByResource propByRes = dataBinder.update(user, userMod);

    execution.setVariable(ActivitiUserWorkflowAdapter.SYNCOPE_USER, user);
    execution.setVariable(ActivitiUserWorkflowAdapter.PROP_BY_RESOURCE,
propByRes);
-----------
The user ends up in the "toberemoved" state in the workflow, which I
see in console.
However when I press "delete" in the console I get strange errors
Cannot delete or update a parent row: a foreign key constraint fails
(`syncope`.`uattruniquevalue`, CONSTRAINT `uattruniquevalue_ibfk_1`
FOREIGN KEY (`ATTRIBUTE_ID`) REFERENCES `UAttr` (`id`)) {prepstmnt
667215072 DELETE FROM UAttr WHERE id = ? [params=?]} [code=1451,
state=23000]

I noticed that the UAttrUniqueValue table holds the old emailaddress
and new emailaddress, both attached to the same attribute which of
course poses a uniqueness problem. When I delete the row with the old
address, I can delete the user through console.

Any ideas on what I did wrong? or is there another way to delete a
user from inside the workflow?

best regards

Bob

Reply via email to