log.debug("baseloc: " + baseloc); try { Processor.synchronizeRelations(rmapping, relnames, store.getTopicMap(), baseloc); store.commit(); } catch (Exception e) { store.abort(); throw e; } finally { if (store.isOpen()) store.close();
private void importFragment(String fragment, TopicMapIF topicmap) { log.debug("Importing fragment " + fragment); LocatorIF base = topicmap.getStore().getBaseAddress(); LTMTopicMapReader reader = new LTMTopicMapReader(new StringReader(fragment), base); try { reader.importInto(topicmap); } catch (java.io.IOException e) { log.error("Syntax error in LTM fragment", e); throw new ActionRuntimeException(e); } }
private static TopicMapIF doCommit(TopicMapIF topicmap) throws IOException { TopicMapStoreIF store = topicmap.getStore(); TopicMapReferenceIF reference = store.getReference(); store.commit(); if (!(store instanceof InMemoryTopicMapStore)) { store.close(); store = reference.createStore(false); } //never forget! topicmap = store.getTopicMap(); return topicmap; }
@Override public synchronized void clear() throws IOException { // naive implementation that gets a store and clears it TopicMapStoreIF store = null; try { store = createStore(false); store.getTopicMap().clear(); } finally { if (store != null && store.isOpen()) store.close(); } }
@Override public void setTitle(String title) { super.setTitle(title); TopicMapStoreIF store = null; try { store = createStore(false); TopicMap topicmap = (TopicMap) store.getTopicMap(); topicmap.setTitle(title); store.commit(); } finally { if (store != null) { store.close(); } } }
LocatorIF baseloc = (outfile == null ? store.getBaseAddress() : new URILocator(new File(outfile))); if (baseloc == null && tmurl != null) baseloc = (ohandler.baseuri == null ? new URILocator(tmurl) : new URILocator(ohandler.baseuri)); store.commit(); log.debug("Transaction committed."); } catch (Exception t) { log.error("Error occurred while running operation '" + operation + "'", t); store.abort(); log.debug("Transaction aborted."); throw t; } finally { if (store.isOpen()) store.close();
public TopicMapImpl(TopicMapSystemIF tmsystem, TopicMapStoreIF store) { super(null); this.tmsystem = tmsystem; wrapped = store.getTopicMap(); topicMap = this; }
public TMO remove(TMO object) throws OntopiaRestException { if (object == null) { // todo: OntopiaRestErrors throw new OntopiaClientException(Status.CLIENT_ERROR_NOT_FOUND, "Cannot find " + objectClass.getSimpleName() + " to remove"); } // todo: move to controller object.remove(); store.commit(); return object; }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { String repositoryId = getRepositoryId(request); String topicMapId = getTopicMapId(request); boolean readOnly = getReadOnly(request); TopicMapStoreIF store; if (repositoryId == null) store = TopicMaps.createStore(topicMapId, readOnly); else store = TopicMaps.createStore(topicMapId, readOnly, repositoryId); try { data.set(store); chain.doFilter(request, response); if (!readOnly) store.commit(); } catch (Exception e) { if (!readOnly) store.abort(); log.error("Exception thrown from doFilter.", e); } finally { data.set(null); store.close(); } }
/** * Tests that close and open update the status of the store appropriately. */ public void testOpenClose() { TopicMapStoreIF _store = factory.makeStandaloneTopicMapStore(); try { assertTrue("Store open", !_store.isOpen()); _store.open(); assertTrue("Store not open", _store.isOpen()); TopicMapIF tm1 = _store.getTopicMap(); _store.close(); assertTrue("Store not closed", !_store.isOpen()); try { TopicMapIF tm = _store.getTopicMap(); // Expected. _store.close(); } catch (StoreNotOpenException ex) { fail("Couldn't retrieve topic map [via TopicMapStoreIF.getTopicMap()] from a closed store!"); } _store.open(); assertTrue("Could not reopen store.", _store.isOpen()); } finally { _store.delete(true); } } }
@Override public void returnTopicMap(TopicMapIF topicmap) { TopicMapStoreIF store = topicmap.getStore(); log.debug("Returning store: " + store); store.close(); }
public void testTransactionAbort() throws IOException { TopicMapEvents.addTopicListener(topicmapRef, new AbstractTopicMapListener() { @Override public void objectAdded(TMObjectIF snapshot) { added++; } }); TopicMapStoreIF store = null; try { store = topicmapRef.createStore(false); store.getTopicMap().getBuilder().makeTopic(); // before commit: 0 calls should have been made to objectAdded assertEquals(0, added); store.abort(); // after abort: 0 calls should have been made to objectAdded assertEquals(0, added); } finally { store.close(); } } }
public boolean isSaveable() { TopicMapReferenceIF ref = getTopicMapIF().getStore().getReference(); return (ref instanceof XTMTopicMapReference); }
@Override public void remove() { wrapped.getStore().delete(true); tmsystem.remove(wrapped.getStore().getBaseAddress()); }
@Override public synchronized void storeClosed(TopicMapStoreIF store) { if (!store.isReadOnly()) { // dereference listeners ((AbstractTopicMapStore)store).setTopicListeners(null); } if (pool != null) { log.debug("RTR: return " + getId() + " i: " + pool.getNumIdle() + " a: " + pool.getNumActive()); try { // return rw store to pool if (!store.isReadOnly()) { pool.returnObject(store); } } catch (Exception e) { throw new OntopiaRuntimeException("Could not return topic map store '" + getId() + "' to pool.", e); } } else { // pool has been closed before store, so we should close store ourselves synchronized (store) { if (store.isOpen()) ((RDBMSTopicMapStore)store).close(false); } } }
protected void mergeTopics(TopicIF targetTopic, TopicIF sourceTopic) throws BackingStoreException { TopicMapStoreIF store = null; try { store = createStore(topicMapReference, false); TopicMapIF topicmap = store.getTopicMap(); TopicIF currentTopic = revitalize(targetTopic, topicmap); TopicIF duplicateTopic = revitalize(sourceTopic, topicmap); MergeUtils.mergeInto(currentTopic, duplicateTopic); store.commit(); } finally { if (store != null) { store.close(); } } }