/** * Ensure the user data map matches the information in the user data file. This should be called * automatically, so that no code outside of this class needs to access this method. */ private void update() { try { if (myWatcher != null && myWatcher.isStale()) { Properties prop = myWatcher.getProperties(); UserAttributeEditor uae = new UserAttributeEditor(); myDetailStorage.clear(); Iterator<Object> it = prop.keySet().iterator(); while (it.hasNext()) { String username = (String) it.next(); uae.setAsText(prop.getProperty(username)); UserAttribute attrs = (UserAttribute) uae.getValue(); if (attrs != null) { myDetailStorage.put(username, makeUser(username, attrs)); } } } } catch (IOException ioe) { // TODO: handle the exception properly myDetailStorage.clear(); createDefaultUser(); } }
/** * Either loads the default property file on the first access, or reloads it if it has been * modified since last access. * * @throws DataAccessResourceFailureException */ void checkUserMap() throws DataAccessResourceFailureException { try { if ((userMap == null) || userDefinitionsFile == null || userDefinitionsFile.isStale()) { if (userDefinitionsFile == null) { Resource propFile = findUserProperties(); userDefinitionsFile = new PropertyFileWatcher(propFile); } userMap = loadUsersFromProperties(userDefinitionsFile.getProperties()); } } catch (Exception e) { LOGGER.log(Level.SEVERE, "An error occurred loading user definitions", e); } }
loadRules(watcher.getProperties()); loadRules(watcher.getProperties()); lastModified = System.currentTimeMillis();
private Set<String> reloadConfiguration() throws IOException { Properties props = configFile.getProperties(); if(props == null){ //file doesn't exist return Collections.emptySet(); } return loadConfiguration(props); }
if (file.exists() && file.canRead()) { Properties properties = watcher.getProperties();
/** * Get Mapping, update from file if changed * * @param typeName * @return the mapping */ public CatalogStoreMapping getMapping(String typeName) { PropertyFileWatcher watcher = watchers.get(typeName); if (watcher!=null && watcher.isModified() ) { try { addMapping (typeName, CatalogStoreMapping.parse(new HashMap<String, String>((Map) watcher.getProperties()))); } catch (IOException e) { LOGGER.log(Level.WARNING, e.toString()); } } return super.getMapping( typeName); }
/** * Get Mapping, update from file if changed * * @param typeName * @return the mapping */ public CatalogStoreMapping getMapping(String typeName) { PropertyFileWatcher watcher = watchers.get(typeName); if (watcher != null && watcher.isModified()) { try { addMapping( typeName, CatalogStoreMapping.parse( new HashMap<String, String>((Map) watcher.getProperties()))); } catch (IOException e) { LOGGER.log(Level.WARNING, e.toString()); } } return super.getMapping(typeName); }
public List<FlowController> buildFlowControllers() throws Exception { timeout = -1; Properties p = configFile.getProperties(); List<FlowController> newControllers = new ArrayList<FlowController>(); for (Object okey : p.keySet()) {
userMap = Collections.emptyMap(); } else { userMap = new HashMap(userDefinitionsFile.getProperties());
/** * Create GeoServerInternalCatalogStore * * @param geoserver * @throws IOException */ public GeoServerInternalCatalogStore(GeoServer geoserver) throws IOException { super( geoserver.getCatalog()); GeoServerResourceLoader loader = geoserver.getCatalog().getResourceLoader(); File dir = loader.findOrCreateDirectory("csw"); for (Name name : descriptorByType.keySet()) { String typeName = name.getLocalPart(); File f = new File(dir, typeName + ".properties"); PropertyFileWatcher watcher = new PropertyFileWatcher(f); watchers.put(typeName, watcher); if (!f.exists()) { IOUtils.copy(getClass().getResourceAsStream(typeName + ".default.properties"),f); } addMapping (typeName, CatalogStoreMapping.parse(new HashMap<String, String>((Map) watcher.getProperties()))); } }
if (Resources.exists(file) && Resources.canRead(file)) { Properties properties = watcher.getProperties();
/** * Create GeoServerInternalCatalogStore * * @param geoserver * @throws IOException */ public GeoServerInternalCatalogStore(GeoServer geoserver) throws IOException { super(geoserver.getCatalog()); GeoServerResourceLoader loader = geoserver.getCatalog().getResourceLoader(); Resource dir = loader.get("csw"); for (Name name : descriptorByType.keySet()) { String typeName = name.getLocalPart(); Resource f = dir.get(typeName + ".properties"); PropertyFileWatcher watcher = new PropertyFileWatcher(f); watchers.put(typeName, watcher); if (!Resources.exists(f)) { IOUtils.copy( getClass().getResourceAsStream(typeName + ".default.properties"), f.out()); } addMapping( typeName, CatalogStoreMapping.parse( new HashMap<String, String>((Map) watcher.getProperties()))); } } }
@Test public void testConfiguration() throws IOException { // store the properties into a temp folder and relaod assertTrue(monitor.getConfig().getFileLocations().isEmpty()); File tmpDir = createTempDir(); GeoServerResourceLoader resourceLoader = new GeoServerResourceLoader(tmpDir); monitor.getConfig().saveConfiguration(resourceLoader); Resource controlFlowProps = Files.asResource(resourceLoader.find("monitor.properties")); assertTrue(Resources.exists(controlFlowProps)); PropertyFileWatcher savedProps = new PropertyFileWatcher(controlFlowProps); assertEquals(savedProps.getProperties(), monitor.getConfig().getProperties()); }