/** * Sets the base directory. * * @param baseDirectory base of data directory used for file configuration files */ public void setBaseDirectory(File baseDirectory) { this.baseDirectory = baseDirectory; if (resources == ResourceStore.EMPTY) { resources = new FileSystemResourceStore(baseDirectory); } }
@Override public void addListener(ResourceListener listener) { getResourceNotificationDispatcher().addListener(path, listener); }
private void attemptRename(String oldName, String newName) throws IOException { assertEquals(1, folder.getRoot().list().length); FileSystemResourceStore toTest = new FileSystemResourceStore(folder.getRoot()); toTest.move(oldName, newName); assertEquals(1, folder.getRoot().list().length); } }
/** * Helper method that move resources files form current folder to the new one, current storage * is deleted */ private void manageStorageChange(Object newStorage) { try { if (newStorage != null) { String newStorageStr = (String) newStorage; Resource newResource = new FileSystemResourceStore(new File(newStorageStr)).get(""); Resource exResource = indexConfiguration.getStorageResource(); if (exResource != null && !newResource .dir() .getAbsolutePath() .equals(exResource.dir().getAbsolutePath())) { exResource.delete(); } indexConfiguration.setStorageResource(newResource); } } catch (Exception exception) { throw new RuntimeException("Error on change store", exception); } }
if (outputStorageDirectory == null || outputStorageDirectory.trim().isEmpty()) { Resource temp = resourceLoader.get("temp/wps"); resourceStore = new FileSystemResourceStore(temp.dir()); } else { File storage = new File(outputStorageDirectory); resourceStore = new FileSystemResourceStore(storage); resourceStore.setLockProvider(new FileLockProvider(lockDirectory.dir())); } catch (IllegalStateException e) { throw new RuntimeException(
@Test public void testInitLoggingLock() throws Exception { final File target = new File("./target"); FileUtils.deleteQuietly(new File(target, "logs")); GeoServerResourceLoader loader = new GeoServerResourceLoader(target); FileSystemResourceStore store = (FileSystemResourceStore) loader.getResourceStore(); store.setLockProvider(new MemoryLockProvider()); // make it copy the log files LoggingUtils.initLogging(loader, "DEFAULT_LOGGING.properties", false, null); // init once from default logging LoggingUtils.initLogging(loader, "DEFAULT_LOGGING.properties", false, null); // init twice, here it used to lock up LoggingUtils.initLogging(loader, "DEFAULT_LOGGING.properties", false, null); } }
input = new FileSystemResourceStore(jsonFile.getParentFile()).get(jsonFile.getName());
private void attemptRename(String oldName, String newName) throws IOException { assertEquals(1, folder.getRoot().list().length); FileSystemResourceStore toTest = new FileSystemResourceStore(folder.getRoot()); toTest.move(oldName, newName); assertEquals(1, folder.getRoot().list().length); } }
@Test public void testParseStyleTwiceLock() throws Exception { StyleInfo style = getCatalog().getStyles().get(0); FileSystemResourceStore store = (FileSystemResourceStore) getDataDirectory().getResourceStore(); store.setLockProvider(new MemoryLockProvider()); // parse twice to check we are not locking on it Resource resource = getDataDirectory().style(style); Styles.handler(style.getFormat()) .parse(resource, style.getFormatVersion(), new DefaultResourceLocator(), null); Styles.handler(style.getFormat()) .parse(resource, style.getFormatVersion(), new DefaultResourceLocator(), null); }
@Override protected Resource getUndefined() { return store.get("NonTestUndef"); } }
/** * Creates a new resource loader. * * @param baseDirectory The directory in which */ public GeoServerResourceLoader(File baseDirectory) { this.baseDirectory = baseDirectory; this.resources = new FileSystemResourceStore(baseDirectory); }
input = new FileSystemResourceStore(cssFile.getParentFile()).get(cssFile.getName());
@Override public void removeListener(ResourceListener listener) { getResourceNotificationDispatcher().removeListener(path, listener); }
@Override public Resource get(String resourcePath) { if (resourcePath == null) { throw new NullPointerException("Resource path required"); } if ("".equals(resourcePath)) { return this; } return FileSystemResourceStore.this.get(Paths.path(path, resourcePath)); }
@Override public void setServletContext(ServletContext servletContext) { if (baseDirectory == null) { String data = lookupGeoServerDataDirectory(servletContext); if (data != null) { this.baseDirectory = new File(data); } else { throw new IllegalStateException("Unable to determine data directory"); } } if (resources == ResourceStore.EMPTY && baseDirectory != null) { // lookup the configuration resources resources = new FileSystemResourceStore(baseDirectory); } }
@Override protected Resource getResource(String path) throws Exception { return store.get(path); }
@Before public void setup() throws Exception { File dirA = folder.newFolder("DirA"); File dirB = folder.newFolder("DirB"); File dirC = new File(dirA, "DirC"); dirC.mkdir(); (new File(dirA, "FileA1")).createNewFile(); (new File(dirA, "FileA2")).createNewFile(); (new File(dirB, "FileA2")).createNewFile(); (new File(dirB, "FileB1")).createNewFile(); (new File(dirB, "FileB2")).createNewFile(); (new File(dirC, "FileC1")).createNewFile(); (new File(dirC, "FileC2")).createNewFile(); store = new FileSystemResourceStore(folder.getRoot()); watcher = initWatcher(); }
@Override public List<Resource> list() { if (!file.exists()) { return Collections.emptyList(); } if (file.isFile()) { return Collections.emptyList(); } String array[] = file.list(); if (array == null) { return Collections.emptyList(); } List<Resource> list = new ArrayList<Resource>(array.length); for (String filename : array) { Resource resource = FileSystemResourceStore.this.get(Paths.path(path, filename)); list.add(resource); } return list; }
@Before public void setUp() throws Exception { folder.newFile("FileA"); folder.newFile("FileB"); File c = folder.newFolder("DirC"); (new File(c, "FileD")).createNewFile(); folder.newFolder("DirE"); store = new FileSystemResourceStore(folder.getRoot()); }