As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
public class MyJOB extends QuartzJobBean { private ActionService actionService; private AuthenticationComponent authenticationComponent; private TransactionService transactionService; protected void executeInternal(JobExecutionContext jobContext) { Authentication currentAuthentication = getAuthenticationComponent().getCurrentAuthentication(); // authenticate as system user getAuthenticationComponent().setSystemUserAsCurrentUser(); UserTransaction tx = null; try { tx = getTransactionService().getUserTransaction(); tx.begin(); Action myJobEx= getActionService().createAction(MyJOBExecuter.NAME); getActionService().executeAction(myJobEx, null); } catch (Throwable err) { err.printStackTrace(); try { if (tx != null) { tx.rollback(); } } catch (Exception tex) { } } finally { // restore user security context getAuthenticationComponent().setCurrentAuthentication(currentAuthentication); } } public void setAuthenticationComponent(AuthenticationComponent authenticationComponent) { this.authenticationComponent = authenticationComponent; } public AuthenticationComponent getAuthenticationComponent() { return authenticationComponent; } public void setActionService(ActionService actionService) { this.actionService = actionService; } public ActionService getActionService() { return actionService; } public void setTransactionService(TransactionService transactionService) { this.transactionService = transactionService; } public TransactionService getTransactionService() { return transactionService; }
finally { // restore user security context authenticationComponent .setCurrentAuthentication(currentAuthentication); try { if (tx != null) { tx.rollback(); } } catch (Exception tex) { } }