public static String getParameter(String paramKey, MacroDefinition macro) { String value = macro.getParameter(paramKey); return value != null ? value.trim() : null; } }
@Override public MacroDefinition migrate(MacroDefinition macro, ConversionContext context) { // Shouldn't need to check existing cql if schema version is being checked - just being a bit defensive while // Confluence core catches up. if (Strings.isNullOrEmpty(macro.getParameter("cql"))) { String cql = getCql(macro); macro.setParameter("cql", cql); macro.setTypedParameter("cql", cql); log.debug("CQL parameter set to '{}'", cql); } macro.setSchemaVersion(2); return macro; }
public void handle(MacroDefinition macroDefinition) { if (!"details".equals(macroDefinition.getName())) return; String bodyText = macroDefinition.getBodyText(); String detailsId = StringUtils.trim(macroDefinition.getParameter(DetailsSummaryMacro.PARAM_ID)); if (detailsId == null) detailsId = ""; if (StringUtils.isBlank(bodyText)) { addToDetails(detailsId, ImmutableMap.<String, PageProperty>of()); return; } try { metrics.detailsExtractionStart(); ImmutableMap<String, PageProperty> extractedDetails = extractDetails(bodyText); metrics.detailsExtractionFinish(extractedDetails.size()); addToDetails(detailsId, extractedDetails); } catch (Exception e) { LOG.error(String.format("Unable to parse detailsById in detailsById macro\n%s", bodyText), e); } }
@Override public MacroDefinition migrate(MacroDefinition macro, ConversionContext context) { String oldValue = macro.getParameter("excerpt"); if (StringUtils.isNotBlank(oldValue)) { ExcerptType excerptParam = ExcerptType.fromOldValue(oldValue); macro.setParameter("excerptType", excerptParam.getValue()); macro.setTypedParameter("excerptType", excerptParam); } macro.setSchemaVersion(macro.getSchemaVersion() + 1); return macro; }