public DeleteLogsMessage(Object source, List<Long> fileIds) { super(source); for (Long fileId : fileIds) { messages.add(new DeleteLogMessage(source, fileId)); } }
public void closeParsedFiles() { for (ParserOpenFileMessage file : openFiles) { log.debug("Closing file: " + file); file.close(); } openFiles.clear(); } }
/** * If a {@link PushContextMessage} was sent, send a {@link PopContextMessage} * so that the context for following actions are not polluted. */ void logout() throws Throwable { if (c != null) { ctx.publishMessage(new ContextMessage.Pop(this ,c)); } } }
DeleteLogsMessage dlms = new DeleteLogsMessage(this, orderedIds); try { ctx.publishMessage(dlms); for (DeleteLogMessage dlm : dlms.getMessages()) { if (dlm.count() == 0) { String filePath = afs.getFilesPath(dlm.getFileId()); addLocalFile(new File(filePath), dlm.getFileId());
private Map<String, Long> performRun(Check c) { // Perform the operation across all groups. Map<String, Long> counts = null; Map<String, String> grpCtx = new HashMap<String, String>(); grpCtx.put("omero.group", "-1"); try { ctx.publishMessage(new ContextMessage.Push(this, grpCtx)); try { counts = c.run(osf.getSession(), em); } finally { ctx.publishMessage(new ContextMessage.Pop(this, grpCtx)); } } catch (Throwable t) { log.error("Could not perform check!", t); throw new InternalException("Could not perform check! See server logs"); } return counts; }
private void eventlog(long id, String perms) { EventLogMessage elm = new EventLogMessage(this, String.format( "CHMOD(%s)", perms), ExperimenterGroup.class, Collections.singletonList(id)); try { ctx.publishMessage(elm); } catch (Throwable t) { if (t instanceof RuntimeException) { throw (RuntimeException) t; } else { throw new RuntimeException(t); } } }
/** */ public void onApplicationEvent(ApplicationEvent event) { if (event instanceof UserGroupUpdateEvent) { cache.updateEvent((UserGroupUpdateEvent) event); } else if (event instanceof DestroySessionMessage) { sessionProvider.executeCloseSession(((DestroySessionMessage) event).getSessionId()); } }
public void onApplicationEvent(InternalMessage im) { if (im instanceof DeleteLogMessage) { handleDLMs(Arrays.asList((DeleteLogMessage) im)); } else if (im instanceof DeleteLogsMessage) { handleDLMs(((DeleteLogsMessage) im).getMessages()); } }
/** * Send a {@link PushContextMessage} to apply this context if not null. */ void login() throws Throwable { if (c != null) { h.debug("Login: %s", c); ctx.publishMessage(new ContextMessage.Push(this, c)); } }
protected void cleanup() { Set<RegisterServiceCleanupMessage> cleanups = cd.emptyCleanups(); for (RegisterServiceCleanupMessage registerServiceCleanupMessage : cleanups) { try { log.info("Cleanup: " + registerServiceCleanupMessage.resource); registerServiceCleanupMessage.close(); } catch (Exception e) { log.warn("Error while cleaning up", e); } } }
protected Boolean loginAttempt(String user, Boolean success) { try { this.ctx.publishMessage(new LoginAttemptMessage(this, user, success)); } catch (Throwable e) { log.error("LoginAttemptMessage error", e); } return success; }
@Override public void onApplicationEvent(EventLogsMessage elm) { if (!isEnabled()) { return; } if (isEmpty(this.queryString)) { return; } Collection<EventLog> matches = elm.matches(klass.getName(), action); if (matches.isEmpty()) { return; } sendEmail(matches); }
/** * Publishes a {@link ReindexMessage} which will get processed * asynchronously. */ protected <T extends IObject> void reindexAll(List<T> list) { if (publisher == null) { throw new ApiUsageException( "Bridge is not configured for sending messages."); } for (T object : list) { if (object == null || object.getId() == null) { throw new ApiUsageException("Object cannot be null"); } } final ReindexMessage<T> rm = new ReindexMessage<T>(this, list); publisher.publishEvent(rm); }
private void internalRemove(String uuid, String reason) { if (!sessions.containsKey(uuid)) { log.warn("Session not in cache: " + uuid); return; // EARLY EXIT! } log.info("Destroying session " + uuid + " due to : " + reason); // Announce to all callbacks. Set<SessionCallback> cbs = sessionCallbackMap.get(uuid); if (cbs != null) { for (SessionCallback cb : cbs) { try { cb.close(); } catch (Exception e) { final String msg = "SessionCallback %s throw exception for session %s"; log.warn(String.format(msg, cb, uuid), e); } } } // Announce to all listeners try { context.publishEvent(new DestroySessionMessage(this, uuid)); } catch (RuntimeException re) { final String msg = "Session listener threw an exception for session %s"; log.warn(String.format(msg, uuid), re); } ehmanager.removeCache("memory:" + uuid); ehmanager.removeCache("ondisk:" + uuid); sessions.remove(uuid); }
public void clearLogs() { if (log.isDebugEnabled()) { log.debug("Clearing EventLogs."); } List<EventLog> logs = getLogs(); if (!logs.isEmpty()) { boolean foundAdminType = false; final Multimap<String, EventLog> map = ArrayListMultimap.create(); for (EventLog el : getLogs()) { String t = el.getEntityType(); if (Experimenter.class.getName().equals(t) || ExperimenterGroup.class.getName().equals(t) || GroupExperimenterMap.class.getName().equals(t)) { foundAdminType = true; } map.put(t, el); } if (ctx == null) { log.error("No context found for publishing"); } else { // publish message if administrative type is modified if (foundAdminType) { this.ctx.publishEvent(new UserGroupUpdateEvent(this)); } this.ctx.publishEvent(new EventLogsMessage(this, map)); } } cd.clearLogs(); }
try { try { applicationContext.publishMessage(new ContextMessage.Push(this, groupContext)); } catch (Throwable t) { LOGGER.error("could not publish context change push", t); } finally { try { applicationContext.publishMessage(new ContextMessage.Pop(this, groupContext)); } catch (Throwable t) { LOGGER.error("could not publish context change pop", t);
/** * Publish database changes to the event log. * @param context the context for publishing the application event * @param action the name of the change action * @param className the class of objects that were changed * @param ids the IDs of the objects that were changed */ public void publishEventLog(ApplicationContext context, String action, String className, Collection<Long> ids) { final Class<? extends IObject> actualClass; try { actualClass = Class.forName(className).asSubclass(IObject.class); } catch (ClassNotFoundException cnfe) { throw new InternalException("reference to unknown model class " + className + ": " + cnfe); } context.publishEvent(new EventLogMessage(this, action, actualClass, ImmutableList.copyOf(ids))); } }
public void onApplicationEvent(InternalMessage event) { try { if (event instanceof UnregisterServantMessage) { UnregisterServantMessage msg = (UnregisterServantMessage) event; Ice.Current curr = msg.getCurrent(); ServantHolder holder = msg.getHolder(); // Using static method since we may not have a clientId // in order to look up the SessionI/ServiceFactoryI SessionI.unregisterServant(curr.id, adapter, holder); } else if (event instanceof FindServiceFactoryMessage) { FindServiceFactoryMessage msg = (FindServiceFactoryMessage) event; Ice.Identity id = msg.getIdentity(); if (id == null) { Ice.Current curr = msg.getCurrent(); id = getServiceFactoryIdentity(curr); } ServiceFactoryI sf = getServiceFactory(id); msg.setServiceFactory(id, sf); } else if (event instanceof DestroySessionMessage) { DestroySessionMessage msg = (DestroySessionMessage) event; reapSession(msg.getSessionId()); } else if (event instanceof ChangeSecurityContextEvent) { ChangeSecurityContextEvent csce = (ChangeSecurityContextEvent) event; checkStatefulServices(csce); } } catch (Throwable t) { throw new MessageException("SessionManagerI.onApplicationEvent", t); } }
try { try { applicationContext.publishMessage(new ContextMessage.Push(this, groupContext)); } catch (Throwable t) { final String errorMessage = "could not publish context change push"; applicationContext.publishMessage(new ContextMessage.Pop(this, groupContext)); } catch (Throwable t) { final String errorMessage = "could not publish context change pop";
/** * Actually perform the password change in the database and log the event against the user. * @param user the name of the user whose password is to be changed * @param password the password to prepare for storing in the table * @param method how the given password is to be stored * @throws PasswordChangeException if the operation failed */ protected void changePassword(String user, String password, PasswordUtil.METHOD method) throws PasswordChangeException { final Long id = util.userId(user); if (id == null) { throw new PasswordChangeException("Couldn't find id: " + user); } util.changeUserPasswordById(id, password, method); final EventLogMessage event = new EventLogMessage(this, "PASSWORD", Experimenter.class, Collections.singletonList(id)); ctx.publishEvent(event); } }