private boolean isPiOf(ExperimenterGroup group) { if (group == null) { return true; } EventContext ec = getEventContext(); List<Long> piOf = ec.getLeaderOfGroupsList(); return piOf.contains(group.getId()); }
public void setGroup(ExperimenterGroup group, Permissions p) { this.group = group; setGroupPermissions(p); if (this.cgId.equals(group.getId())) { // Do nothing. } else { this.cgId = group.getId(); this.cgName = null; // If unloaded or group.id < -1 these will remain null if (group.isLoaded()) { this.cgName = group.getName(); } } }
public void toString(StringBuilder sb) { sb.append(";perm="); sb.append(_perms == null ? null : _perms.toString()); if (_externalInfo != null) { sb.append(";external=" + _externalInfo.getId()); } sb.append("user="); sb.append(_owner == null ? null : _owner.getId()); sb.append(";group="); sb.append(_group == null ? null : _group.getId()); sb.append(";create="); sb.append(_creation == null ? null : _creation.getId()); sb.append(";update="); sb.append(_update == null ? null : _update.getId()); }
public Long getCurrentGroupId() { return session.getDetails().getGroup().getId(); }
@Transactional(readOnly = true) public Object doWork(Session session, ServiceFactory sf) { final ExperimenterGroup group = sf.getQueryService().findByQuery( "select p.details.group from Pixels p where p.id = :id", new ome.parameters.Parameters().addId(mpm.pixelsID)); return group.getId(); } });
public boolean isInUserGroup(Details d) { if (d == null || d.getGroup() == null) { return false; } Long groupId = d.getGroup().getId(); return isInUserGroup(groupId); } }
boolean leader(Details d, EventContext c) { Long g = d.getGroup() == null ? null : d.getGroup().getId(); return leader(g, c); }
public boolean isInSystemGroup(Details d) { if (d == null || d.getGroup() == null) { return false; } Long groupId = d.getGroup().getId(); return isInSystemGroup(groupId); }
boolean member(Details d, EventContext c) { Long g = d.getGroup() == null ? null : d.getGroup().getId(); return member(g, c); }
private GroupExperimenterMap findLink(ExperimenterGroup group, Experimenter owner) { GroupExperimenterMap m = iQuery.findByQuery( "select m from GroupExperimenterMap m " + "where m.parent.id = :pid " + "and m.child.id = :cid", new Parameters() .addLong("pid", group.getId()) .addLong("cid", owner.getId())); return m; }
@RolesAllowed("user") @Transactional(readOnly = false) public void deleteGroup(ExperimenterGroup group) { adminOrPiOfGroups(adminPrivileges.getPrivilege(AdminPrivilege.VALUE_MODIFY_GROUP), group); final ExperimenterGroup g = groupProxy(group.getId()); getSecuritySystem().runAsAdmin(new AdminAction() { public void runAsAdmin() { iUpdate.deleteObject(g); } }); getBeanHelper().getLogger().info("Deleted group: " + g.getName()); }
OwnerOrGroup(Details d, String prefix) { if (prefix == null) { prefix = ""; } if (d != null) { if (d.getOwner() != null) { Long _id = d.getOwner().getId(); if (_id == null) { throw new ApiUsageException("Id for owner cannot be null."); } id = _id.longValue(); path = prefix + "details.owner.id"; } else if (d.getGroup() != null) { Long _id = d.getGroup().getId(); if (_id == null) { throw new ApiUsageException("Id for group cannot be null."); } id = _id.longValue(); path = prefix + "details.group.id"; } } }
@RolesAllowed("user") @SuppressWarnings("unchecked") @Transactional(readOnly = false) public void moveToCommonSpace(IObject... iObjects) { // ticket:1794 final AdminPrivilege modifyGroup = adminPrivileges.getPrivilege(AdminPrivilege.VALUE_MODIFY_GROUP); for (IObject object : iObjects) { if (object != null) { Long id = object.getId(); Class<IObject> c = (Class<IObject>) Utils.trueClass(object.getClass()); IObject o = iQuery.get(c, id); ExperimenterGroup g = o.getDetails().getGroup(); if (!g.getId().equals(getSecurityRoles().getUserGroupId())) { adminOrPiOfGroups(modifyGroup, g); internalMoveToCommonSpace(o); } } } }
/** * returns the id of the {@link ome.model.meta.ExperimenterGroup group} of this entity, * or null if: (1) the object is null, (2) the {@link Details} is null, (3) the * group is null. * * @param iobject * Can be null. * @return the id or null. */ public static Long nullSafeGroupId(IObject iobject) { if (iobject == null) { return null; } if (iobject.getDetails() == null) { return null; } if (iobject.getDetails().getGroup() == null) { return null; } return iobject.getDetails().getGroup().getId(); }
public long createGroup(ExperimenterGroup group) { group = copyGroup(group); if (group.getDetails().getPermissions() == null) { group.getDetails().setPermissions(Permissions.USER_PRIVATE); } final Session session = sf.getSession(); ExperimenterGroup g = sec.doAction(new SecureMerge(session), group); return g.getId(); }
public long createGroup(String name, Permissions perms, boolean strict, boolean isLdap) { Session s = sf.getSession(); ExperimenterGroup g = groupByName(name, s); if (g == null) { g = new ExperimenterGroup(); g.setName(name); g.setLdap(isLdap); if (perms == null) { perms = Permissions.USER_PRIVATE; // ticket:1434 } g.getDetails().setPermissions(perms); g = (ExperimenterGroup) s.merge(g); } else { if (strict) { throw new ValidationException("Group already exists: " + name); } } return g.getId(); }
public long setStatsInfo(Channel ch, StatsInfo si) { final Details d = ch.getDetails(); final long id = nextValue("seq_statsinfo", 1); _jdbc().update(_lookup("stats_info_creation"), //$NON-NLS-1$ id, Utils.internalForm(d.getPermissions()), si.getGlobalMax(), si.getGlobalMin(), d.getCreationEvent().getId(), d.getGroup().getId(), d.getOwner().getId(), d.getUpdateEvent().getId()); _jdbc().update(_lookup("stats_info_set_on_channel"), //$NON-NLS-1$ id, ch.getId()); return id; }
/** * Method which takes all the fields of the given {@link Details} instance * and sets unloaded proxies of them into the current instance. */ public void shallowCopy(Details copy) { if (copy == null) { throw new IllegalArgumentException("argument may not be null"); } setOwner(copy.getOwner() == null ? null : new Experimenter(copy .getOwner().getId(), false)); setGroup(copy.getGroup() == null ? null : new ExperimenterGroup(copy .getGroup().getId(), false)); setCreationEvent(copy.getCreationEvent() == null ? null : new Event( copy.getCreationEvent().getId(), false)); setPermissions(copy.getPermissions() == null ? null : new Permissions(copy.getPermissions())); setExternalInfo(copy.getExternalInfo() == null ? null : new ExternalInfo(copy.getExternalInfo().getId(), false)); setUpdateEvent(copy.getUpdateEvent() == null ? null : new Event(copy .getUpdateEvent().getId(), false)); _filteredCollections = copy.filteredSet(); }