// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
// Special characters, e.g., é, ö, à, etc. are supported in comments.
package communitycommons.actions;
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.systemwideinterfaces.core.IMendixObject;
import com.mendix.webui.CustomJavaAction;
import com.mendix.webui.FeedbackHelper;
import communitycommons.ORM;
/**
* Use this function to automatically encrypt attributes of an object during (for example) before commit.
*
* The function assumes that if the provided attributeName is in 'changed' status, a new plain text value has been assigned which needs to be encrypted. Leaves the value as-is otherwise.
*
* - item : the owner of the specified attribute
* - attributeName : the attribute which should be encrypted
* - key : the encryption key (zie encrypt string)
* - refreshItem: whether the object should be refreshed in the client. If true, the users sees the encrypted value, if false, the user still sees the unencrypted value, although the database already contains an encrypted value
*
* returns: true if the value was changed and has been re-encrypted. False otherwise
*/
public class encryptMemberIfChanged extends CustomJavaAction<java.lang.Boolean>
{
private IMendixObject item;
private java.lang.String attributeName;
private java.lang.String key;
private java.lang.Boolean refreshItem;
public encryptMemberIfChanged(IContext context, IMendixObject item, java.lang.String attributeName, java.lang.String key, java.lang.Boolean refreshItem)
{
super(context);
this.item = item;
this.attributeName = attributeName;
this.key = key;
this.refreshItem = refreshItem;
}
@Override
public java.lang.Boolean executeAction() throws Exception
{
// BEGIN USER CODE
if (refreshItem && item != null) {
FeedbackHelper.addRefreshObjectFeedback(this.getContext(), item.getId());
}
return ORM.encryptMemberIfChanged(getContext(), item, attributeName, key);
// END USER CODE
}
/**
* Returns a string representation of this action
*/
@Override
public java.lang.String toString()
{
return "encryptMemberIfChanged";
}
// BEGIN EXTRA CODE
// END EXTRA CODE
}