Exemplo n.º 1
0
  @Override
  public Iterator<IModel<Preference>> getItemModels() {
    final JetspeedServiceLocator locator =
        ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
    PortletRegistry registry = locator.getPortletRegistry();
    PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
    PortletDefinition def = PortletApplicationUtils.getPortletOrClone(app, paNodeBean.getName());

    curPrefs = def.getPortletPreferences().getPortletPreferences();

    return new ModelIteratorAdapter<Preference>(curPrefs.iterator()) {
      @Override
      protected IModel<Preference> model(Preference preference) {
        return new PreferenceModel(locator, paNodeBean, preference);
      }
    };
  }
Exemplo n.º 2
0
  @Override
  public void delete(IModel<Preference>[] fields) {
    FeedbackPanel feed = (FeedbackPanel) getPage().get("feedback");

    try {
      PortletRegistry registry =
          ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
      PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
      PortletDefinition def = PortletApplicationUtils.getPortletOrClone(app, paNodeBean.getName());
      PortletPreferencesProvider prefProvider =
          (PortletPreferencesProvider)
              ((AbstractAdminWebApplication) getApplication())
                  .getServiceLocator()
                  .getService(CommonPortletServices.CPS_PORTLET_PREFERENCES_PROVIDER);

      for (IModel<Preference> field : fields) {
        prefProvider.removeDefaults(def, field.getObject().getName());
      }

      StringResourceModel resModel =
          new StringResourceModel(
              "pam.details.action.status.portlet.saveOK",
              this,
              null,
              new Object[] {paNodeBean.getName()});
      feed.info(resModel.getString());
    } catch (Exception e) {
      logger.error("Failed to remove portlet default preference.", e);
      StringResourceModel resModel =
          new StringResourceModel(
              "pam.details.action.status.portlet.saveFailure",
              this,
              null,
              new Object[] {paNodeBean.getName(), e.getMessage()});
      feed.info(resModel.getString());
    }
  }