/** {@inheritDoc} */ @Override public void visit(CollectionSetVisitor visitor) { m_wrapped.visit(visitor); }
@Override public final void visit(CollectionSetVisitor visitor) { visitor.visitCollectionSet(this); m_collectionResource.visit(visitor); visitor.completeCollectionSet(this); }
/** {@inheritDoc} */ @Override public String getResourceNameFromIndex(CollectionResource resource) { StringAttributeVisitor visitor = new StringAttributeVisitor(HR_STORAGE_DESC); resource.visit(visitor); String value = (visitor.getValue() != null ? visitor.getValue() : resource.getInstance()); /* * Use special translation for root (base) filesystem */ if (value.equals("/")) return "_root_fs"; /* * 1. Eliminate first slash character * 2. Eliminate tabs and spaces on filesystem names * 3. Replace slash (file separator) character with "-" * 4. Remove Additional Information on Windows Drives */ return value.replaceFirst("/", "").replaceAll("\\s", "").replaceAll("/", "-").replaceAll(":\\\\.*", ""); }
@Override public final void visit(CollectionSetVisitor visitor) { visitor.visitCollectionSet(this); for(T resource : getCollectionResources()) { resource.visit(visitor); } visitor.completeCollectionSet(this); }
@Override public void visit(CollectionSetVisitor visitor) { visitor.visitCollectionSet(this); for(CollectionResource resource : buildCollectionResources()) { resource.visit(visitor); } visitor.completeCollectionSet(this); } }
/** {@inheritDoc} */ @Override public void visit(CollectionSetVisitor visitor) { visitor.visitCollectionSet(this); for (CollectionResource resource : getResources()) { resource.visit(visitor); } visitor.completeCollectionSet(this); }
@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; }
/** {@inheritDoc} */ @Override public String getResourceNameFromIndex(CollectionResource resource) { LOG.debug("Finding the value of sibling column {} for resource {}@{}", m_siblingColumnName, resource.getInstance(), resource.getParent()); StringAttributeVisitor visitor = new StringAttributeVisitor(m_siblingColumnName); resource.visit(visitor); String value = (visitor.getValue() != null ? visitor.getValue() : resource.getInstance()); // First remove all non-US-ASCII characters and turn all forward slashes into dashes String name = value.replaceAll("[^\\x00-\\x7F]", "").replaceAll("/", "-"); // Then perform all replacement operations specified in the parameters for (StringReplaceOperation op : m_replaceOps) { LOG.debug("Doing string replacement on instance name '{}' using {}", name, op); name = op.replace(name); } LOG.debug("Inbound instance name was '{}', outbound was '{}'", resource.getInstance(), ("".equals(name) ? resource.getInstance() : name)); return ("".equals(name) ? resource.getInstance() : name); }
protected static void assertMibObjectsPresent(CollectionResource resource, final List<MibObject> attrList) { assertNotNull(resource); AttributeVerifier attributeVerifier = new AttributeVerifier(attrList); resource.visit(attributeVerifier); assertEquals("Unexpected number of attributes", attrList.size(), attributeVerifier.attributeCount); }