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) {
}
}
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.