diff --git a/marlo-parent/pom.xml b/marlo-parent/pom.xml index f4071efaa9..d572b396d3 100644 --- a/marlo-parent/pom.xml +++ b/marlo-parent/pom.xml @@ -24,7 +24,7 @@ 8.0.28 3.0.1 2.2.1 - 3.13 + 5.3.0 1.0 4.0.1 20231013 diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/ParticipantsAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/ParticipantsAction.java index 2e02a8ae04..a2c893be4d 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/ParticipantsAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/ParticipantsAction.java @@ -40,8 +40,6 @@ import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; -import org.apache.poi.EncryptedDocumentException; -import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.DataValidation; import org.apache.poi.ss.usermodel.DataValidationConstraint; @@ -236,7 +234,7 @@ public String preLoadExcelFile() { input.close(); - } catch (IOException | EncryptedDocumentException | InvalidFormatException e) { + } catch (Exception e) { e.printStackTrace(); } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/test.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/test.java index 09f3923008..e7d9bae39d 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/test.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/test.java @@ -180,26 +180,23 @@ public Object getCellData(Cell cell) { if (cell != null) { switch (cell.getCellType()) { - case Cell.CELL_TYPE_STRING: + case STRING: cellData = cell.getStringCellValue(); break; - case Cell.CELL_TYPE_NUMERIC: + case NUMERIC: cellData = cell.getNumericCellValue(); break; - case Cell.CELL_TYPE_BOOLEAN: + case BOOLEAN: cellData = cell.getBooleanCellValue(); break; - case Cell.CELL_TYPE_BLANK: - cellData = cell.getStringCellValue(); + case BLANK: + cellData = ""; break; - - default: break; } } - return cellData; } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReport2018POISummaryAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReport2018POISummaryAction.java index 9e32684985..f36e13cb10 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReport2018POISummaryAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReport2018POISummaryAction.java @@ -88,7 +88,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.math.BigInteger; @@ -120,13 +119,13 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPrGeneral; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPageSz; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSimpleField; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STPageOrientation; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STStyleType; import org.slf4j.Logger; @@ -161,7 +160,7 @@ private static void addCustomHeadingStyle(XWPFDocument docxDocument, String strS ctStyle.setQFormat(onoffnull); // style defines a heading of the given level - CTPPr ppr = CTPPr.Factory.newInstance(); + CTPPrGeneral ppr = CTPPrGeneral.Factory.newInstance(); ppr.setOutlineLvl(indentNumber); ctStyle.setPPr(ppr); @@ -689,7 +688,7 @@ public void createPageFooter() { try { XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr); headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, paragraphs); - } catch (IOException e) { + } catch (Exception e) { LOG.error("Failed to createFooter. Exception: " + e.getMessage()); } } @@ -2183,7 +2182,7 @@ public String execute() throws Exception { CTP ctP = paragraph.getCTP(); CTSimpleField toc = ctP.addNewFldSimple(); toc.setInstr("TOC \\h"); - toc.setDirty(STOnOff.TRUE); + toc.setDirty(true); XWPFRun run = paragraph.createRun(); // First page @@ -2668,7 +2667,7 @@ public String execute() throws Exception { CTP ctP = paragraph.getCTP(); CTSimpleField toc = ctP.addNewFldSimple(); toc.setInstr("TOC \\h"); - toc.setDirty(STOnOff.TRUE); + toc.setDirty(true); XWPFRun run = paragraph.createRun(); // First page diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReportPOISummaryAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReportPOISummaryAction.java index 86f4cbeae5..50bb52edb0 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReportPOISummaryAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReportPOISummaryAction.java @@ -75,7 +75,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.math.BigInteger; @@ -571,7 +570,7 @@ public void createPageFooter() { try { XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr); headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, paragraphs); - } catch (IOException e) { + } catch (Exception e) { LOG.error("Failed to createFooter. Exception: " + e.getMessage()); } } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnualReportPOISummaryAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnualReportPOISummaryAction.java index ce954d5423..05a0eb4722 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnualReportPOISummaryAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnualReportPOISummaryAction.java @@ -75,7 +75,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.math.BigInteger; @@ -571,7 +570,7 @@ public void createPageFooter() { try { XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr); headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, paragraphs); - } catch (IOException e) { + } catch (Exception e) { LOG.error("Failed to createFooter. Exception: " + e.getMessage()); } } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/POWBPOISummary2019Action.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/POWBPOISummary2019Action.java index 5042797b95..d043fa7054 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/POWBPOISummary2019Action.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/POWBPOISummary2019Action.java @@ -75,7 +75,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.math.BigInteger; @@ -108,6 +107,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPrGeneral; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPageSz; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString; @@ -133,22 +133,25 @@ private static void addCustomHeadingStyle(XWPFDocument docxDocument, String strS styleName.setVal(strStyleId); ctStyle.setName(styleName); + // Assuming headingLevel is an integer representing the level of the heading CTDecimalNumber indentNumber = CTDecimalNumber.Factory.newInstance(); - indentNumber.setVal(BigInteger.valueOf(headingLevel)); + indentNumber.setVal(BigInteger.valueOf(headingLevel)); // Set the UI priority - // lower number > style is more prominent in the formats bar + // Set the style's UI priority (using an integer value) ctStyle.setUiPriority(indentNumber); CTOnOff onoffnull = CTOnOff.Factory.newInstance(); - ctStyle.setUnhideWhenUsed(onoffnull); + ctStyle.setUnhideWhenUsed(onoffnull); // Set the style to unhide when used - // style shows up in the formats bar + // Style shows up in the formats bar ctStyle.setQFormat(onoffnull); - // style defines a heading of the given level - CTPPr ppr = CTPPr.Factory.newInstance(); - ppr.setOutlineLvl(indentNumber); - ctStyle.setPPr(ppr); + // Define a heading of the given level + CTPPrGeneral pprGeneral = CTPPrGeneral.Factory.newInstance(); // Create a new instance of CTPPrGeneral + CTDecimalNumber outlineLvl = CTDecimalNumber.Factory.newInstance(); // Create a new instance of CTDecimalNumber + outlineLvl.setVal(BigInteger.valueOf(headingLevel)); // Set the outline level value + pprGeneral.setOutlineLvl(outlineLvl); // Set the outline level in the paragraph properties + ctStyle.setPPr(pprGeneral); // Apply the paragraph properties to the style XWPFStyle style = new XWPFStyle(ctStyle); @@ -326,7 +329,7 @@ public void createPageFooter() { try { XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr); headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, paragraphs); - } catch (IOException e) { + } catch (Exception e) { LOG.error("Failed to createFooter. Exception: " + e.getMessage()); } @@ -1053,7 +1056,7 @@ public String execute() throws Exception { * CTP ctP = paragraph.getCTP(); * CTSimpleField toc = ctP.addNewFldSimple(); * toc.setInstr("TOC \\h"); - * toc.setDirty(STOnOff.TRUE); + * toc.setDirty(true); */ XWPFRun run = paragraph.createRun(); // run.addBreak(BreakType.PAGE); @@ -1327,7 +1330,7 @@ public String execute() throws Exception { * CTP ctP = paragraph.getCTP(); * CTSimpleField toc = ctP.addNewFldSimple(); * toc.setInstr("TOC \\h"); - * toc.setDirty(STOnOff.TRUE); + * toc.setDirty(true); */ XWPFRun run = paragraph.createRun(); // run.addBreak(BreakType.PAGE); diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/ProgressReportProcessPOISummaryAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/ProgressReportProcessPOISummaryAction.java index c250ff0b09..2df9f4680c 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/ProgressReportProcessPOISummaryAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/ProgressReportProcessPOISummaryAction.java @@ -75,7 +75,6 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.math.BigInteger; @@ -113,13 +112,12 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocument1; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPrGeneral; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSimpleField; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STStyleType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -154,7 +152,7 @@ private static void addCustomHeadingStyle(XWPFDocument docxDocument, String strS ctStyle.setQFormat(onoffnull); // style defines a heading of the given level - CTPPr ppr = CTPPr.Factory.newInstance(); + CTPPrGeneral ppr = CTPPrGeneral.Factory.newInstance(); ppr.setOutlineLvl(indentNumber); ctStyle.setPPr(ppr); @@ -616,7 +614,7 @@ public void createPageFooter() { try { XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr); headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, paragraphs); - } catch (IOException e) { + } catch (Exception e) { LOG.error("Failed to createFooter. Exception: " + e.getMessage()); } @@ -822,6 +820,7 @@ public String execute() throws Exception { && c.getCrpProgramOutcome().getComposedName().contains("PDO Indicator 1")) .collect(Collectors.toList())); } catch (Exception e) { + LOG.error("Error generating Progress Summary " + e.getMessage()); } // PDO 2 @@ -832,6 +831,7 @@ public String execute() throws Exception { && c.getCrpProgramOutcome().getComposedName().contains("PDO Indicator 2")) .collect(Collectors.toList())); } catch (Exception e) { + LOG.error("Error generating Progress Summary " + e.getMessage()); } // PDO 3 @@ -842,6 +842,7 @@ public String execute() throws Exception { && c.getCrpProgramOutcome().getComposedName().contains("PDO Indicator 3")) .collect(Collectors.toList())); } catch (Exception e) { + LOG.error("Error generating Progress Summary " + e.getMessage()); } // PDO 4 try { @@ -851,6 +852,7 @@ public String execute() throws Exception { && c.getCrpProgramOutcome().getComposedName().contains("PDO Indicator 4")) .collect(Collectors.toList())); } catch (Exception e) { + LOG.error("Error generating Progress Summary " + e.getMessage()); } // IPI 1.1 @@ -861,6 +863,7 @@ public String execute() throws Exception { && c.getCrpProgramOutcome().getComposedName().contains("IPI 1.1")) .collect(Collectors.toList())); } catch (Exception e) { + LOG.error("Error generating Progress Summary " + e.getMessage()); } // IPI 1.2 @@ -871,6 +874,7 @@ public String execute() throws Exception { && c.getCrpProgramOutcome().getComposedName().contains("IPI 1.2")) .collect(Collectors.toList())); } catch (Exception e) { + LOG.error("Error generating Progress Summary " + e.getMessage()); } // IPI 1.3 @@ -1057,7 +1061,7 @@ public String execute() throws Exception { CTP ctP = paragraph.getCTP(); CTSimpleField toc = ctP.addNewFldSimple(); toc.setInstr("TOC \\h"); - toc.setDirty(STOnOff.TRUE); + toc.setDirty(true); XWPFRun run = paragraph.createRun(); document.createParagraph().setPageBreak(true); } @@ -1107,7 +1111,7 @@ public String execute() throws Exception { run.addBreak(); run.addPicture(new FileInputStream(imageFile), imgFormat, imgFile, Units.toEMU(width), Units.toEMU(height)); } catch (Exception e) { - // System.out.println(e); + LOG.error("Error generating Progress Summary " + e.getMessage()); } // Project Title @@ -1601,7 +1605,7 @@ public void loadProvider(Map session) { try { ServletActionContext.getContext().setLocale(locale); } catch (Exception e) { - + LOG.error("Error generating Progress Summary " + e.getMessage()); } if (session.containsKey(APConstants.SESSION_CRP)) { diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/ReadExcelFile.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/ReadExcelFile.java index 66eb0f1475..61dfc3c04d 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/ReadExcelFile.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/ReadExcelFile.java @@ -21,7 +21,6 @@ import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; @@ -29,7 +28,6 @@ import java.util.Map; import org.apache.poi.EncryptedDocumentException; -import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; @@ -52,17 +50,17 @@ public Object getCellData(Cell cell) { if (cell != null) { switch (cell.getCellType()) { - case Cell.CELL_TYPE_STRING: + case STRING: cellData = cell.getStringCellValue(); break; - case Cell.CELL_TYPE_NUMERIC: + case NUMERIC: cellData = cell.getNumericCellValue(); break; - case Cell.CELL_TYPE_BOOLEAN: + case BOOLEAN: cellData = cell.getBooleanCellValue(); break; - case Cell.CELL_TYPE_BLANK: - cellData = cell.getStringCellValue(); + case BLANK: + cellData = ""; break; default: @@ -158,7 +156,7 @@ public Object[][] readExcelFile(File file) { } - } catch (EncryptedDocumentException | InvalidFormatException | IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -240,7 +238,7 @@ public boolean validarExcelFile(File file) { equal = false; } - } catch (EncryptedDocumentException | InvalidFormatException | IOException e) { + } catch (Exception e) { equal = false; } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoExcel.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoExcel.java index abb1ae7d9e..e6b2d81d82 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoExcel.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoExcel.java @@ -153,7 +153,7 @@ private static Font mergeFont(Font font, STYLES fontStyle, String fontValue, Wor case BOLD: case EM: case STRONG: - font.setBoldweight(Font.BOLDWEIGHT_BOLD); + font.setBold(true); break; case UNDERLINE: font.setUnderline(Font.U_SINGLE); diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoWord.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoWord.java index 0ef7815c04..72c0452d6a 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoWord.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoWord.java @@ -170,7 +170,7 @@ private static Font mergeFont(Font font, STYLES fontStyle, String fontValue, XWP case BOLD: case EM: case STRONG: - font.setBoldweight(Font.BOLDWEIGHT_BOLD); + font.setBold(true); break; case UNDERLINE: font.setUnderline(Font.U_SINGLE);