@Override protected void removeNodeSpi() throws BackingStoreException { prefsFile.delete(); boolean removeSucceed = dir.delete(); if (!removeSucceed) { throw new BackingStoreException("Cannot remove " + toString()); } }
@Override protected String[] childrenNamesSpi() throws BackingStoreException { String[] names = dir.list(new FilenameFilter() { public boolean accept(File parent, String name) { return new File(path + File.separator + name).isDirectory(); } }); if (names == null) {// file is not a directory, exception case throw new BackingStoreException("Cannot get child names for " + toString() + " (path is " + path + ")"); } return names; }
@Override protected void flushSpi() throws BackingStoreException { if ( !file.getParentFile().exists() && !file.getParentFile().mkdirs() ) { throw new BackingStoreException("Could not create parent directories for: " + file); } OutputStream out = null; try { out = new BufferedOutputStream(new FileOutputStream(file)); properties.store(out, "# Auto-generated by " + FileBasedPreferences.class.getName()); } catch ( IOException e ) { throw new BackingStoreException(e); } finally { CloseableUtils.closeQuietly(out); } } }
@Override protected void flushSpi() throws BackingStoreException { try { //if removed, return if(isRemoved()){ return; } // reload Properties currentPrefs = XMLParser.readXmlPreferences(prefsFile); // merge Iterator<String> it = removed.iterator(); while (it.hasNext()) { currentPrefs.remove(it.next()); } removed.clear(); it = updated.iterator(); while (it.hasNext()) { Object key = it.next(); currentPrefs.put(key, prefs.get(key)); } updated.clear(); // flush prefs = currentPrefs; XMLParser.writeXmlPreferences(prefsFile, prefs); } catch (Exception e) { throw new BackingStoreException(e); } }
@Override protected void flushSpi () throws BackingStoreException { throw new BackingStoreException("Not implemented"); } protected Map<String, String> _values = new HashMap<String, String>();
@Override protected void flushSpi () throws BackingStoreException { throw new BackingStoreException("Not implemented"); } protected Map<String, String> _values = new HashMap<String, String>();
private void mkdirIfNecessary() throws BackingStoreException { if (!dir.exists() && !dir.mkdirs()) { throw new BackingStoreException("Failed to create directory '" + dir + "'!"); } }
@Override protected void removeNodeSpi() throws BackingStoreException { prefsFile.delete(); boolean removeSucceed = dir.delete(); if (!removeSucceed) { throw new BackingStoreException("Cannot remove " + toString()); } }
@Override protected void removeNodeSpi() throws BackingStoreException { prefsFile.delete(); boolean removeSucceed = dir.delete(); if (!removeSucceed) { throw new BackingStoreException("Cannot remove " + toString()); } }
@Override protected void removeNodeSpi() throws BackingStoreException { prefsFile.delete(); boolean removeSucceed = dir.delete(); if (!removeSucceed) { throw new BackingStoreException("Cannot remove " + toString()); } }
@Override protected void removeNodeSpi() throws BackingStoreException { prefsFile.delete(); boolean removeSucceed = dir.delete(); if (!removeSucceed) { throw new BackingStoreException("Cannot remove " + toString()); } }
@Override protected String[] childrenNamesSpi() throws BackingStoreException { String[] names = dir.list(new FilenameFilter() { public boolean accept(File parent, String name) { return new File(path + File.separator + name).isDirectory(); } }); if (names == null) {// file is not a directory, exception case throw new BackingStoreException("Cannot get child names for " + toString() + " (path is " + path + ")"); } return names; }
@Override protected String[] childrenNamesSpi() throws BackingStoreException { String[] names = dir.list(new FilenameFilter() { public boolean accept(File parent, String name) { return new File(path + File.separator + name).isDirectory(); } }); if (names == null) {// file is not a directory, exception case throw new BackingStoreException("Cannot get child names for " + toString() + " (path is " + path + ")"); } return names; }
@Override protected void removeNodeSpi() throws BackingStoreException { prefsFile.delete(); boolean removeSucceed = dir.delete(); if (!removeSucceed) { throw new BackingStoreException("Cannot remove " + toString()); } }
@Override protected void removeNodeSpi() throws BackingStoreException { prefsFile.delete(); boolean removeSucceed = dir.delete(); if (!removeSucceed) { throw new BackingStoreException("Cannot remove " + toString()); } }
protected TopicMapStoreIF createStore(TopicMapReferenceIF topicMapReference, boolean readonly) throws BackingStoreException { try { return topicMapReference.createStore(readonly); } catch (IOException e) { throw new BackingStoreException(e); } }
@Override protected String[] childrenNamesSpi() throws BackingStoreException { String[] names = dir.list(new FilenameFilter() { public boolean accept(File parent, String name) { return new File(path + File.separator + name).isDirectory(); } }); if (names == null) {// file is not a directory, exception case throw new BackingStoreException("Cannot get child names for " + toString() + " (path is " + path + ")"); } return names; }
@Override public Preferences systemRoot() { String key = getSystemKey(); if (systemRoots.get(key) == null) { TopicMapReferenceIF topicMapReference = getSystemTopicMapReference(key); if (topicMapReference == null) throw new RuntimeException(new BackingStoreException("System: Topicmap with key '" + key + "' was not resolved!")); Preferences systemPreferences = TopicMapPreferences.createSystemRoot(topicMapReference, this); systemRoots.put(key, systemPreferences); } return systemRoots.get(key); }
@Override protected final void syncSpi() throws BackingStoreException { if (dir.exists() && file.exists()) { try { file.load(); } catch (final Exception ex) { throw new BackingStoreException(ex); } } }
private void createCursor() throws BackingStoreException { if(!dbc.isCapped()) { throw new BackingStoreException("Unable to create cursor: collection is not capped"); } cursor = dbc.find(query).sort(new BasicDBObject("$natural", 1)).addOption(Bytes.QUERYOPTION_TAILABLE).addOption(Bytes.QUERYOPTION_AWAITDATA); }