public void save(StoreInfo store) { if (store.getId() == null) { // add it instead of saving add(store); return; } validate(store, false); facade.save(store); }
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); }
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; } }
<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 String getIdValue(StoreInfo store, int arg1) { return store.getId(); }
public String getIdValue(Object object, int index) { return ((StoreInfo) object).getId(); } }
public StoreInfoDetachableModel(StoreInfo store) { super(store); this.id = store.getId(); }
public StoreInfoDetachableModel(StoreInfo store) { super(store); this.id = store.getId(); }
public String getIdValue(StoreInfo store, int arg1) { return store.getId(); } }
public String getIdValue(Object object, int index) { return ((StoreInfo) object).getId(); }
protected StoreEditPanel(final String componentId, final Form storeEditForm) { super(componentId); this.storeEditForm = storeEditForm; StoreInfo info = (StoreInfo) storeEditForm.getModel().getObject(); final boolean isNew = null == info.getId(); if (isNew && info instanceof DataStoreInfo) { applyDataStoreParamsDefaults(info); } }
protected StoreEditPanel(final String componentId, final Form storeEditForm) { super(componentId); this.storeEditForm = storeEditForm; StoreInfo info = (StoreInfo) storeEditForm.getModel().getObject(); final boolean isNew = null == info.getId(); if (isNew && info instanceof DataStoreInfo) { applyDataStoreParamsDefaults(info); } }
static StoreInfo resolve(StoreInfo s, Catalog cat, boolean lookupByName) { if (s != null) { StoreInfo resolved = null; if (s.getId() != null) { resolved = cat.getStore(s.getId(), StoreInfo.class); } if (resolved == null && lookupByName) { resolved = cat.getStoreByName(s.getWorkspace(), s.getName(), StoreInfo.class); } if (resolved != null) { s = resolved; } } if (s != null && s.getCatalog() == null && s instanceof StoreInfoImpl) { ((StoreInfoImpl)s).setCatalog(cat); } return resolveCollections(s); }
static StoreInfo resolve(StoreInfo s, Catalog cat, boolean lookupByName) { if (s != null) { StoreInfo resolved = null; if (s.getId() != null) { resolved = cat.getStore(s.getId(), StoreInfo.class); } if (resolved == null && lookupByName) { resolved = cat.getStoreByName(s.getWorkspace(), s.getName(), StoreInfo.class); } if (resolved != null) { s = resolved; } } if (s != null && s.getCatalog() == null && s instanceof StoreInfoImpl) { ((StoreInfoImpl) s).setCatalog(cat); } return resolveCollections(s); }
@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); }
@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.add(selectLayersContainer); addFeedbackPanels(target); } });
ConfigChangeEvent newChangeEvent(Info subj, Type type) { String name = (String) (OwsUtils.has(subj, "name") ? OwsUtils.get(subj, "name") : null); WorkspaceInfo ws = (WorkspaceInfo) (OwsUtils.has(subj, "workspace") ? OwsUtils.get(subj, "workspace") : null); StoreInfo store = (StoreInfo) (OwsUtils.has(subj, "store") ? OwsUtils.get(subj, "store") : null); ConfigChangeEvent ev = new ConfigChangeEvent(subj.getId(), name, subj.getClass(), type); if (ws != null) { ev.setWorkspaceId(ws.getId()); } if (store != null) { ev.setStoreId(store.getId()); } if (subj instanceof ResourceInfo) { ev.setNativeName(((ResourceInfo) subj).getNativeName()); } return ev; }
public ImportContext reattach(ImportContext context) { // reload store and workspace objects from catalog so they are "attached" with // the proper references to the catalog initialized context.reattach(catalog); for (ImportTask task : context.getTasks()) { StoreInfo store = task.getStore(); if (store != null && store.getId() != null) { task.setStore(catalog.getStore(store.getId(), StoreInfo.class)); // ((StoreInfoImpl) task.getStore()).setCatalog(catalog); // @todo remove if the // above sets catalog } if (task.getLayer() != null) { LayerInfo l = task.getLayer(); if (l.getDefaultStyle() != null && l.getDefaultStyle().getId() != null) { l.setDefaultStyle(catalog.getStyle(l.getDefaultStyle().getId())); } if (l.getResource() != null) { ResourceInfo r = l.getResource(); r.setCatalog(catalog); if (r.getStore() == null && resourceMatchesStore(r, store)) { r.setStore(store); } } } } return context; }
public ImportContext reattach(ImportContext context) { //reload store and workspace objects from catalog so they are "attached" with // the proper references to the catalog initialized context.reattach(catalog); for (ImportTask task : context.getTasks()) { StoreInfo store = task.getStore(); if (store != null && store.getId() != null) { task.setStore(catalog.getStore(store.getId(), StoreInfo.class)); //((StoreInfoImpl) task.getStore()).setCatalog(catalog); // @todo remove if the above sets catalog } if (task.getLayer() != null) { LayerInfo l = task.getLayer(); if (l.getDefaultStyle() != null && l.getDefaultStyle().getId() != null) { l.setDefaultStyle(catalog.getStyle(l.getDefaultStyle().getId())); } if (l.getResource() != null) { ResourceInfo r = l.getResource(); r.setCatalog(catalog); if (r.getStore() == null && resourceMatchesStore(r, store)) { r.setStore(store); } } } } return context; }
final String existingId = existing.getId(); if (!existingId.equals(edittingStoreId)) { ValidationError error = new ValidationError();