protected String idToUuid(long shareId) { Session s = iQuery.get(Session.class, shareId); return s.getUuid(); }
@RolesAllowed("user") public ExperimenterGroup groupProxy(Long id) { if (id == null) { throw new ApiUsageException("Id argument cannot be null."); } ExperimenterGroup g = iQuery.get(ExperimenterGroup.class, id); return g; }
@RolesAllowed("system") @Transactional(readOnly = false) @Deprecated public void setDN(Long experimenterID, String dn) { Experimenter experimenter = iQuery.get(Experimenter.class, experimenterID); experimenter.setLdap(StringUtils.isNotBlank(dn)); iUpdate.saveObject(experimenter); }
@RolesAllowed("user") public Experimenter userProxy(final Long id) { if (id == null) { throw new ApiUsageException("Id argument cannot be null."); } Experimenter e = iQuery.get(Experimenter.class, id); return e; }
@Override @RolesAllowed("user") @Transactional(readOnly = true) public Collection retrieveCollection(IObject arg0, String arg1, Parameters arg2) { IObject context = iQuery.get(arg0.getClass(), arg0.getId()); Collection c = (Collection) context.retrieve(arg1); // FIXME not // type.o.null safe iQuery.initialize(c); return c; }
public void runAsAdmin() { final Share share = iQuery.get(Share.class, shareId); CommentAnnotation comment = new CommentAnnotation(); comment.setTextValue(commentText); comment.setNs(NS_COMMENT); share.linkAnnotation(comment); iUpdate.flush(); rv[0] = iQuery.get(CommentAnnotation.class, comment.getId()); }});
@RolesAllowed("user") @Transactional(readOnly = false) public void changeOwner(IObject iObject, String omeName) { // should take an Owner IObject copy = iQuery.get(iObject.getClass(), iObject.getId()); Experimenter owner = userProxy(omeName); copy.getDetails().setOwner(owner); iUpdate.saveObject(copy); }
protected void storeShareData(long shareId, ShareData data) { // This should reload the object already in the first-cache Share share = iQuery.get(Share.class, shareId); this.sec.doAction(new SecureStore(data), share); adminFlush(); }
file = iQuery.get(OriginalFile.class, fileId);
@RolesAllowed("user") public boolean canAnnotate(final IObject obj) { if (obj == null) { throw new ApiUsageException("Argument cannot be null"); } final Class<? extends IObject> c = Utils.trueClass(obj.getClass()); IObject trusted = iQuery.get(c, obj.getId()); return aclVoter.allowAnnotate(trusted, trusted.getDetails()); }
/** * Queries the LDAP server and returns the DN for the specified OMERO user * ID. The LDAP server is queried and the DN returned only for IDs that have * the <code>ldap</code> flag enabled. * * @param id * The user ID. * @return The DN as a String. Null if user isn't from LDAP. */ public String lookupLdapAuthExperimenter(Long id) { // First, check that the supplied user ID is an LDAP user String dn = null; Experimenter experimenter = iQuery.get(Experimenter.class, id); if (experimenter.getLdap()) { dn = findDN(experimenter.getOmeName()); } return dn; }
@RolesAllowed("user") public boolean canUpdate(final IObject obj) { if (obj == null) { throw new ApiUsageException("Argument cannot be null"); } final Class<? extends IObject> c = Utils.trueClass(obj.getClass()); IObject trusted = iQuery.get(c, obj.getId()); return aclVoter.allowUpdate(trusted, trusted.getDetails()); }
@RolesAllowed("user") @Transactional(readOnly = false) public CommentAnnotation addComment(final long shareId, @NotNull final String commentText) { getShareIfAccessible(shareId); ExperimenterGroup group = iQuery.get(Share.class, shareId).getGroup(); final CommentAnnotation[] rv = new CommentAnnotation[1]; sec.runAsAdmin(group, new AdminAction(){ public void runAsAdmin() { final Share share = iQuery.get(Share.class, shareId); CommentAnnotation comment = new CommentAnnotation(); comment.setTextValue(commentText); comment.setNs(NS_COMMENT); share.linkAnnotation(comment); iUpdate.flush(); rv[0] = iQuery.get(CommentAnnotation.class, comment.getId()); }}); return rv[0]; }
@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); } } } }
@RolesAllowed("user") public void deleteSettings(final long imageId) { Image i = iQuery.get(Image.class, imageId); throwSecurityViolationIfNotAllowed(i); final Session session = sf.getSession(); sec.runAsAdmin(new AdminAction() { public void runAsAdmin() { List<Object[]> rdefs = iQuery.projection( SETTINGSID_QUERY, new Parameters().addId(imageId)); for (Object[] rv: rdefs) { Long rid = (Long) rv[0]; Long qid = (Long) rv[1]; Query q = session.createQuery("delete ChannelBinding cb where cb.renderingDef.id = :rid"); q.setParameter("rid", rid); q.executeUpdate(); q = session.createQuery("delete RenderingDef r where r.id = :rid"); q.setParameter("rid", rid); q.executeUpdate(); q = session.createQuery("delete QuantumDef q where q.id = :qid"); q.setParameter("qid", qid); q.executeUpdate(); } } }); }
@RolesAllowed("user") public void deleteChannels(final long imageId) { Image i = iQuery.get(Image.class, imageId); throwSecurityViolationIfNotAllowed(i); final Session session = sf.getSession(); sec.runAsAdmin(new AdminAction() { public void runAsAdmin() { List<Object[]> channels = iQuery.projection( CHANNELID_QUERY, new Parameters().addId(imageId)); for (Object[] rv: channels) { Long chid = (Long) rv[0]; Long siid = (Long) rv[1]; Long lcid = (Long) rv[2]; execute(session, chid, "delete Channel ch where ch.id = :id"); execute(session, siid, "delete StatsInfo si where si.id = :id"); List<Object[]> remainingChannels = iQuery.projection( "select ch.id from LogicalChannel lc join lc.channels ch " + "where lc.id = :id", new Parameters().addId(lcid)); if (remainingChannels.size() == 0) { execute(session, lcid, "delete LogicalChannel lc where lc.id = :id"); } } } }); }
s = iQuery.get(JobStatus.class, s.getId()); } catch (Exception e) { throw new ApiUsageException("Unknown job status: " + s);
@RolesAllowed("user") @Transactional(readOnly = false) public Long copyAndResizeImage(long imageId, Integer sizeX, Integer sizeY, Integer sizeZ, Integer sizeT, List<Integer> channelList, String name, boolean copyStats) { Image iFrom = iQuery.get(Image.class, imageId); Image iTo = new Image(); // Set the image name iTo.setAcquisitionDate(iFrom.getAcquisitionDate()); iTo.setName(name); iTo.setObjectiveSettings(iFrom.getObjectiveSettings()); iTo.setImagingEnvironment(iFrom.getImagingEnvironment()); iTo.setExperiment(iFrom.getExperiment()); iTo.setStageLabel(iFrom.getStageLabel()); iTo.setInstrument(iFrom.getInstrument()); // Copy each Pixels set that the source image has Iterator<Pixels> i = iFrom.iteratePixels(); while (i.hasNext()) { Pixels p = i.next(); Pixels to = _copyAndResizePixels(p.getId(), sizeX, sizeY, sizeZ, sizeT, channelList, null, copyStats); iTo.addPixels(to); } // Save and return our newly created Image Id iTo = iUpdate.saveAndReturnObject(iTo); return iTo.getId(); }
@Override @RolesAllowed("user") public RenderingDef retrieveRndSettings(long pixId) { Long userId = sec.getEffectiveUID(); RenderingDef rd = retrieveRndSettingsFor(pixId, userId); if (rd == null) { final EventContext ec = this.sec.getEventContext(false); final Pixels pixelsObj = this.iQuery.get(Pixels.class, pixId); final boolean isGraphCritical = this.sec.isGraphCritical(pixelsObj.getDetails()); long pixOwner = pixelsObj.getDetails().getOwner().getId(); long currentUser = ec.getCurrentUserId(); if (currentUser != pixOwner) { rd = retrieveRndSettingsFor(pixId, pixOwner); } } return rd; }
final Image i = iQuery.get(Image.class, id);