/** * Returns a sorted list of workspace names */ ArrayList<String> getWorkspaceNames() { ArrayList<String> result = new ArrayList<String>(); for (WorkspaceInfo ws : getCatalog().getWorkspaces()) { result.add(ws.getName()); } Collections.sort(result); result.add(0, "*"); return result; }
@Override protected void onUpdate(AjaxRequestTarget target) { layerChoice.setChoices(new Model<ArrayList<String>>( getLayerNames(workspaceChoice.getConvertedInput()))); layerChoice.modelChanged(); target.addComponent(layerChoice); } });
@Override public void validate(Form<?> form) { // only validate on final submit if (form.findSubmittingButton() != form.get("save")) { return; } updateModels(); if (rolesFormComponent.getRolesNamesForStoring().isEmpty()) { form.error(new ParamResourceModel("emptyRoles", getPage()).getString()); } } }
public AbstractDataAccessRulePage(final DataAccessRule rule) { add(form); form.add(workspaceChoice = new DropDownChoice<String>("workspace", getWorkspaceNames())); workspaceChoice.setRequired(true); workspaceChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { form.add(layerChoice = new DropDownChoice<String>("layer", getLayerNames(rule.getWorkspace()))); layerChoice.setRequired(true); layerChoice.setOutputMarkupId(true);
public AbstractDataAccessRulePage(final DataAccessRule rule) { add(form); form.add(new EmptyRolesValidator()); layerContainer.add(layerAndLabel = new WebMarkupContainer("layerAndLabel")); layerAndLabel.add( layerChoice = new DropDownChoice<String>("layer", getLayerNames(rule.getRoot()))); layerAndLabel.setVisible(!rule.isGlobalGroupRule()); layerChoice.setRequired(true);
@Override public void onSubmit() { DataAccessRule rule = (DataAccessRule) getForm().getModelObject(); if (rolesFormComponent.isHasAnyRole()) { rule.getRoles().clear(); rule.getRoles().add(GeoServerRole.ANY_ROLE.getAuthority()); } onFormSubmit(rule); } });
public Object getDisplayValue(AccessMode object) { return (String) new ParamResourceModel( object.name(), getPage()) .getObject(); }
public AbstractDataAccessRulePage(final DataAccessRule rule) { add(form); form.add(workspaceChoice = new DropDownChoice<String>("workspace", getWorkspaceNames())); workspaceChoice.setRequired(true); workspaceChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { form.add(layerChoice = new DropDownChoice<String>("layer", getLayerNames(rule.getWorkspace()))); layerChoice.setRequired(true); layerChoice.setOutputMarkupId(true);
@Override public void onSubmit() { DataAccessRule rule = (DataAccessRule) getForm().getModelObject(); if (rolesFormComponent.isHasAnyRole()) { rule.getRoles().clear(); rule.getRoles().add(GeoServerRole.ANY_ROLE.getAuthority()); } onFormSubmit(rule); } });
public Object getDisplayValue(AccessMode object) { return (String) new ParamResourceModel( object.name(), getPage()) .getObject(); }
@Override public void validate(Form<?> form) { // only validate on final submit if (form.findSubmittingButton() != form.get("save")) { return; } updateModels(); if (rolesFormComponent.getRolesNamesForStoring().isEmpty()) { form.error(new ParamResourceModel("emptyRoles", getPage()).getString()); } } }
/** * Returns a sorted list of workspace names */ ArrayList<String> getWorkspaceNames() { ArrayList<String> result = new ArrayList<String>(); for (WorkspaceInfo ws : getCatalog().getWorkspaces()) { result.add(ws.getName()); } Collections.sort(result); result.add(0, "*"); return result; }
@Override protected void onUpdate(AjaxRequestTarget target) { layerChoice.setChoices( new Model<ArrayList<String>>( getLayerNames(rootChoice.getConvertedInput()))); layerChoice.modelChanged(); target.add(layerChoice); } });
@Override public void onSubmit() { DataAccessRule rule = (DataAccessRule) getForm().getModelObject(); if (rolesFormComponent.isHasAnyRole()) { rule.getRoles().clear(); rule.getRoles().add(GeoServerRole.ANY_ROLE.getAuthority()); } if (globalGroupRule.getModelObject()) { // just to be on the safe side rule.setLayer(null); } onFormSubmit(rule); } });
public Object getDisplayValue(AccessMode object) { return (String) new ParamResourceModel(object.name(), getPage()).getObject(); }
@Override public void validate(Form<?> form) { // only validate on final submit if (form.findSubmittingButton() != form.get("save")) { return; } updateModels(); String roleInputString = rolesFormComponent.getPalette().getRecorderComponent().getInput(); if ((roleInputString == null || roleInputString.trim().isEmpty()) && !rolesFormComponent.isHasAnyRole()) { form.error(new ParamResourceModel("emptyRoles", getPage()).getString()); } } }
/** * Returns a sorted list of layer names in the specified workspace (or * if the workspace is *) */ ArrayList<String> getLayerNames(String workspaceName) { ArrayList<String> result = new ArrayList<String>(); if (!workspaceName.equals("*")) { for (ResourceInfo r : getCatalog().getResources(ResourceInfo.class)) { if (r.getStore().getWorkspace().getName().equals(workspaceName)) result.add(r.getName()); } Collections.sort(result); } result.add(0, "*"); return result; }
@Override protected void onUpdate(AjaxRequestTarget target) { layerChoice.setChoices(new Model<ArrayList<String>>( getLayerNames(workspaceChoice.getConvertedInput()))); layerChoice.modelChanged(); target.addComponent(layerChoice); } });
/** * Returns a sorted list of layer names in the specified workspace (or * if the workspace is *) */ ArrayList<String> getLayerNames(String workspaceName) { ArrayList<String> result = new ArrayList<String>(); if (!workspaceName.equals("*")) { for (ResourceInfo r : getCatalog().getResources(ResourceInfo.class)) { if (r.getStore().getWorkspace().getName().equals(workspaceName)) result.add(r.getName()); } Collections.sort(result); } result.add(0, "*"); return result; }
/** * Returns a sorted list of layer names in the specified workspace (or * if the workspace is *) */ ArrayList<String> getLayerNames(String rootName) { ArrayList<String> result = new ArrayList<String>(); if (!rootName.equals("*")) { Filter wsResources = Predicates.equal("store.workspace.name", rootName); try (CloseableIterator<ResourceInfo> it = getCatalog().list(ResourceInfo.class, wsResources)) { while (it.hasNext()) { result.add(it.next().getName()); } } // collect also layer groups getCatalog() .getLayerGroupsByWorkspace(rootName) .stream() .map(lg -> lg.getName()) .forEach( name -> { if (!result.contains(name)) { result.add(name); } }); Collections.sort(result); } result.add(0, "*"); return result; }