|
16 | 16 | */ |
17 | 17 | public class PumlConfluenceUploader { |
18 | 18 | private static final Logger LOGGER = Logger.getLogger(PumlConfluenceUploader.class.getName()); |
19 | | - |
| 19 | + |
20 | 20 | public PumlConfluenceUploader() { |
21 | 21 | super(); |
22 | 22 | } |
23 | | - |
| 23 | + |
24 | 24 | /** |
25 | | - * Title: |
26 | | - * | |
27 | | - * |----- V1.0 Title |
28 | | - * | |
29 | | - * |----- V1.1 Title |
30 | | - * |
31 | 25 | * |
32 | 26 | * @param specFile |
33 | 27 | * @param parentPageID |
34 | 28 | * @param userName |
35 | 29 | * @param password |
36 | 30 | * @param confluenceURL |
37 | 31 | * @param spaceKey |
38 | | - * @param htmlDocumentationURL |
39 | | - * @param clientkitURL |
40 | | - * @throws IOException |
| 32 | + * @param title |
| 33 | + * @throws IOException |
41 | 34 | */ |
42 | 35 | public void processPuml2Confluence(String specFile, String parentPageID, String userName, String password, |
43 | | - String confluenceURL, String spaceKey,String title) throws IOException { |
44 | | - |
| 36 | + String confluenceURL, String spaceKey, String title) throws IOException { |
| 37 | + |
45 | 38 | File pumlFile = new File(specFile); |
46 | | - |
47 | | - if(pumlFile.isFile()){ |
48 | | - |
| 39 | + |
| 40 | + if (pumlFile.isFile()) { |
| 41 | + |
49 | 42 | String pumlContents = FileUtils.readFileToString(pumlFile, "UTF-8"); |
50 | | - |
51 | | - if(StringUtils.isNotEmpty(pumlContents) |
52 | | - && pumlContents.contains("@startuml")){ |
53 | | - String swaggerPageContent = plantUMLMacroContent(pumlContents); |
54 | | - |
| 43 | + |
| 44 | + if (StringUtils.isNotEmpty(pumlContents) && pumlContents.contains("@startuml")) { |
| 45 | + String swaggerPageContent = plantUMLMacroContent(pumlContents); |
| 46 | + |
55 | 47 | LOGGER.log(Level.INFO, "About to generate Page -->" + title); |
56 | | - |
| 48 | + |
57 | 49 | ConfluenceVo parentPageVo = createSwaggerPage(new ConfluenceVo(userName, password, confluenceURL, "", |
58 | 50 | parentPageID, "", title, "0", swaggerPageContent, spaceKey, false)); |
59 | | - |
60 | | - LOGGER.log(Level.INFO, "Done.... by generating Pages "+ parentPageVo.getPageID()); |
61 | | - } |
62 | | - else{ |
| 51 | + |
| 52 | + LOGGER.log(Level.INFO, "Done.... by generating Pages " + parentPageVo.getPageID()); |
| 53 | + } else { |
63 | 54 | throw new RuntimeException("Puml File provided in input is not valid"); |
64 | 55 | } |
65 | | - } |
66 | | - else{ |
| 56 | + } else { |
67 | 57 | throw new RuntimeException("Puml File provided in input is not valid"); |
68 | 58 | } |
69 | 59 | } |
70 | | - |
| 60 | + |
71 | 61 | /** |
72 | 62 | * |
73 | | - * @param swaggerLoctaion |
74 | | - * @param htmlDocumentationURL |
75 | | - * @param clientkitURL |
| 63 | + * @param pumlContents |
76 | 64 | * @return |
77 | 65 | */ |
78 | 66 | private String plantUMLMacroContent(String pumlContents) { |
79 | | - |
80 | 67 | StringBuilder macroString = new StringBuilder(); |
81 | | - macroString.append("<ac:structured-macro ac:name=\"plantuml\" ac:schema-version=\"1\" ac:macro-id=\"29f50cc-3338-43cc-9f67-15a851eb3417\">") |
82 | | - .append("<ac:parameter ac:name=\"atlassian-macro-output-type\">INLINE</ac:parameter>") |
83 | | - .append("<ac:plain-text-body><![CDATA[") |
84 | | - .append(addEscapeChars(pumlContents)) |
85 | | - .append("]]></ac:plain-text-body></ac:structured-macro>"); |
86 | | - |
| 68 | + macroString |
| 69 | + .append("<ac:structured-macro ac:name=\"plantuml\" ac:schema-version=\"1\" ac:macro-id=\"29f50cc-3338-43cc-9f67-15a851eb3417\">") |
| 70 | + .append("<ac:parameter ac:name=\"atlassian-macro-output-type\">INLINE</ac:parameter>") |
| 71 | + .append("<ac:plain-text-body><![CDATA[").append(addEscapeChars(pumlContents)) |
| 72 | + .append("]]></ac:plain-text-body></ac:structured-macro>"); |
| 73 | + |
87 | 74 | return macroString.toString(); |
88 | 75 | } |
89 | | - |
| 76 | + |
90 | 77 | /** |
91 | 78 | * |
92 | 79 | * @param inputString |
93 | 80 | * @return |
94 | 81 | */ |
95 | | - private String addEscapeChars(String inputString){ |
| 82 | + private String addEscapeChars(String inputString) { |
96 | 83 | return inputString; |
97 | 84 | } |
98 | | - |
| 85 | + |
99 | 86 | /** |
100 | 87 | * |
101 | | - * @param title |
| 88 | + * @param confluenceVo |
102 | 89 | * @return |
103 | 90 | */ |
104 | 91 | private ConfluenceVo createSwaggerPage(ConfluenceVo confluenceVo) { |
|
0 commit comments