@Deprecated private String path(StoreInfo store) { WorkspaceInfo workspace = store.getWorkspace(); return Paths.path("workspaces", workspace.getName(), store.getName()); }
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; } }
/** * Builds a store. * * <p>The workspace of the resulting store is {@link #workspace} if set, else the default * workspace from the catalog. */ void buildStore(StoreInfo info, String name) { info.setName(name); info.setEnabled(true); // set workspace, falling back on default if none specified if (workspace != null) { info.setWorkspace(workspace); } else { info.setWorkspace(catalog.getDefaultWorkspace()); } }
/** * Checks if the provided store is visible in the current context. * * @param store the store to check, may be NULL * @return the store if visible, otherwise NULL */ private <T extends StoreInfo> T enforceStoreIsolation(T store) { if (store == null) { // nothing to do, the store is already NULL return null; } WorkspaceInfo workspace = store.getWorkspace(); // check if the store workspace is visible in this context return canSeeWorkspace(workspace) ? store : null; }
<T extends StoreInfo> void initStore( T s, Class<T> clazz, String sId, String name, WorkspaceInfo ws) { expect(s.getId()).andReturn(sId).anyTimes(); expect(s.getName()).andReturn(name).anyTimes(); expect(s.getWorkspace()).andReturn(ws).anyTimes(); expect(s.getCatalog()).andReturn(catalog).anyTimes(); expect(s.isEnabled()).andReturn(true).anyTimes(); expect(catalog.getStore(sId, clazz)).andReturn(s).anyTimes(); expect(catalog.getStore(sId, StoreInfo.class)).andReturn(s).anyTimes(); expect(catalog.getStoreByName(name, clazz)).andReturn(s).anyTimes(); expect(catalog.getStoreByName(name, StoreInfo.class)).andReturn(s).anyTimes(); expect(catalog.getStoreByName(ws.getName(), name, clazz)).andReturn(s).anyTimes(); expect(catalog.getStoreByName(ws.getName(), name, StoreInfo.class)).andReturn(s).anyTimes(); expect(catalog.getStoreByName(ws, name, clazz)).andReturn(s).anyTimes(); expect(catalog.getStoreByName(ws, name, StoreInfo.class)).andReturn(s).anyTimes(); }
public ValidationResult validate(StoreInfo store, boolean isNew) { if (isNull(store.getName())) { throw new IllegalArgumentException("Store name must not be null"); } if (store.getWorkspace() == null) { throw new IllegalArgumentException("Store must be part of a workspace"); } WorkspaceInfo workspace = store.getWorkspace(); StoreInfo existing = getStoreByName(workspace, store.getName(), StoreInfo.class); if (existing != null && (isNew || !existing.getId().equals(store.getId()))) { String msg = "Store '" + store.getName() + "' already exists in workspace '" + workspace.getName() + "'"; throw new IllegalArgumentException(msg); } return postValidate(store, isNew); }
if (task.getStore().getId() == null) { StoreInfo store = task.getStore(); store.setName(findUniqueStoreName(task.getStore())); if (!store.getConnectionParameters().containsKey("namespace")) { WorkspaceInfo ws = task.getContext().getTargetWorkspace(); if (ws == null && task.getContext().getTargetStore() != null) { ws = task.getContext().getTargetStore().getWorkspace(); store.getConnectionParameters().put("namespace", ns.getURI());
private void renameStore(StoreInfo s, String newName) throws IOException { LOGGER.fine("Renaming store " + s.getName() + "to " + newName); Resource directory = dd.get(s); renameRes(directory, newName); }
public void add(StoreInfo store) { if (store.getWorkspace() == null) { store.setWorkspace(getDefaultWorkspace()); } validate(store, true); // TODO: remove synchronized block, need transactions StoreInfo added; synchronized (facade) { added = facade.add(resolve(store)); // if there is no default store use this one as the default if (getDefaultDataStore(store.getWorkspace()) == null && store instanceof DataStoreInfo) { setDefaultDataStore(store.getWorkspace(), (DataStoreInfo) store); } } added(added); }
@Override protected void onUpdate(AjaxRequestTarget target) { if (stores.getModelObject() != null) { StoreInfo store = (StoreInfo) stores.getModelObject(); NewLayerPage.this.storeId = store.getId(); provider.setStoreId(store.getId()); storeName.setDefaultModelObject(store.getName()); selectLayers.setVisible(true); // make sure we can actually list the contents, it may happen // the store is actually unreachable, in that case we // want to display an error message try { provider.getItems(); } catch(Exception e) { LOGGER.log(Level.SEVERE, "Error retrieving layers for the specified store", e); error(e.getMessage()); selectLayers.setVisible(false); } updateSpecialFunctionPanels(store); } else { selectLayers.setVisible(false); createTypeContainer.setVisible(false); } target.addComponent(selectLayersContainer); target.addComponent(feedbackPanel); }
public void save(StoreInfo store) { if (store.getId() == null) { // add it instead of saving add(store); return; } validate(store, false); facade.save(store); }
si.setDescription(generalParams.description); si.getConnectionParameters().putAll(params); si.setEnabled(true); si.setType(factory.getDisplayName()); getCatalog().add(si); pp.put("store", si.getName()); pp.put("workspace", workspace.getName()); pp.put("storeNew", true);
/** 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)); } } } } }
void doIndirectImport(ImportTask task) throws IOException { if (!task.getStore().isEnabled()) { task.getStore().setEnabled(true);
Map<String, Serializable> params = store.getConnectionParameters(); String databaseLocation = null; if ("h2".equals(params.get("dbtype"))) { store.accept(v);
/** @see ResourceInfo#enabled() */ public boolean enabled() { StoreInfo store = getStore(); boolean storeEnabled = store != null && store.isEnabled(); return storeEnabled && this.isEnabled(); }
public void reattach(Catalog catalog, boolean lookupByName) { if (data != null) { data.reattach(); } targetWorkspace = resolve(targetWorkspace, catalog, lookupByName); if (targetStore != null) { targetStore.setWorkspace(targetWorkspace); } targetStore = resolve(targetStore, catalog, lookupByName); for (ImportTask task : tasks) { task.setContext(this); task.reattach(catalog, lookupByName); } }
@SuppressWarnings({ "rawtypes", "unchecked" }) public static LayerInfoImpl mockLayer(String resourceName, String[] extraStyles, Type type) { StoreInfo store = new DataStoreInfoImpl(null); store.setName(resourceName + "-store"); store.setEnabled(true);
/** Test that a request for a resource from a disabled store fails. */ @Test public void testRequestDisabledStore() throws Exception { Catalog catalog = getCatalog(); StoreInfo store = catalog.getStoreByName("cdf", DataStoreInfo.class); try { store.setEnabled(false); catalog.save(store); Document doc = getAsDOM( "wfs?service=WFS&version=1.0.0&request=GetFeature&typename=cdf:Fifteen"); // print(doc); XMLAssert.assertXpathEvaluatesTo("1", "count(//ogc:ServiceException)", doc); XMLAssert.assertXpathEvaluatesTo( "InvalidParameterValue", "//ogc:ServiceException/@code", doc); XMLAssert.assertXpathEvaluatesTo("typeName", "//ogc:ServiceException/@locator", doc); } finally { store.setEnabled(true); catalog.save(store); } }
private void checkLayerGroupResourceIsInWorkspace(LayerInfo layer, WorkspaceInfo ws) { if (layer == null) return; ResourceInfo r = layer.getResource(); if (r.getStore().getWorkspace() != null && !ws.equals(r.getStore().getWorkspace())) { throw new IllegalArgumentException( "Layer group within a workspace (" + ws.getName() + ") can not contain resources from other workspace: " + r.getStore().getWorkspace().getName()); } }