@Override public String getDescription() { return "create another: " + this.trigger.getDescription(); }
@Override public String toString() { return "Trigger Id: " + getTriggerId() + ", Description: " + getDescription(); }
private void ajaxExpireTrigger(final HttpServletRequest req, final Map<String, Object> ret, final User user) throws ServletException, TriggerManagerException { final int triggerId = getIntParam(req, "triggerId"); final Trigger t = this.triggerManager.getTrigger(triggerId); if (t == null) { ret.put("message", "Trigger with ID " + triggerId + " does not exist"); ret.put("status", "error"); return; } this.triggerManager.expireTrigger(triggerId); logger.info("User '" + user.getUserId() + " has removed trigger " + t.getDescription()); ret.put("status", "success"); ret.put("message", "trigger " + triggerId + " removed from Schedules."); return; }
/** * TODO: Don't understand why we need synchronized here. */ @Override public synchronized void addTrigger(final Trigger t) throws TriggerLoaderException { logger.info("Inserting trigger " + t.toString() + " into db."); final SQLTransaction<Long> insertAndGetLastID = transOperator -> { transOperator.update(ADD_TRIGGER, DateTime.now().getMillis()); // This commit must be called in order to unlock trigger table and have last insert ID. transOperator.getConnection().commit(); return transOperator.getLastInsertId(); }; try { final long id = this.dbOperator.transaction(insertAndGetLastID); t.setTriggerId((int) id); updateTrigger(t); logger.info("uploaded trigger " + t.getDescription()); } catch (final SQLException ex) { logger.error("Adding Trigger " + t.getTriggerId() + " failed."); throw new TriggerLoaderException("trigger id is not properly created.", ex); } }
private void onTriggerPause(final Trigger t) throws TriggerManagerException { final List<TriggerAction> expireActions = t.getExpireActions(); for (final TriggerAction action : expireActions) { try { logger.info("Doing expire actions for " + action.getDescription() + " for " + t); action.doAction(); } catch (final Exception e) { logger.error("Failed to do expire action " + action.getDescription() + " for " + t, e); } catch (final Throwable th) { logger.error("Failed to do expire action " + action.getDescription() + " for " + t, th); } } logger.info("Pausing Trigger " + t.getDescription()); t.setStatus(TriggerStatus.PAUSED); try { TriggerManager.this.triggerLoader.updateTrigger(t); } catch (final TriggerLoaderException e) { throw new TriggerManagerException(e); } }
@Override public String getDescription() { return "create another: " + this.trigger.getDescription(); }
@Override public String getDescription() { return "create another: " + trigger.getDescription(); }
@Override public String toString() { return "Trigger Id: " + getTriggerId() + ", Description: " + getDescription(); }
private void ajaxExpireTrigger(HttpServletRequest req, Map<String, Object> ret, User user) throws ServletException, TriggerManagerException{ int triggerId = getIntParam(req, "triggerId"); Trigger t = triggerManager.getTrigger(triggerId); if(t == null) { ret.put("message", "Trigger with ID " + triggerId + " does not exist"); ret.put("status", "error"); return; } // if(!hasPermission(project, user, Type.SCHEDULE)) { // ret.put("status", "error"); // ret.put("message", "Permission denied. Cannot remove trigger with id " + triggerId); // return; // } triggerManager.expireTrigger(triggerId); logger.info("User '" + user.getUserId() + " has removed trigger " + t.getDescription()); // projectManager.postProjectEvent(project, EventType.SCHEDULE, user.getUserId(), "Schedule " + sched.toString() + " has been removed."); ret.put("status", "success"); ret.put("message", "trigger " + triggerId + " removed from Schedules."); return; }
private synchronized void addTrigger(Connection connection, Trigger t, EncodingType encType) throws TriggerLoaderException { QueryRunner runner = new QueryRunner(); long id; try { runner.update(connection, ADD_TRIGGER, DateTime.now().getMillis()); connection.commit(); id = runner.query(connection, LastInsertID.LAST_INSERT_ID, new LastInsertID()); if (id == -1l) { logger.error("trigger id is not properly created."); throw new TriggerLoaderException("trigger id is not properly created."); } t.setTriggerId((int)id); updateTrigger(t); logger.info("uploaded trigger " + t.getDescription()); } catch (SQLException e) { throw new TriggerLoaderException("Error creating trigger.", e); } }
/** * TODO: Don't understand why we need synchronized here. */ @Override public synchronized void addTrigger(final Trigger t) throws TriggerLoaderException { logger.info("Inserting trigger " + t.toString() + " into db."); final SQLTransaction<Long> insertAndGetLastID = transOperator -> { transOperator.update(ADD_TRIGGER, DateTime.now().getMillis()); // This commit must be called in order to unlock trigger table and have last insert ID. transOperator.getConnection().commit(); return transOperator.getLastInsertId(); }; try { final long id = this.dbOperator.transaction(insertAndGetLastID); t.setTriggerId((int) id); updateTrigger(t); logger.info("uploaded trigger " + t.getDescription()); } catch (final SQLException ex) { logger.error("Adding Trigger " + t.getTriggerId() + " failed."); throw new TriggerLoaderException("trigger id is not properly created.", ex); } }
private void onTriggerPause(final Trigger t) throws TriggerManagerException { final List<TriggerAction> expireActions = t.getExpireActions(); for (final TriggerAction action : expireActions) { try { logger.info("Doing expire actions for " + action.getDescription() + " for " + t); action.doAction(); } catch (final Exception e) { logger.error("Failed to do expire action " + action.getDescription() + " for " + t, e); } catch (final Throwable th) { logger.error("Failed to do expire action " + action.getDescription() + " for " + t, th); } } logger.info("Pausing Trigger " + t.getDescription()); t.setStatus(TriggerStatus.PAUSED); try { TriggerManager.this.triggerLoader.updateTrigger(t); } catch (final TriggerLoaderException e) { throw new TriggerManagerException(e); } }
logger.info("Ready to insert trigger " + t.getDescription()); triggerLoader.addTrigger(t);