Search in sources :

Example 1 with ReplaceAllOperation

use of org.opennms.core.utils.ReplaceAllOperation in project opennms by OpenNMS.

the class SiblingColumnStorageStrategy method setParameters.

/**
 * {@inheritDoc}
 */
@Override
public void setParameters(List<Parameter> parameterCollection) throws IllegalArgumentException {
    if (parameterCollection == null) {
        final String msg = "Got a null parameter list, but need one containing a '" + PARAM_SIBLING_COLUMN_NAME + "' parameter.";
        LOG.error(msg);
        throw new IllegalArgumentException(msg);
    }
    for (Parameter param : parameterCollection) {
        if (PARAM_SIBLING_COLUMN_NAME.equals(param.getKey())) {
            m_siblingColumnName = param.getValue();
        } else if (PARAM_REPLACE_FIRST.equals(param.getKey())) {
            m_replaceOps.add(new ReplaceFirstOperation(param.getValue()));
        } else if (PARAM_REPLACE_ALL.equals(param.getKey())) {
            m_replaceOps.add(new ReplaceAllOperation(param.getValue()));
        } else {
            if (param.getKey().equals("sibling-column-oid")) {
                final String msg = "The parameter 'sibling-column-oid' has been deprecated and it is no longer used. You should configure 'sibling-column-name' instead. For this parameter, you should use the name of any MibObj defined as string for the same resource type.";
                LOG.error(msg);
                throw new IllegalArgumentException(msg);
            } else {
                LOG.warn("Encountered unsupported parameter key=\"{}\". Can accept: {}, {}, {}", param.getKey(), PARAM_SIBLING_COLUMN_NAME, PARAM_REPLACE_FIRST, PARAM_REPLACE_ALL);
            }
        }
    }
    if (m_siblingColumnName == null) {
        final String msg = "The provided parameter list must contain a '" + PARAM_SIBLING_COLUMN_NAME + "' parameter.";
        LOG.error(msg);
        throw new IllegalArgumentException(msg);
    }
}
Also used : Parameter(org.opennms.netmgt.collection.api.Parameter) ReplaceFirstOperation(org.opennms.core.utils.ReplaceFirstOperation) ReplaceAllOperation(org.opennms.core.utils.ReplaceAllOperation)

Aggregations

ReplaceAllOperation (org.opennms.core.utils.ReplaceAllOperation)1 ReplaceFirstOperation (org.opennms.core.utils.ReplaceFirstOperation)1 Parameter (org.opennms.netmgt.collection.api.Parameter)1