/** {@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_INDEX_FORMAT + "' parameter."; LOG.error(msg); throw new IllegalArgumentException(msg); } parameterCollection.forEach((param) -> { if (null == param.getKey()) { LOG.warn("Encountered unsupported parameter key=\"{}\". Can accept: {}, {}", param.getKey(), PARAM_INDEX_FORMAT, PARAM_CLEAN_OUTPUT); } else { m_parameters.put(param.getKey(), param.getValue()); } }); if (!m_parameters.containsKey(PARAM_INDEX_FORMAT)) { throw new IllegalArgumentException("Missing index-format expression"); } }
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);
@Override public boolean shouldPersist(CollectionResource resource) { LOG.debug("shouldPersist: checking resource {}", resource); if (m_parameterCollection == null) { LOG.warn("shouldPersist: no parameters defined; the resource will be persisted."); return true; } EvaluatorContextVisitor visitor = new EvaluatorContextVisitor(); resource.visit(visitor); ExpressionParser parser = new SpelExpressionParser(); for (Parameter param : m_parameterCollection) { if (param.getKey().equals(MATCH_EXPRESSION)) { Expression exp = parser.parseExpression(param.getValue()); boolean shouldPersist = false; try { shouldPersist = (Boolean)exp.getValue(visitor.getEvaluationContext(), Boolean.class); } catch (Exception e) { LOG.warn("shouldPersist: can't evaluate expression {} for resource {} because: {}", param.getValue(), resource, e.getMessage()); } LOG.debug("shouldPersist: checking {} ? {}", param.getValue(), shouldPersist); if (shouldPersist) return true; } } return false; }
if (strategy.endsWith(".SiblingColumnStorageStrategy")) { for (final Parameter parameter : resourceType.getStorageStrategy().getParameters()) { if ("sibling-column-name".equals(parameter.getKey())) { final String name = parameter.getValue(); if (name != null && !name.trim().isEmpty()) { type.setResourceNameTemplate("${" + name + "}");