コード例 #1
0
  @Override
  protected void simulateDeleteSubmit() throws Exception {

    assertTrue(DataAccessRuleDAO.get().getRules().size() > 0);

    SelectionDataRuleRemovalLink link = (SelectionDataRuleRemovalLink) getRemoveLink();
    Method m =
        link.delegate
            .getClass()
            .getDeclaredMethod("onSubmit", AjaxRequestTarget.class, Component.class);
    m.invoke(link.delegate, null, null);

    assertEquals(0, DataAccessRuleDAO.get().getRules().size());
  }
コード例 #2
0
 @Override
 protected String getSearchString() throws Exception {
   for (DataAccessRule rule : DataAccessRuleDAO.get().getRules()) {
     if (MockData.CITE_PREFIX.equals(rule.getWorkspace())
         && MockData.BRIDGES.getLocalPart().equals(rule.getLayer())) return rule.getKey();
   }
   return null;
 }
コード例 #3
0
  public DataAccessRulePage() {
    DataAccessRuleProvider provider = new DataAccessRuleProvider();
    add(
        rules =
            new GeoServerTablePanel<DataAccessRule>("table", provider, true) {

              @Override
              protected Component getComponentForProperty(
                  String id, IModel<DataAccessRule> itemModel, Property<DataAccessRule> property) {
                if (property == DataAccessRuleProvider.RULEKEY) {
                  return editRuleLink(id, itemModel, property);
                }
                if (property == DataAccessRuleProvider.ROLES) {
                  return new Label(id, property.getModel(itemModel));
                }
                throw new RuntimeException("Uknown property " + property);
              }

              @Override
              protected void onSelectionUpdate(AjaxRequestTarget target) {
                removal.setEnabled(rules.getSelection().size() > 0);
                target.add(removal);
              }
            });

    rules.setOutputMarkupId(true);

    setHeaderPanel(headerPanel());

    Form form =
        new Form(
            "catalogModeForm",
            new CompoundPropertyModel(new CatalogModeModel(DataAccessRuleDAO.get().getMode())));
    add(form);
    form.add(
        new AjaxLink("catalogModeHelp") {
          @Override
          public void onClick(AjaxRequestTarget target) {
            dialog.showInfo(
                target,
                new StringResourceModel("catalogModeHelp.title", getPage(), null),
                new StringResourceModel("catalogModeHelp.message", getPage(), null),
                new StringResourceModel("catalogModeHelp.hide", getPage(), null),
                new StringResourceModel("catalogModeHelp.mixed", getPage(), null),
                new StringResourceModel("catalogModeHelp.challenge", getPage(), null));
          }
        });
    catalogModeChoice = new RadioChoice("catalogMode", CATALOG_MODES, new CatalogModeRenderer());
    catalogModeChoice.setSuffix(" ");
    form.add(catalogModeChoice);

    form.add(
        new SubmitLink("save") {
          @Override
          public void onSubmit() {
            try {
              DataAccessRuleDAO dao = DataAccessRuleDAO.get();
              CatalogMode newMode = dao.getByAlias(catalogModeChoice.getValue());
              dao.setCatalogMode(newMode);
              dao.storeRules();
              doReturn();
            } catch (Exception e) {
              LOGGER.log(Level.SEVERE, "Error occurred while saving user", e);
              error(new ParamResourceModel("saveError", getPage(), e.getMessage()));
            }
          }
        });
    form.add(new BookmarkablePageLink("cancel", GeoServerHomePage.class));
  }