/** * @param macroDefinition macro definition * @return task list name or empty string if no name specified */ public static String getTaskListName(MacroDefinition macroDefinition) { String result = macroDefinition.getParameters().get("title"); if (result == null) result = macroDefinition.getDefaultParameterValue(); return defaultString(result); }
public MacroDefinition migrate(MacroDefinition macroDefinition, ConversionContext conversionContext) { Map<String, String> macroParameters = macroDefinition.getParameters(); if (macroParameters.containsKey("reverseSort")) { Map<String, String> modifiedMacroParameters = new HashMap<>(macroDefinition.getParameters()); modifiedMacroParameters.remove("reverseSort"); modifiedMacroParameters.put("reverse", "true"); final MacroDefinitionBuilder builder = MacroDefinition.builder(macroDefinition.getName()) .withMacroBody(macroDefinition.getBody()) .withParameters(modifiedMacroParameters); builder.setDefaultParameterValue(macroDefinition.getDefaultParameterValue()); return builder.build(); } return macroDefinition; } }
public MacroDefinition update(MacroDefinition macroDefinition) { taskListMacroDefinitionHandler.handle(macroDefinition); if (!taskListUpdated && taskListMacroDefinitionHandler.getMatchingTaskList() != null) { MacroBody macroBody = new PlainTextMacroBody(taskListSerializer.serialize(updatedTaskList)); MacroDefinitionBuilder updatedMacroDefinition = MacroDefinition.builder(macroDefinition.getName()) .withMacroBody(macroBody) .withParameters(macroDefinition.getParameters()); updatedMacroDefinition.setDefaultParameterValue(macroDefinition.getDefaultParameterValue()); taskListUpdated = true; return updatedMacroDefinition.build(); } return macroDefinition; } }
private boolean linkingToSelf(final Link link, final ConversionContext conversionContext) { if (conversionContext == null) { return true; } if (isGlobalObject(conversionContext)) { return false; } final ResourceIdentifier resourceIdentifier = link.getDestinationResourceIdentifier(); // If linking to same page then the confluence macro linking mechanism does not // include a resourceIdentifier in the macroDefinition. There could still be a link // input via the storage format though, which is why we still do the checks. if (resourceIdentifier == null) { if (conversionContext.getProperty(MACRO_DEFINITION) != null) { String linkedPageName = ((MacroDefinition) conversionContext.getProperty(MACRO_DEFINITION)) .getDefaultParameterValue(); return isSamePageTitle(conversionContext, linkedPageName); } return true; } // Note that we check content type before we check if it's the same space // because the same space check relies on a page/blog post content type. return isSameContentType(conversionContext, resourceIdentifier) && isSamePageTitle(conversionContext, resourceIdentifier) && isSameSpace(conversionContext, resourceIdentifier) && isSamePostingDateForBlog(conversionContext, resourceIdentifier); }