this method must be called within the same transaction scope (namely engine is already started
@param procInstId
@throws DataAccessException
761571
public Integer lockProcessInstance(Long procInstId)
       throws DataAccessException {
        try {
            if (!isInTransaction()) throw
                new DataAccessException("Cannot lock activity instance without a transaction");
            return engineImpl.getDataAccess().lockProcessInstance(procInstId);
        } catch (SQLException e) {
            throw new DataAccessException(0, "Failed to lock process instance", e);
        }
    }
301098
public ProcessInstance getProcessInstance(Long procInstId)
            throws SQLException {
        String query = "select " + PROCINST_QUERY_FIELDS +
            " from PROCESS_INSTANCE where PROCESS_INSTANCE_ID=?";
        ResultSet rs = db.runSelect(query, procInstId);
        if (!rs.next()) throw new SQLException("Failed to load process instance: " + procInstId);
        return this.getProcessInstanceSub(rs);
    }
375045
public TransitionInstance getWorkTransitionInstance(Long pId)
    throws DataAccessException, ProcessException {
        TransitionInstance wti;
        TransactionWrapper transaction = null;
        EngineDataAccessDB edao = new EngineDataAccessDB();
        try {
            transaction = edao.startTransaction();
            wti = edao.getWorkTransitionInstance(pId);
        } catch (SQLException e) {
            throw new ProcessException(0, "Failed to get work transition instance", e);
        } finally {
            edao.stopTransaction(transaction);
        }
        return wti;
    }
918829
public String getSynchronousProcessResponse(Long procInstId, String varname)
    throws DataAccessException {
        TransactionWrapper transaction=null;
        try {
            transaction = startTransaction();
            return engineImpl.getServiceProcessResponse(procInstId, varname);
        } catch (Exception e) {
            if (canRetryTransaction(e)) {
                transaction = (TransactionWrapper)initTransactionRetry(transaction);
                return ((ProcessExecutor)getTransactionRetrier()).getSynchronousProcessResponse(procInstId, varname);
            }
            else
                throw new DataAccessException(0, "Failed to get value for variable " + varname, e);
        } finally {
            stopTransaction(transaction);
        }
    }
664301
@Override
	public AppEngineTransaction beginTransaction() {
		if (isTransactional()) {
			throw new IllegalStateException("Transaction has already started ["
					+ transaction.get().id() + "]");
		}
		
		AppEngineTransaction tx = new AppEngineTransaction(this);
		transaction.set(tx);
		logger.fine("Transaction [" + transaction.get().id() + "] started");
		return tx;
	}
313407
private void authorize(HttpSession session, Action action, Entity entity, String location)
            throws AuthorizationException, DataAccessException {
        AuthenticatedUser user  = (AuthenticatedUser)session.getAttribute("authenticatedUser");
        if (user == null && ApplicationContext.getServiceUser() != null) {
            String cuid = ApplicationContext.getServiceUser();
            user = new AuthenticatedUser(UserGroupCache.getUser(cuid));
        }

        if (user == null)
            throw new AuthorizationException(AuthorizationException.NOT_AUTHORIZED, "Authentication failure");
        if (action == Action.Create || action == Action.Delete) {
            if (!user.hasRole(Role.PROCESS_EXECUTION)) {
                throw new AuthorizationException(AuthorizationException.FORBIDDEN, "User "
                        + user.getCuid() + " not authorized for " + action + " on " + location);
            }
            logger.info("Asset mod request received from user: " + user.getCuid() + " for: " + location);
            UserAction userAction = new UserAction(user.getCuid(), action, entity, 0L, location);
            userAction.setSource(getClass().getSimpleName());
            ServiceLocator.getUserServices().auditLog(userAction);
        }
    }
1246260
@Override
  public void updateProcessBusinessKeyInHistory(ExecutionEntity processInstance) {
    if (isHistoryEnabled()) {
      if (log.isDebugEnabled()) {
        log.debug("updateProcessBusinessKeyInHistory : {}", processInstance.getId());
      }
      if (processInstance != null) {
        HistoricProcessInstanceEntity historicProcessInstance = getHistoricProcessInstanceEntityManager().findById(processInstance.getId());
        if (historicProcessInstance != null) {
          historicProcessInstance.setBusinessKey(processInstance.getProcessInstanceBusinessKey());
          getHistoricProcessInstanceEntityManager().update(historicProcessInstance, false);
        }
      }
    }
  }
194035
@Override public void init(ProcessingEnvironment procEnv) {
		super.init(procEnv);
		String className = procEnv.getClass().getName();
		if (className.startsWith("org.eclipse.jdt.")) {
			errorToShow = "This version of disableCheckedExceptions is not compatible with eclipse. javac only; sorry.";
			procEnv.getMessager().printMessage(Kind.WARNING, errorToShow);
		} else if (!procEnv.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment")) {
			procEnv.getMessager().printMessage(Kind.WARNING, "You aren't using a compiler based around javac v1.6, so disableCheckedExceptions will not work.\n" +
					"Your processor class is: " + className);
		} else {
			new LiveInjector().inject(ClassRootFinder.findClassRootOfClass(DisableCheckedExceptionsAgent.class));
		}
	}
1064373
public TransactionWrapper startTransaction() throws DataAccessException {
        TransactionWrapper transaction = new TransactionWrapper();
        TransactionUtil transUtil = TransactionUtil.getInstance();
        TransactionManager transManager = transUtil.getTransactionManager();
        try {
            if (logger.isTraceEnabled()) {
                logger.trace("startTransaction - transaction manager=" + transManager.hashCode() + " (status=" + transManager.getStatus() + ")");
            }
            transaction.setDatabaseAccess(db);
            if (transManager.getStatus()==Status.STATUS_NO_TRANSACTION) {
                transaction.setTransactionAlreadyStarted(false);
                // Get connection BEFORE beginning transaction to avoid transaction timeout (10 minutes) exceptions (Fail to stop the transaction)
                db.openConnection().setAutoCommit(false); // Also set autoCommit to false
                transManager.begin();
                transUtil.setCurrentConnection(db.getConnection());
            } else {
                if (logger.isTraceEnabled())
                    logger.trace("   ... transaction already started, status=" + transManager.getStatus());
                transaction.setTransactionAlreadyStarted(true);
                if (db.connectionIsOpen()) {
                    transaction.setDatabaseConnectionAlreadyOpened(true);
                } else {
                    if (logger.isTraceEnabled())
                        logger.trace("   ... but database is not open");
                    // not opened through this DatabaseAccess
                    transaction.setDatabaseConnectionAlreadyOpened(false);
                    if (transUtil.getCurrentConnection() == null) {
                        db.openConnection().setAutoCommit(false);  // Set autoCommit to false
                        transUtil.setCurrentConnection(db.getConnection());
                    } else {
                        db.setConnection(transUtil.getCurrentConnection());
                    }
                }
            }
            transaction.setTransaction(transManager.getTransaction());
            return transaction;
        } catch (Throwable e) {
            if (transaction.getTransaction()!=null) stopTransaction(transaction);
            throw new DataAccessException(0, "Fail to start transaction", e);
        }
    }
107593
void documentStart() throws SAXException{
        encoding = null;
        standalone = null;
        prefixLength = 0;
        value.setLength(0);
        valueStarted = false;
        entityValue = false;

        elem = elements[0];
        elemLock = elemDepth = 0;
        nsFree = 4;

        systemID = null;
        publicID = null;

        entities.clear();
        entityStack.clear();

        paramEntities.clear();
        paramEntityStack.clear();
        peReferenceOutsideMarkup = false;

        dtd = null;
        _dtd.reset();
        dtdElement = null;
        attributeList = null;
        dtdAttribute = null;

        if(contentHandler!=null){
            contentHandler.setDocumentLocator(this);
            contentHandler.startDocument();
        }
    }
502665
private void processINodesUC(DataInputStream in, ImageVisitor v,
      boolean skipBlocks) throws IOException {
    int numINUC = in.readInt();

    v.visitEnclosingElement(ImageElement.INODES_UNDER_CONSTRUCTION,
                           ImageElement.NUM_INODES_UNDER_CONSTRUCTION, numINUC);

    for(int i = 0; i < numINUC; i++) {
      checkInterruption();
      v.visitEnclosingElement(ImageElement.INODE_UNDER_CONSTRUCTION);
      
      byte [] name = FSImageSerialization.readBytes(in);
      String n = new String(name, "UTF8");
      v.visit(ImageElement.INODE_PATH, n);
      
      if (LayoutVersion.supports(Feature.ADD_INODE_ID, imageVersion)) {
        v.visit(ImageElement.INODE_ID, in.readLong());
      }
      
      v.visit(ImageElement.REPLICATION, in.readShort());
      v.visit(ImageElement.MODIFICATION_TIME, formatDate(in.readLong()));

      v.visit(ImageElement.PREFERRED_BLOCK_SIZE, in.readLong());
      int numBlocks = in.readInt();
      processBlocks(in, v, numBlocks, skipBlocks);

      processPermission(in, v);
      v.visit(ImageElement.CLIENT_NAME, FSImageSerialization.readString(in));
      v.visit(ImageElement.CLIENT_MACHINE, FSImageSerialization.readString(in));

      // Skip over the datanode descriptors, which are still stored in the
      // file but are not used by the datanode or loaded into memory
      int numLocs = in.readInt();
      for(int j = 0; j < numLocs; j++) {
        in.readShort();
        in.readLong();
        in.readLong();
        in.readLong();
        in.readInt();
        FSImageSerialization.readString(in);
        FSImageSerialization.readString(in);
        WritableUtils.readEnum(in, AdminStates.class);
      }

      v.leaveEnclosingElement(); // INodeUnderConstruction
    }

    v.leaveEnclosingElement(); // INodesUnderConstruction
  }
723109
public void configureIncidentQuery(IncidentQueryImpl query) {
    configureQuery(query);
    CompositePermissionCheck permissionCheck = new PermissionCheckBuilder()
            .disjunctive()
            .atomicCheck(PROCESS_INSTANCE, "RES.PROC_INST_ID_", READ)
            .atomicCheck(PROCESS_DEFINITION, "PROCDEF.KEY_", READ_INSTANCE)
            .build();
    addPermissionCheck(query.getAuthCheck(), permissionCheck);
  }
542734
@Override
    public void onProcessUnstructuredSSRequest(ProcessUnstructuredSSRequest procUnstrReqInd) {
//        NetworkIdState networkIdState = this.mapStack.getMAPProvider().getNetworkIdState(0);
//        if (!(networkIdState == null || networkIdState.isAvailavle() && networkIdState.getCongLevel() == 0)) {
//            // congestion or unavailable
//            logger.warn("onProcessUnstructuredSSRequest Congestion - onUnstructuredSSRequest: networkIdState=" + networkIdState);
//            try {
//                Thread.sleep(1000);
//            } catch (InterruptedException e) {
//                // TODO Auto-generated catch block
//                e.printStackTrace();
//            }
//        }

        if (logger.isDebugEnabled()) {
            logger.debug(String.format("onProcessUnstructuredSSRequestIndication for DialogId=%d", procUnstrReqInd
                    .getMAPDialog().getLocalDialogId()));
        }
        try {
            long invokeId = procUnstrReqInd.getInvokeId();

            USSDString ussdStrObj = this.mapProvider.getMAPParameterFactory().createUSSDString(
                    "USSD String : Hello World <CR> 1. Balance <CR> 2. Texts Remaining");
            CBSDataCodingScheme ussdDataCodingScheme = new CBSDataCodingSchemeImpl(0x0F);
            MAPDialogSupplementary dialog = procUnstrReqInd.getMAPDialog();

            dialog.setUserObject(invokeId);

            ISDNAddressString msisdn = this.mapProvider.getMAPParameterFactory().createISDNAddressString(
                    AddressNature.international_number, NumberingPlan.ISDN, "31628838002");

            dialog.addUnstructuredSSRequest(ussdDataCodingScheme, ussdStrObj, null, msisdn);
            dialog.send();
        } catch (MAPException e) {
            logger.error("Error while sending UnstructuredSSRequest ", e);
        }
    }
299424
@Override
  public void recordProcessInstanceStart(ExecutionEntity processInstance, FlowElement startElement) {
    if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
      HistoricProcessInstanceEntity historicProcessInstance = getHistoricProcessInstanceEntityManager().create(processInstance); 
      historicProcessInstance.setStartActivityId(startElement.getId());

      // Insert historic process-instance
      getHistoricProcessInstanceEntityManager().insert(historicProcessInstance, false);
      
      // Fire event
      ActivitiEventDispatcher activitiEventDispatcher = getEventDispatcher();
      if (activitiEventDispatcher != null && activitiEventDispatcher.isEnabled()) {
        activitiEventDispatcher.dispatchEvent(
            ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_PROCESS_INSTANCE_CREATED, historicProcessInstance));
      }

    }
  }
