/** * {@inheritDoc} */ @Override protected Map<PluginProperty, String> applyConfiguration(List<PluginProperty> properties) throws PluginConfigurationException { if (properties.size() == 1 && ORDER_PROPERTY.equalsIgnoreCase(properties.get(0).getName())) { order = properties.get(0).getValue() == null ? DEFAULT_ORDER_VALUE : Integer.parseInt(properties.get(0).getValue()); properties.get(0).setHint(ORDER_HINT); return new HashMap<>(); } else { throw new PluginConfigurationException( "Can't apply configuration: incorrect parameters count or order not found"); } }
switch (property.getName()) { case WIDTH_PROPERTY: width = Integer.valueOf(property.getValue()); break; case HEIGHT_PROPERTY: height = Integer.valueOf(property.getValue()); break; case LENGTH_PROPERTY: length = Integer.valueOf(property.getValue()); break; case POSSIBLE_SYMBOLS_PROPERTY: possibleSymbols = property.getValue(); break; LOGGER.error(property.getValue() + " is not valid value for property " + property.getName(), ex);
@Override protected Map<PluginProperty, String> applyConfiguration(List<PluginProperty> properties) throws PluginConfigurationException { String url = null; String login = null; String password = null; for (PluginProperty property : properties) { if (URL_PROPERTY.equalsIgnoreCase(property.getName())) { url = property.getValue() == null ? null : property.getValue().trim(); } else if (LOGIN_PROPERTY.equalsIgnoreCase(property.getName())) { login = property.getValue() == null ? null : property.getValue().trim(); } else if (PASSWORD_PROPERTY.equalsIgnoreCase(property.getName())) { password = property.getValue(); } } if (url == null || url.isEmpty()) { // this should be returned as a map, but this mechanism should be implemented in the plugin API first throw new PluginConfigurationException("Can't apply configuration: Url should not be null."); } else if (!validateUrl(url)) { throw new PluginConfigurationException("Can't apply configuration: Incorrect format for Url value."); } service = new PoulpeAuthService(url, login, password); pluginProperties = properties; return new HashMap<>(); }
/** * {@inheritDoc} */ @Override public void updateProperties(List<PluginProperty> properties) { for (PluginProperty property: properties) { PluginProperty persistedProperty = (PluginProperty) session().load(property.getClass(), property.getId()); persistedProperty.setValue(property.getValue()); session().saveOrUpdate(persistedProperty); } session().flush(); } }