Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Dec 22, 2022
2 parents 47193ce + 0638fab commit d3d56cd
Show file tree
Hide file tree
Showing 15 changed files with 263 additions and 38 deletions.
4 changes: 2 additions & 2 deletions docgen/parameters.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"title" : "Venus (Fugerit Document Generation Framework)",
"name": "Venus",
"version" : "0.6.0",
"date" : "20/12/2022",
"version" : "0.6.1",
"date" : "22/12/2022",
"organization" : {
"name" : "Fugerit Org",
"url" : "https://www.fugerit.org"
Expand Down
6 changes: 6 additions & 0 deletions docgen/release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.6.1 (2022-12-22)
------------------
+ Added doc(x) and xls(x) validators
+ Corrected type in package name

0.6.0 (2022-12-20)
------------------
+ Added compatibility check for Tiff Image Validator (required java 9+ at runtime)
Expand All @@ -7,6 +12,7 @@
0.5.11 (2022-12-19)
------------------
+ Added doc type validation module (fj-doc-val)
+ Now fj-doc requires java9+ at build time (will be build with java 11), java8 at runtime (some functionalities will not works)

0.5.10 (2022-12-12)
------------------
Expand Down
11 changes: 11 additions & 0 deletions fj-doc-val/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@
<artifactId>pdfbox</artifactId>
<version>${pdfbox-version}</version>
</dependency>

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>${poi-version}</version>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
package org.fugerit.java.doc.val.pdf.boc;

import java.io.InputStream;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.fugerit.java.doc.val.core.DocTypeValidationResult;
import org.fugerit.java.doc.val.core.DocTypeValidator;
import org.fugerit.java.doc.val.core.basic.AbstractDocTypeValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PdfboxValidator extends AbstractDocTypeValidator {

private static final Logger logger = LoggerFactory.getLogger( PdfboxValidator.class );

public static final String EXTENSION = "PDF";

public static final String MIME_TYPE = "application/pdf";

public static final DocTypeValidator DEFAULT = new PdfboxValidator();

public PdfboxValidator() {
super( MIME_TYPE, EXTENSION );
}

@Override
public DocTypeValidationResult validate(InputStream is) {
DocTypeValidationResult result = DocTypeValidationResult.newFail();
try {
PDDocument.load( is );
result = DocTypeValidationResult.newOk();
} catch (Exception e) {
logger.warn( "Failed check on pdf : "+e );
}
return result;
}
@Deprecated
public class PdfboxValidator extends org.fugerit.java.doc.val.pdf.box.PdfboxValidator {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.fugerit.java.doc.val.pdf.box;

import java.io.InputStream;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.fugerit.java.doc.val.core.DocTypeValidationResult;
import org.fugerit.java.doc.val.core.DocTypeValidator;
import org.fugerit.java.doc.val.core.basic.AbstractDocTypeValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PdfboxValidator extends AbstractDocTypeValidator {

private static final Logger logger = LoggerFactory.getLogger( PdfboxValidator.class );

public static final String EXTENSION = "PDF";

public static final String MIME_TYPE = "application/pdf";

public static final DocTypeValidator DEFAULT = new PdfboxValidator();

public PdfboxValidator() {
super( MIME_TYPE, EXTENSION );
}

@Override
public DocTypeValidationResult validate(InputStream is) {
DocTypeValidationResult result = DocTypeValidationResult.newFail();
try {
PDDocument.load( is );
result = DocTypeValidationResult.newOk();
} catch (Exception e) {
logger.warn( "Failed check on pdf : "+e );
}
return result;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.fugerit.java.doc.val.poi;

import java.io.InputStream;

import org.apache.poi.hwpf.HWPFDocument;
import org.fugerit.java.doc.val.core.DocTypeValidationResult;
import org.fugerit.java.doc.val.core.DocTypeValidator;
import org.fugerit.java.doc.val.core.basic.AbstractDocTypeValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DocValidator extends AbstractDocTypeValidator {

private static final Logger logger = LoggerFactory.getLogger( DocValidator.class );

public static final String EXTENSION = "DOC";

public static final String MIME_TYPE = "application/msword";

public static final DocTypeValidator DEFAULT = new DocValidator();

public DocValidator() {
super( MIME_TYPE, EXTENSION );
}

@Override
public DocTypeValidationResult validate(InputStream is) {
DocTypeValidationResult result = DocTypeValidationResult.newFail();
try ( HWPFDocument workbook = new HWPFDocument( is ) ) {
result = DocTypeValidationResult.newOk();
} catch (Exception e) {
logger.warn( "Failed check on pdf : "+e );
}
return result;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.fugerit.java.doc.val.poi;

import java.io.InputStream;

import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.fugerit.java.doc.val.core.DocTypeValidationResult;
import org.fugerit.java.doc.val.core.DocTypeValidator;
import org.fugerit.java.doc.val.core.basic.AbstractDocTypeValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DocxValidator extends AbstractDocTypeValidator {

private static final Logger logger = LoggerFactory.getLogger( DocxValidator.class );

public static final String EXTENSION = "DOCX";

public static final String MIME_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";

public static final DocTypeValidator DEFAULT = new DocxValidator();

public DocxValidator() {
super( MIME_TYPE, EXTENSION );
}

@Override
public DocTypeValidationResult validate(InputStream is) {
DocTypeValidationResult result = DocTypeValidationResult.newFail();
try ( XWPFDocument workbook = new XWPFDocument( is ) ) {
result = DocTypeValidationResult.newOk();
} catch (Exception e) {
logger.warn( "Failed check on pdf : "+e );
}
return result;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.fugerit.java.doc.val.poi;

import java.io.InputStream;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.fugerit.java.doc.val.core.DocTypeValidationResult;
import org.fugerit.java.doc.val.core.DocTypeValidator;
import org.fugerit.java.doc.val.core.basic.AbstractDocTypeValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class XlsValidator extends AbstractDocTypeValidator {

private static final Logger logger = LoggerFactory.getLogger( XlsValidator.class );

public static final String EXTENSION = "XLS";

public static final String MIME_TYPE = "application/vnd.ms-excel";

public static final DocTypeValidator DEFAULT = new XlsValidator();

public XlsValidator() {
super( MIME_TYPE, EXTENSION );
}

@Override
public DocTypeValidationResult validate(InputStream is) {
DocTypeValidationResult result = DocTypeValidationResult.newFail();
try ( HSSFWorkbook workbook = new HSSFWorkbook( is ) ) {
result = DocTypeValidationResult.newOk();
} catch (Exception e) {
logger.warn( "Failed check on pdf : "+e );
}
return result;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.fugerit.java.doc.val.poi;

import java.io.InputStream;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.fugerit.java.doc.val.core.DocTypeValidationResult;
import org.fugerit.java.doc.val.core.DocTypeValidator;
import org.fugerit.java.doc.val.core.basic.AbstractDocTypeValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class XlsxValidator extends AbstractDocTypeValidator {

private static final Logger logger = LoggerFactory.getLogger( XlsxValidator.class );

public static final String EXTENSION = "XLSX";

public static final String MIME_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

public static final DocTypeValidator DEFAULT = new XlsxValidator();

public XlsxValidator() {
super( MIME_TYPE, EXTENSION );
}

@Override
public DocTypeValidationResult validate(InputStream is) {
DocTypeValidationResult result = DocTypeValidationResult.newFail();
try ( XSSFWorkbook workbook = new XSSFWorkbook( is ) ) {
result = DocTypeValidationResult.newOk();
} catch (Exception e) {
logger.warn( "Failed check on pdf : "+e );
}
return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.fugerit.java.doc.val.core.DocValidatorFacade;
import org.fugerit.java.doc.val.core.basic.ImageValidator;
import org.fugerit.java.doc.val.pdf.boc.PdfboxValidator;
import org.fugerit.java.doc.val.pdf.box.PdfboxValidator;
import org.junit.Test;

public class TestAllFacade extends TestDocValidatorFacade {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package test.org.fugerit.java.doc.val;

import org.fugerit.java.doc.val.core.DocValidatorFacade;
import org.fugerit.java.doc.val.pdf.boc.PdfboxValidator;
import org.fugerit.java.doc.val.pdf.box.PdfboxValidator;
import org.junit.Test;

public class TestPdfBoxValidator extends TestDocValidatorFacade {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package test.org.fugerit.java.doc.val;

import org.fugerit.java.doc.val.core.DocValidatorFacade;
import org.fugerit.java.doc.val.poi.DocValidator;
import org.fugerit.java.doc.val.poi.DocxValidator;
import org.fugerit.java.doc.val.poi.XlsValidator;
import org.fugerit.java.doc.val.poi.XlsxValidator;
import org.junit.Test;

public class TestPoiValidator extends TestDocValidatorFacade {

private static final DocValidatorFacade FACADE = DocValidatorFacade.newFacadeStrict(
DocxValidator.DEFAULT,
DocValidator.DEFAULT,
XlsxValidator.DEFAULT,
XlsValidator.DEFAULT
);

@Test
public void testDocAsDoc() {
this.worker(FACADE, "doc_as_doc.doc", true );
}

@Test
public void testDocxAsDocx() {
this.worker(FACADE, "docx_as_docx.docx", true );
}

@Test
public void testXlsAsXls() {
this.worker(FACADE, "xls_as_xls.xls", true );
}

@Test
public void testXlsxAsXlsx() {
this.worker(FACADE, "xlsx_as_xlsx.xlsx", true );
}

@Test
public void testDocxAsDoc() {
this.worker(FACADE, "docx_as_doc.doc", false );
}

@Test
public void testJpgAsXlsx() {
this.worker(FACADE, "jpg_as_xlsx.xlsx", false );
}

@Test
public void testXlsxAsXls() {
this.worker(FACADE, "xlsx_as_xls.xls", false );
}

}
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit d3d56cd

Please sign in to comment.