/** * Get the entry with this id, or null if not found. * * @param container * The container id. * @param id * The id. * @return The entry with this id, or null if not found. */ public Entity getResource(String container, String id) { if (container == null) container = ""; Container c = ((Container) m_store.get(container)); if (c == null) return null; return (Entity) c.contained.get(caseId(id)); }
/** * flush */ protected void flush() { Document doc = createDocument(); StorageUtils.writeDocument(doc, m_fileStoragePath); }
/** * Close. */ public void close() { flush(); m_locks.clear(); m_locks = null; m_store.clear(); m_store = null; }
List containers = getAllContainers(); List rv = new Vector();
List containers = getAllContainers(); List rv = new Vector();
/** * Get the entry with this id, or null if not found. * * @param container * The container id. * @param id * The id. * @return The entry with this id, or null if not found. */ public Entity getResource(String container, String id) { if (container == null) container = ""; Container c = ((Container) m_store.get(container)); if (c == null) return null; return (Entity) c.contained.get(caseId(id)); }
/** * Close. */ public void close() { flush(); m_locks.clear(); m_locks = null; m_store.clear(); m_store = null; }
/** * flush */ protected void flush() { Document doc = createDocument(); StorageUtils.writeDocument(doc, m_fileStoragePath); }
/** * Check if a resource by this id exists. * * @param container * The container id. * @param id * The id. * @return true if a resource by this id exists, false if not. */ public boolean checkResource(String container, String id) { if (container == null) container = ""; Container c = ((Container) m_store.get(container)); if (c == null) return false; return c.contained.get(caseId(id)) != null; }
/** * Check if a resource by this id exists. * * @param container * The container id. * @param id * The id. * @return true if a resource by this id exists, false if not. */ public boolean checkResource(String container, String id) { if (container == null) container = ""; Container c = ((Container) m_store.get(container)); if (c == null) return false; return c.contained.get(caseId(id)) != null; }
/** * Remove this entry. * * @param container * The container id. * @param edit * The entry to remove. */ public void removeResource(String container, Edit edit) { if (container == null) container = ""; Container c = ((Container) m_store.get(container)); if (c != null) { // remove from the info store c.contained.remove(caseId(edit.getId())); } // release the lock m_locks.remove(edit.getReference()); }
/** * Remove this entry. * * @param container * The container id. * @param edit * The entry to remove. */ public void removeResource(String container, Edit edit) { if (container == null) container = ""; Container c = ((Container) m_store.get(container)); if (c != null) { // remove from the info store c.contained.remove(caseId(edit.getId())); } // release the lock m_locks.remove(edit.getReference()); }
/** * Commit the changes and release the lock. * * @param container * The container id. * @param edit * The entry to commit. */ public void commitResource(String container, Edit edit) { if (container == null) container = ""; Container c = ((Container) m_store.get(container)); if (c != null) { // make a new Entry from the Edit to update the info store Entity updatedEntry = m_user.newResource(c.container, edit); c.contained.put(caseId(updatedEntry.getId()), updatedEntry); } // release the lock m_locks.remove(edit.getReference()); }
/** * Return a lock on the entry with this id, or null if a lock cannot be made. * * @param container * The container id. * @param id * The id. * @return The locked object with this id, or null if a lock cannot be made. */ public Edit editResource(String container, String id) { if (container == null) container = ""; Container c = ((Container) m_store.get(container)); if (c == null) return null; Entity entry = (Entity) c.contained.get(caseId(id)); if (entry == null) return null; synchronized (m_locks) { // check for a lock in place if (m_locks.get(entry.getReference()) != null) return null; // make an Edit Edit edit = m_user.newResourceEdit(c.container, entry); // store it in the locks m_locks.put(entry.getReference(), edit); return edit; } }
/** * Commit the changes and release the lock. * * @param container * The container id. * @param edit * The entry to commit. */ public void commitResource(String container, Edit edit) { if (container == null) container = ""; Container c = ((Container) m_store.get(container)); if (c != null) { // make a new Entry from the Edit to update the info store Entity updatedEntry = m_user.newResource(c.container, edit); c.contained.put(caseId(updatedEntry.getId()), updatedEntry); } // release the lock m_locks.remove(edit.getReference()); }
/** * Add a new entry with this id. * * @param container * The container id. * @param id * The id. * @param others * Other fields for the newResource call * @return The locked object with this id, or null if the id is in use. */ public Edit putResource(String container, String id, Object[] others) { if (container == null) container = ""; Container c = ((Container) m_store.get(container)); if (c == null) return null; // if it's already defined if (c.contained.get(caseId(id)) != null) return null; // make an Edit Edit edit = m_user.newResourceEdit(c.container, id, others); synchronized (m_locks) { // if it's in the locks (i.e. it's been put() but not committed if (m_locks.get(edit.getReference()) != null) return null; // store it in the locks m_locks.put(edit.getReference(), edit); } return edit; }
/** * Add a new entry with this id. * * @param container * The container id. * @param id * The id. * @param others * Other fields for the newResource call * @return The locked object with this id, or null if the id is in use. */ public Edit putResource(String container, String id, Object[] others) { if (container == null) container = ""; Container c = ((Container) m_store.get(container)); if (c == null) return null; // if it's already defined if (c.contained.get(caseId(id)) != null) return null; // make an Edit Edit edit = m_user.newResourceEdit(c.container, id, others); synchronized (m_locks) { // if it's in the locks (i.e. it's been put() but not committed if (m_locks.get(edit.getReference()) != null) return null; // store it in the locks m_locks.put(edit.getReference(), edit); } return edit; }
/** * Return a lock on the entry with this id, or null if a lock cannot be made. * * @param container * The container id. * @param id * The id. * @return The locked object with this id, or null if a lock cannot be made. */ public Edit editResource(String container, String id) { if (container == null) container = ""; Container c = ((Container) m_store.get(container)); if (c == null) return null; Entity entry = (Entity) c.contained.get(caseId(id)); if (entry == null) return null; synchronized (m_locks) { // check for a lock in place if (m_locks.get(entry.getReference()) != null) return null; // make an Edit Edit edit = m_user.newResourceEdit(c.container, entry); // store it in the locks m_locks.put(entry.getReference(), edit); return edit; } }