Example usage for org.apache.commons.configuration2 HierarchicalConfiguration addProperty

List of usage examples for org.apache.commons.configuration2 HierarchicalConfiguration addProperty

Introduction

In this page you can find the example usage for org.apache.commons.configuration2 HierarchicalConfiguration addProperty.

Prototype

void addProperty(String key, Object value);

Source Link

Document

Add a property to the configuration.

Usage

From source file:com.github.technosf.posterer.modules.commons.config.CommonsConfiguratorPropertiesImpl.java

/**
 * {@inheritDoc}/*from w w w. j  ava 2 s .c  o m*/
 *
 * @see com.github.technosf.posterer.models.Properties#addData(com.github.technosf.posterer.models.Proxy)
 */
@Override
public boolean addData(final @Nullable Proxy proxy) {
    boolean result = false;

    if (proxy != null) {
        ProxyBean pdi = new ProxyBean(proxy);
        if (pdi.isActionable() && (result = putIfAbsent(pdi))) {
            config.addProperty(PROP_PROXIES_PROXY_ID, pdi.hashCode());
            HierarchicalConfiguration<ImmutableNode> property = getProxy(pdi.hashCode());
            property.addProperty("proxyHost", pdi.getProxyHost());
            property.addProperty("proxyPort", pdi.getProxyPort());
            property.addProperty("proxyUser", pdi.getProxyUser());
            property.addProperty("proxyPassword", pdi.getProxyPassword());
            dirty();
        }
    }

    return result;
}

From source file:com.github.technosf.posterer.modules.commons.config.CommonsConfiguratorPropertiesImpl.java

/**
 * {@inheritDoc}//from  w  ww  .  java 2 s  . com
 * 
 * @see com.github.technosf.posterer.models.Properties#addData(com.github.technosf.posterer.models.Properties.impl.PropertiesModel.Request)
 */
@Override
public boolean addData(final @Nullable Request request) {
    boolean result = false;

    if (request != null) {
        RequestBean pdi = new RequestBean(request);
        if (pdi.isActionable() && (result = putIfAbsent(pdi))) {
            config.addProperty(PROP_REQUESTS_REQUEST_ID, pdi.hashCode());
            HierarchicalConfiguration<ImmutableNode> property = getRequest(pdi.hashCode());
            property.addProperty("endpoint", pdi.getEndpoint());
            property.addProperty("payload", pdi.getPayload());
            property.addProperty("method", pdi.getMethod());
            property.addProperty("security", pdi.getSecurity());
            property.addProperty("contentType", pdi.getContentType());
            property.addProperty("base64", pdi.getBase64());
            dirty();
        }
    }

    return result;
}