/** * Provides an {@link EventContext} instance without reloading the session, * via {@link LocalAdmin#getEventContextQuiet()}. * @return the event context */ public EventContext getEventContext() { final LocalAdmin admin = (LocalAdmin) sf.getAdminService(); final EventContext ec = admin.getEventContextQuiet(); return ec; } }
@Transactional(readOnly = false) public Object doWork(org.hibernate.Session session, ServiceFactory sf) { return ((LocalAdmin) sf.getAdminService()).checkPassword( _principal.getName(), credentials, false); } });
/** * To prevent having the transaction rolled back, this method returns null * rather than throw an exception. */ private ExperimenterGroup _getDefaultGroup(ServiceFactory sf, String name) { LocalAdmin admin = (LocalAdmin) sf.getAdminService(); try { Experimenter exp = admin.userProxy(name); ExperimenterGroup grp = admin.getDefaultGroup(exp.getId()); return grp; } catch (Exception e) { log.warn("Exception while running " + "executeDefaultGroup", e); return null; } }
@Transactional(readOnly=true) public Object doWork(Session session, ServiceFactory sf) { LocalAdmin admin = (LocalAdmin) sf.getAdminService(); EventContext ec = admin.getEventContextQuiet(); long guestId = admin.getSecurityRoles().getGuestId(); return ec.getCurrentUserId().equals(guestId); } });
List<Object> list = new ArrayList<Object>(); LocalAdmin admin = (LocalAdmin) sf.getAdminService(); final List<Long> memberOfGroupsIds = admin.getMemberOfGroupIds(exp); final List<Long> leaderOfGroupsIds = admin.getLeaderOfGroupIds(exp); final List<String> userRoles = admin.getUserRoles(exp); final Session reloaded = sessionProvider.findSessionById(session.getId(), sf); final Experimenter sudoer = reloaded.getSudoer(); boolean hasAdminPrivileges = memberOfGroupsIds.contains(roles.getSystemGroupId()); if (sudoer != null) { hasAdminPrivileges = hasAdminPrivileges && admin.getMemberOfGroupIds(sudoer).contains(roles.getSystemGroupId());
final EventContext ec = admin.getEventContext(); if (!(admin.canAnnotate(parentObject) || parentObjectGroupId == roles.getUserGroupId() && ec.getCurrentGroupPermissions().isGranted(
exp = new Experimenter(ec.getCurrentUserId(), false); } else { exp = admin.userProxy(ec.getCurrentUserId()); sudoer = new Experimenter(sudoerId, false); } else { sudoer = admin.userProxy(sudoerId); callGroup = admin.groupProxy(groupId); eventGroup = callGroup; callPerms = callGroup.getDetails().getPermissions(); eventGroup = admin.getGroup(eventGroupId); callGroup = new ExperimenterGroup(groupId, false); callPerms = Permissions.DUMMY;
public void runAsAdmin() { String dsQuery; if (force) { dsQuery = dsNotOwnQuery; p.addLong("owner", iAdmin.getEventContext().getCurrentUserId()); } else { dsQuery = dsAllQuery; } rv.addAll(iQuery.findAllByQuery(dsQuery, p)); // TODO What about categories of other users? }
/** * Counts via {@link LocalAdmin#getLockingIds(Session, IObject)} all the * items which entities which link to the given object. * * @param object */ @SuppressWarnings("unchecked") void count(final IObject object) { Map<Long, Map<String, Long>> id_class_id = map.get(object.getClass() .getName()); if (id_class_id == null) { id_class_id = new HashMap<Long, Map<String, Long>>(); map.put(object.getClass().getName(), id_class_id); } if (!id_class_id.containsKey(object.getId())) { id_class_id.put(object.getId(), admin.getLockingIds( (Class<IObject>) object.getClass(), object.getId(), null)); } } }
@Transactional(readOnly = true) public Object doWork(Session session, ServiceFactory sf) { return ((LocalAdmin) sf.getAdminService()).getEventContextQuiet(); } });
@Transactional(readOnly = true) public Object doWork(org.hibernate.Session session, ServiceFactory sf) { try { return ((LocalAdmin) sf.getAdminService()).checkPassword( _principal.getName(), credentials, true); } catch (Exception e) { // thrown if ldap is trying to create a user; // primarily a performance optimization to prevent // creating an event, etc. for all the password // checks which will *not* try to create a user. return null; } } });
@Transactional(readOnly=true) public Object doWork(Session session, ServiceFactory sf) { return ((LocalAdmin) sf.getAdminService()).getEventContextQuiet(); } });
@Transactional(readOnly = true) public Object doWork(Session session, ServiceFactory sf) { return ((LocalAdmin) sf.getAdminService()).getEventContextQuiet(); } });
@Transactional(readOnly=true) public Object doWork(org.hibernate.Session session, ServiceFactory sf) { return ((LocalAdmin) sf.getAdminService()).getEventContextQuiet(); } });
@Transactional(readOnly = false) public Object doWork(Session session, ServiceFactory sf) { try { EventContext ec = ((LocalAdmin) sf.getAdminService()) .getEventContextQuiet(); Deletion d = executor.getContext().getBean( Deletion.class.getName(), Deletion.class); final SetMultimap<String, Long> toDelete = HashMultimap.create(); toDelete.put("OriginalFile", id); d.deleteFiles(toDelete); return null; } catch (ome.conditions.ValidationException ve) { log.debug("ValidationException on delete", ve); } catch (Throwable e) { log.warn("Throwable while deleting script " + id, e); } return null; }
@Transactional(readOnly = false) public Object doWork(Session session, ServiceFactory sf) { final ome.system.EventContext eventContext; if (effectiveEventContext == null) { eventContext = ((LocalAdmin) sf.getAdminService()).getEventContextQuiet(); } else { eventContext = effectiveEventContext; /* sudo */ } for (CheckedPath checked : dirs) { try { repo.makeDir(checked, parents, session, sf, getSqlAction(), eventContext); } catch (ServerError se) { throw new Rethrow(se); } } return null; } });
.getAdminService()).getEventContextQuiet(); if (!ec.isCurrentUserAdmin()) { throw helper.cancel(new ERR(), null, "no-permissions",