public static void performTransition(
      ActivityInstanceBean activityInstance, TransitionTarget transitionTarget, boolean complete) {
    ExecutionPlan plan = new ExecutionPlan(transitionTarget);
    plan.assertNoOtherActiveActivities();

    ModelManager mm = ModelManagerFactory.getCurrent();
    IActivity target =
        mm.findActivity(transitionTarget.getModelOid(), transitionTarget.getActivityRuntimeOid());
    if (target == null) {
      throw new ObjectNotFoundException(
          BpmRuntimeError.MDL_UNKNOWN_ACTIVITY_IN_MODEL.raise(
              transitionTarget.getActivityRuntimeOid(), transitionTarget.getModelOid()));
    }

    BpmRuntimeEnvironment rtEnv = PropertyLayerProviderInterceptor.getCurrent();
    ExecutionPlan oldPlan = rtEnv.getExecutionPlan();
    try {
      rtEnv.setExecutionPlan(plan);
      if (complete) {
        ActivityInstanceUtils.complete(activityInstance, null, null, true);
      } else {
        long rootOid = plan.getRootActivityInstanceOid();
        if (rootOid != activityInstance.getOID()) {
          activityInstance = ActivityInstanceUtils.lock(rootOid);
        }
        ActivityInstanceUtils.abortActivityInstance(activityInstance);
      }
    } finally {
      rtEnv.setExecutionPlan(oldPlan);
    }
  }
 public static void verify(IData data, ClientPermission permission) {
   BpmRuntimeEnvironment runtimeEnvironment = PropertyLayerProviderInterceptor.getCurrent();
   if (runtimeEnvironment.isSecureContext()) {
     AuthorizationContext context = AuthorizationContext.create(permission);
     DataAuthorization2Predicate authorizationPredicate = new DataAuthorization2Predicate(context);
     if (!authorizationPredicate.accept(data)) {
       IUser user = context.getUser();
       throw new AccessForbiddenException(
           BpmRuntimeError.AUTHx_AUTH_MISSING_GRANTS.raise(
               user.getOID(), String.valueOf(permission), user.getAccount()));
     }
   }
 }