/** Cancels all companions for a given file. */ private synchronized void cancelCompanions(PnfsId pnfsId, String cause) { for (Companion companion : _companions.values()) { if (pnfsId.equals(companion.getPnfsId())) { companion.cancel(cause); } } }
@Override @Transactional(readOnly = true) public Collection<Pin> getPins(PnfsId pnfsId) { PersistenceManager pm = _pmf.getPersistenceManager(); Query query = pm.newQuery(Pin.class, "_pnfsId == :pnfsId"); Collection<Pin> pins = (Collection<Pin>) query.execute(pnfsId.toString()); return pm.detachCopyAll(pins); }
@Override @Transactional(readOnly = true) public Pin getPin(PnfsId pnfsId, String requestId) { PersistenceManager pm = _pmf.getPersistenceManager(); Query query = pm.newQuery(Pin.class, "_pnfsId == :pnfsId && _requestId == :requestId"); query.setUnique(true); Pin pin = (Pin) query.execute(pnfsId.toString(), requestId); return (pin == null) ? null : pm.detachCopy(pin); }
@Override @Transactional public void deletePin(PnfsId pnfsId) { PersistenceManager pm = _pmf.getPersistenceManager(); pm.newQuery(Pin.class, "_pnfsId == :pnfsId").deletePersistentAll(pnfsId.toString()); }
private String toImageName(PnfsId id) { return id.toString(); }