public void clientClosed(Client src) { log.debug("disconnect session for " + user.getUserId()); for (int i = 0; i < queues.length; i++) { if (queues[i] != null) { try { queues[i].close(); } catch (Throwable t) { log.info(t); } queues[i] = null; } } for (int i = 0; i < dbs.length; i++) { if (dbs[i] != null) { try { dbs[i].close(); } catch (Throwable t) { log.info(t); } dbs[i] = null; } } dbProvider = null; user = null; }
public void unlock(String id, boolean force, UserInformation user) throws MorseException { if (log.t4()) log.info("UNLOCK: " + id + ' ' + user); ObjectUtil.assetId(id); if (!force && user == null) throw new MorseException(MorseException.UNKNOWN_USER); // create lock file ObjectFileStore ofs = driver.getFileStore().get(IType.TYPE_OBJECT)[0]; try { if (log.t4()) log.debug("xLOCK: " + id + ' ' + user); if (!ofs.lock(id)) throw new MorseException(MorseException.ERROR); } catch (IOException e) { throw new MorseException(MorseException.ERROR, e); } try { IQueryResult res = fetch(id, user, false); if (!res.next()) { res.close(); throw new MorseException(MorseException.ACCESS_DENIED, id); } String lock = res.getString(IAttribute.M_LOCK); res.close(); if (!force && ObjectUtil.validateId(lock) && !lock.equals(user.getUserId())) { throw new MorseException(MorseException.NOT_OWNER, id); } Properties p = new Properties(); Reader reader = ofs.getReader(id); p.load(reader); reader.close(); p.setProperty(IAttribute.M_LOCK, ""); Writer writer = ofs.getWriter(id); p.store(writer); writer.close(); } catch (Exception e) { log.error(e); } finally { if (log.t4()) log.debug("xUNLOCK: " + id + ' ' + user); ofs.unlock(id); } }