877594
public static AuthorizationDto fromAuthorization(Authorization dbAuthorization, ProcessEngineConfiguration engineConfiguration) {
    AuthorizationDto authorizationDto = new AuthorizationDto();

    authorizationDto.setId(dbAuthorization.getId());
    authorizationDto.setType(dbAuthorization.getAuthorizationType());

    Permission[] dbPermissions = getPermissions(dbAuthorization, engineConfiguration);
    authorizationDto.setPermissions(PermissionConverter.getNamesForPermissions(dbAuthorization, dbPermissions));

    authorizationDto.setUserId(dbAuthorization.getUserId());
    authorizationDto.setGroupId(dbAuthorization.getGroupId());
    authorizationDto.setResourceType(dbAuthorization.getResourceType());
    authorizationDto.setResourceId(dbAuthorization.getResourceId());

    return authorizationDto;
  }
339254
public void putTransient(DbEntity e) {
    CachedDbEntity cachedDbEntity = new CachedDbEntity();
    cachedDbEntity.setEntity(e);
    cachedDbEntity.setEntityState(TRANSIENT);
    putInternal(cachedDbEntity);
  }
73224
@Override
    public void begin()
    {
        if (isActive())
        {
            throw new IllegalStateException("Transaction is already active");
        }
        else
        {
            this.coordinator = ((EntityManagerImpl) entityManager).getPersistenceDelegator().getCoordinator();
            ((EntityManagerImpl) entityManager).getPersistenceDelegator().begin(); // transaction
                                                                                   // de-marcation.
            this.coordinator.coordinate(TxAction.BEGIN);
        }
    }