Modify the macro name in Confluence Migration Process

Hi Users,

I have created an macro name preview and i have deployed it locally by copy the jar file in WEB-INF/lib.

To overcome the missing macro, i have defined an new macro.

While checking my confluence entities file macro name shows like this.

image

I need to convert that highlighted macro name “panel” to link preview

I have added some condition in DefaultMacroConverter.java of confluence xml git source.

image

After code changes i have deployed & copied the jar file in WEB-INF/lib folder. And again started to conversion. But the macro panel is not renaming it to “preview

Is that anything i need to do update further or did i miss any?

This is not really the right way to add a new converter. You should add a new component implementing MacroConverter interface and setting “panel” as hint.

See how it’s done for the anchor macro on https://github.com/xwiki-contrib/confluence/blob/master/confluence-xml/src/main/java/org/xwiki/contrib/confluence/filter/internal/macros/AnchorMacroConverter.java.

@tmortagne

I have an doubt from your reply, you have mentioned to define new component like AnchorMacroConverter.

Like i said in my question, i have created an component name preview in the new macro “Link Preview” and deployed it.
image

Is that new component creation is required in the confluence xml? if it is right why we didn’t create component for info macro?

my question may be wrong, to have an better clarity regarding this process am asking this question.

You are mixing several things here actually.

There is two different areas where you can act on the macros Confluence macros:

During the import of the Confluence package

The importer (DefaultMacroConverter to be more precise) try to find a special converter (a component implementing MacroConverter interface) associated to a macro id (for example the anchor one I mentioned) and call it to convert the Confluence macro into an XWiki equivalent (here it convert it in the XWiki id macro).

If it does not find any special converter then you end up with a macro which have exactly the same name and parameters than the Confluence one.

After the import

That’s the XWiki Rendering macro (a component implementing Macro interface) you wrote which mimic the Confluence macro behavior.