How to copy access control rules into other project using single button

One of the most popular configurations of TrackStudio: several similar projects, access control rules for which are configured differently for different commands. This configuration can be found in HelpDesk, and in custom development. Every time we create a new project, we need to configure the access control rules. What if we try to copy these settings from other project, which is developed by the same team?

This can be done by a single button, which will run Add Message/Instead Of Trigger. However, the message itself will not be created. Code of the project, from which the settings are to be copied, is indicated in the body of the message.

package scripts.instead_of_add_message;

import com.trackstudio.exception.GranException;
import com.trackstudio.external.OperationTrigger;
import com.trackstudio.secured.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.List;

 * Copies ACL from the task, described in the body of message, to the current one. */
public class CopyAccessRules  implements OperationTrigger {

       public static Log log = LogFactory.getLog(CopyAccessRules.class);
    public SecuredMessageTriggerBean execute(SecuredMessageTriggerBean message) throws GranException
        String taskNum = message.getDescription();
        SessionContext sc = message.getSecure();
        SecuredTaskBean task = AdapterManager.getInstance().getSecuredTaskAdapterManager().findTaskByNumber(sc, taskNum);
        if (task!=null){
        List targetAcl = AdapterManager.getInstance().getSecuredAclAdapterManager().getTaskAclList(sc,
        List sourceAcl = AdapterManager.getInstance().getSecuredAclAdapterManager().getTaskAclList(sc,

        for (SecuredTaskAclBean tb: sourceAcl){
            if (tb.canManage() && tb.getTaskId().equals(task.getId())){

                SecuredPrstatusBean group = tb.getGroup();
                SecuredUserBean user = tb.getUser();
                SecuredPrstatusBean prstatus = tb.getPrstatus();
                boolean isOverride = tb.isOverride();
            boolean exists = false;
                if (!sc.getUser().equals(user)){
            for (SecuredTaskAclBean ta: targetAcl){
                SecuredPrstatusBean groupA = ta.getGroup();
                SecuredUserBean userA = ta.getUser();
                SecuredPrstatusBean prstatusA = ta.getPrstatus();
                boolean isOverrideA = ta.isOverride();
                if ((group!=null && groupA!=null && group.equals(groupA)) 
|| (group==null && groupA == null))
                    if ((user!=null && userA!=null && user.equals(userA)) 
|| (user==null && userA == null))
                        if ((prstatus!=null && prstatusA!=null && prstatus.equals(prstatusA)) ||
 (prstatus==null && prstatusA == null))
                            if (isOverride==isOverrideA){
                                exists = true;
                if (!exists){
                    // create
                    String aclid = 
AdapterManager.getInstance().getSecuredAclAdapterManager().createAcl(sc, message.getTaskId(), null,
                            user!=null ? user.getId() : null, group!=null ? group.getId() : null);
AdapterManager.getInstance().getSecuredAclAdapterManager().updateTaskAcl(sc, aclid, prstatus.getId(), isOverride);

        return message;