use of javax.ejb.Asynchronous in project ART-TIME by Artezio.
the class MailingEngine method send.
@Asynchronous
public void send(String senderId, String recipientId, Mail mail) throws MessagingException {
InternetAddress[] addressesTo = InternetAddress.parse(recipientId, false);
if (addressesTo.length > 0) {
MimeMessage mimeMessage = new MimeMessage(session);
mimeMessage.setSubject(mail.getSubject(), "UTF-8");
mimeMessage.setText(mail.getText(), "UTF-8", "html");
mimeMessage.setSentDate(new Date());
mimeMessage.setRecipients(javax.mail.Message.RecipientType.TO, addressesTo);
mimeMessage.setFrom(new InternetAddress(senderId));
Transport.send(mimeMessage);
}
}
use of javax.ejb.Asynchronous in project quickstart by wildfly.
the class AsynchronousAccessBean method longerRunning.
@Asynchronous
@Override
public Future<String> longerRunning(long sleepTime) {
LOGGER.info("Will wait for " + sleepTime + "ms");
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
}
LOGGER.info("returning the result");
return new AsyncResult<>("returning at " + new Date() + ", duration was " + sleepTime + "ms");
}
use of javax.ejb.Asynchronous in project dataverse by IQSS.
the class IndexAsync method indexRoles.
@Asynchronous
public void indexRoles(Collection<DvObject> dvObjects) {
for (DvObject dvObject : dvObjects) {
IndexResponse indexResponse = solrIndexService.indexPermissionsOnSelfAndChildren(dvObject);
logger.fine("output from permission indexing operations (dvobject " + dvObject.getId() + ": " + indexResponse);
}
}
use of javax.ejb.Asynchronous in project dataverse by IQSS.
the class BatchServiceBean method processFilePath.
@Asynchronous
public void processFilePath(String fileDir, String parentIdtf, DataverseRequest dataverseRequest, Dataverse owner, ImportUtil.ImportType importType, Boolean createDV) {
logger.info("BEGIN IMPORT");
PrintWriter validationLog = null;
PrintWriter cleanupLog = null;
try {
JsonArrayBuilder status = Json.createArrayBuilder();
Date timestamp = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
validationLog = new PrintWriter(new FileWriter("../logs/validationLog" + formatter.format(timestamp) + ".txt"));
cleanupLog = new PrintWriter(new FileWriter("../logs/cleanupLog" + formatter.format(timestamp) + ".txt"));
File dir = new File(fileDir);
if (dir.isDirectory()) {
for (File file : dir.listFiles()) {
if (!file.isHidden()) {
if (file.isDirectory()) {
try {
status.add(handleDirectory(dataverseRequest, file, importType, validationLog, cleanupLog, createDV));
} catch (ImportException e) {
logger.log(Level.SEVERE, "Exception in handleDirectory() for " + file.getName(), e);
}
} else {
try {
status.add(importService.handleFile(dataverseRequest, owner, file, importType, validationLog, cleanupLog));
} catch (ImportException e) {
logger.log(Level.SEVERE, "Exception in handleFile() for " + file.getName(), e);
}
}
}
}
} else {
status.add(importService.handleFile(dataverseRequest, owner, dir, importType, validationLog, cleanupLog));
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Exception in processFilePath()", e);
} finally {
validationLog.close();
cleanupLog.close();
}
logger.info("END IMPORT");
}
use of javax.ejb.Asynchronous in project dataverse by IQSS.
the class WorkflowServiceBean method rollback.
@Asynchronous
private void rollback(Workflow wf, WorkflowContext ctxt, Failure failure, int lastCompletedStepIdx) {
ctxt = refresh(ctxt);
final List<WorkflowStepData> steps = wf.getSteps();
for (int stepIdx = lastCompletedStepIdx; stepIdx >= 0; --stepIdx) {
WorkflowStepData wsd = steps.get(stepIdx);
WorkflowStep step = createStep(wsd);
try {
logger.log(Level.INFO, "Workflow {0} step {1}: Rollback", new Object[] { ctxt.getInvocationId(), stepIdx });
rollbackStep(step, ctxt, failure);
} catch (Exception e) {
logger.log(Level.WARNING, "Workflow " + ctxt.getInvocationId() + " step " + stepIdx + ": Rollback error: " + e.getMessage(), e);
}
}
logger.log(Level.INFO, "Removing workflow lock");
try {
engine.submit(new RemoveLockCommand(ctxt.getRequest(), ctxt.getDataset(), DatasetLock.Reason.Workflow));
// Corner case - delete locks generated within this same transaction.
Query deleteQuery = em.createQuery("DELETE from DatasetLock l WHERE l.dataset.id=:id AND l.reason=:reason");
deleteQuery.setParameter("id", ctxt.getDataset().getId());
deleteQuery.setParameter("reason", DatasetLock.Reason.Workflow);
deleteQuery.executeUpdate();
} catch (CommandException ex) {
logger.log(Level.SEVERE, "Error restoring dataset locks state after rollback: " + ex.getMessage(), ex);
}
}
Aggregations