/** Decrypts previously encrypted store connection parameters. */ public void decode(StoreInfo info) { List<GeoServerPasswordEncoder> encoders = securityManager.loadPasswordEncoders(null, true, null); Set<String> encryptedFields = getEncryptedFields(info); if (info.getConnectionParameters() != null) { for (String key : info.getConnectionParameters().keySet()) { if (encryptedFields.contains(key)) { String value = (String) info.getConnectionParameters().get(key); if (value != null) { info.getConnectionParameters().put(key, decode(value, encoders)); } } } } }
@Override public boolean matches(Object argument) { return namespace.equals( ((StoreInfo) argument).getConnectionParameters().get("namespace")); }
if (info != null && info.getConnectionParameters() != null) { toEncrypt = new HashSet<String>(3); for (Param p : factory.getParametersInfo()) {
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof StoreInfo)) { return false; } final StoreInfo other = (StoreInfo) obj; if (connectionParameters == null) { if (other.getConnectionParameters() != null) return false; } else if (!connectionParameters.equals(other.getConnectionParameters())) return false; if (description == null) { if (other.getDescription() != null) return false; } else if (!description.equals(other.getDescription())) return false; if (enabled != other.isEnabled()) return false; if (id == null) { if (other.getId() != null) return false; } else if (!id.equals(other.getId())) return false; if (name == null) { if (other.getName() != null) return false; } else if (!name.equals(other.getName())) return false; if (workspace == null) { if (other.getWorkspace() != null) return false; } else if (!workspace.equals(other.getWorkspace())) return false; return true; } }
Map<String, Serializable> connectionParams = store.getConnectionParameters(); Serializable autoIndexingParam = connectionParams.get(GeoGigDataStoreFactory.AUTO_INDEXING.key);
public Repository findRepository(LayerInfo geogigLayer) { Preconditions.checkArgument(isGeogigLayer(geogigLayer)); Map<String, Serializable> params = geogigLayer.getResource().getStore().getConnectionParameters(); String repoUriStr = String.valueOf(params.get(GeoGigDataStoreFactory.REPOSITORY.key)); URI repoURI = URI.create(repoUriStr); RepositoryResolver resolver = RepositoryResolver.lookup(repoURI); String repoName = resolver.getName(repoURI); RepositoryInfo repoInfo = getByRepoName(repoName); String repoId = repoInfo.getId(); try { Repository repository = getRepository(repoId); Preconditions.checkState(repository != null); return repository; } catch (IOException e) { throw Throwables.propagate(e); } } }
protected void applyParamDefault(ParamInfo paramInfo, StoreInfo info) { Serializable defValue = paramInfo.getValue(); if ("namespace".equals(paramInfo.getName())) { defValue = getCatalog().getDefaultNamespace().getURI(); } else if (URL.class == paramInfo.getBinding() && null == defValue) { defValue = "file:data/example.extension"; } else { defValue = paramInfo.getValue(); } info.getConnectionParameters().put(paramInfo.getName(), defValue); }
/** * Initializes all store parameters to their default value * * @param info */ protected void applyDataStoreParamsDefaults(StoreInfo info) { // grab the factory final DataStoreInfo dsInfo = (DataStoreInfo) info; DataAccessFactory dsFactory; try { dsFactory = getCatalog().getResourcePool().getDataStoreFactory(dsInfo); } catch (IOException e) { throw new RuntimeException(e); } final Param[] dsParams = dsFactory.getParametersInfo(); Map connParams = info.getConnectionParameters(); for (Param p : dsParams) { ParamInfo paramInfo = new ParamInfo(p); // set default value if not already set to some default if (!connParams.containsKey(p.key) || connParams.get(p.key) == null) { applyParamDefault(paramInfo, info); } } }
/** * Initializes all store parameters to their default value * @param info */ protected void applyDataStoreParamsDefaults(StoreInfo info) { // grab the factory final DataStoreInfo dsInfo = (DataStoreInfo) info; DataAccessFactory dsFactory; try { dsFactory = getCatalog().getResourcePool().getDataStoreFactory(dsInfo); } catch (IOException e) { throw new RuntimeException(e); } final Param[] dsParams = dsFactory.getParametersInfo(); Map connParams = info.getConnectionParameters(); for (Param p : dsParams) { ParamInfo paramInfo = new ParamInfo(p); // set default value if not already set to some default if (!connParams.containsKey(p.key) || connParams.get(p.key) == null) { applyParamDefault(paramInfo, info); } } }
protected void applyParamDefault(ParamInfo paramInfo, StoreInfo info) { Serializable defValue = paramInfo.getValue(); if ("namespace".equals(paramInfo.getName())) { defValue = getCatalog().getDefaultNamespace().getURI(); } else if (URL.class == paramInfo.getBinding() && null == defValue) { defValue = "file:data/example.extension"; } else { defValue = paramInfo.getValue(); } info.getConnectionParameters().put(paramInfo.getName(), defValue); }
Map<String, Serializable> params = store.getConnectionParameters(); String databaseLocation = null; if ("h2".equals(params.get("dbtype"))) {
if (!store.getConnectionParameters().containsKey("namespace")) { WorkspaceInfo ws = task.getContext().getTargetWorkspace(); if (ws == null && task.getContext().getTargetStore() != null) { NamespaceInfo ns = catalog.getNamespaceByPrefix(ws.getName()); if (ns != null) { store.getConnectionParameters().put("namespace", ns.getURI());
if (!store.getConnectionParameters().containsKey("namespace")) { WorkspaceInfo ws = task.getContext().getTargetWorkspace(); if (ws == null && task.getContext().getTargetStore() != null) { NamespaceInfo ns = catalog.getNamespaceByPrefix(ws.getName()); if (ns != null) { store.getConnectionParameters().put("namespace", ns.getURI());
si.getConnectionParameters().putAll(params); si.setEnabled(true); si.setType(factory.getDisplayName());
@Test public void testImportShapefileFromDataDir() throws Exception { File dataDir = getCatalog().getResourceLoader().getBaseDirectory(); File dir = unpack("shape/archsites_epsg_prj.zip", dataDir); ImportContext context = importer.createContext(new SpatialFile(new File(dir, "archsites.shp"))); assertEquals(1, context.getTasks().size()); ImportTask task = context.getTasks().get(0); assertEquals(ImportTask.State.READY, task.getState()); assertEquals("archsites", task.getLayer().getResource().getName()); importer.run(context); Catalog cat = getCatalog(); assertNotNull(cat.getLayerByName("archsites")); assertEquals(ImportTask.State.COMPLETE, task.getState()); assertEquals( "file:archsites.shp", task.getLayer().getResource().getStore().getConnectionParameters().get("url")); runChecks("archsites"); }
assertEquals( getCatalog().getNamespaceByPrefix(ws.getName()).getURI(), store.getConnectionParameters().get("namespace"));