Skip to content

Commit 6ee1796

Browse files
authored
Merge pull request #66 from fugerit-org/feature/issue_65_deprecation
FopConfigClassLoader (previously deprecated) (#61)
2 parents a16972f + b84a4cd commit 6ee1796

File tree

13 files changed

+266
-113
lines changed

13 files changed

+266
-113
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Removed
11+
12+
- FopConfigClassLoader (previously deprecated) (#61)
13+
1014
## [2.0.0] - 2023-09-05
1115

1216
### Changed

fj-doc-mod-fop/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@
5353
<artifactId>fj-doc-freemarker</artifactId>
5454
</dependency>
5555

56+
<dependency>
57+
<groupId>org.fugerit.java</groupId>
58+
<artifactId>fj-test-helper8</artifactId>
59+
<scope>test</scope>
60+
<exclusions>
61+
<exclusion>
62+
<groupId>*</groupId>
63+
<artifactId>*</artifactId>
64+
</exclusion>
65+
</exclusions>
66+
</dependency>
67+
5668
</dependencies>
5769

5870
<organization>

fj-doc-mod-fop/src/main/java/org/fugerit/java/doc/mod/fop/PdfFopTypeHandler.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.fugerit.java.doc.base.config.DocInput;
3030
import org.fugerit.java.doc.base.config.DocOutput;
3131
import org.fugerit.java.doc.base.config.DocTypeHandler;
32-
import org.fugerit.java.doc.mod.fop.config.FopConfigClassLoader;
3332
import org.fugerit.java.doc.mod.fop.config.FopConfigClassLoaderWrapper;
3433
import org.w3c.dom.Element;
3534

@@ -46,12 +45,7 @@ public class PdfFopTypeHandler extends FreeMarkerFopTypeHandler {
4645
public static final String ATT_FOP_CONFIG_MODE_DEFAULT = "default";
4746
public static final String ATT_FOP_CONFIG_MODE_CLASS_LOADER = "classloader";
4847

49-
50-
/**
51-
* @deprecated planned for removal in version 1.6 (see https://github.com/fugerit-org/fj-doc/issues/7)
52-
*/
53-
@Deprecated
54-
public static final String ATT_FOP_CONFIG_MODE_CLASS_LOADER_LEGACY = "classloader-legacy";
48+
private static final String ATT_FOP_CONFIG_MODE_CLASS_LOADER_LEGACY = "classloader-legacy"; // removed as of v2.0.1
5549

5650
public static final String ATT_FOP_CONFIG_CLASSLOADER_PATH = "fop-config-classloader-path";
5751

@@ -74,11 +68,7 @@ public class PdfFopTypeHandler extends FreeMarkerFopTypeHandler {
7468
private static final String[] VALID_PDF_UA = { ATT_PDF_UA_MODE_PDF_UA_1 };
7569
public static final List<String> VALID_PDF_UA_MODES = Arrays.asList( VALID_PDF_UA );
7670

77-
/**
78-
* @deprecated planned for removal in version 1.6 (see https://github.com/fugerit-org/fj-doc/issues/7)
79-
*/
80-
@Deprecated
81-
public static final String ATT_FONT_BASE_CLASSLOADER_PATH = "font-base-classloader-path";
71+
private static final String ATT_FONT_BASE_CLASSLOADER_PATH = "font-base-classloader-path"; // removed as of v2.0.1
8272

8373
public static final boolean DEFAULT_ACCESSIBILITY = true;
8474

@@ -197,7 +187,8 @@ protected void handleConfigTag(Element config) throws ConfigException {
197187
// legacy class loader mode
198188
if ( StringUtils.isEmpty( fopConfigMode ) && StringUtils.isNotEmpty( fopConfigClassloaderPath ) && StringUtils.isNotEmpty( fontBaseClassloaderPath ) ) {
199189
fopConfigMode = ATT_FOP_CONFIG_MODE_CLASS_LOADER_LEGACY;
200-
log.warn( "Activated legacy ClassLoader mode. It is strongly recomended to update te configuration {} -> {}", ATT_FOP_CONFIG_MODE_CLASS_LOADER_LEGACY, FopConfigClassLoader.MIN_VERSION_NEW_CLASSLOADER_MODE );
190+
log.warn( "Activated legacy ClassLoader mode. it is now deprecated : {}", ATT_FOP_CONFIG_MODE_CLASS_LOADER_LEGACY );
191+
throw new ConfigException( "Depcreated config mode, see github fugerit-org/fj-doc repository, issue 65" );
201192
}
202193
if ( ATT_FOP_CONFIG_MODE_CLASS_LOADER.equalsIgnoreCase( fopConfigMode ) ) {
203194
try {
@@ -208,8 +199,8 @@ protected void handleConfigTag(Element config) throws ConfigException {
208199
throw new ConfigException( PdfFopTypeHandler.class.getSimpleName()+" configuration error : "+e, e );
209200
}
210201
} else if ( ATT_FOP_CONFIG_MODE_CLASS_LOADER_LEGACY.equalsIgnoreCase( fopConfigMode ) ) {
211-
FopConfigClassLoader fopConfigClassLoader = new FopConfigClassLoader(fopConfigClassloaderPath, fontBaseClassloaderPath);
212-
this.fopConfig = fopConfigClassLoader;
202+
log.warn( "Activated legacy ClassLoader mode. it is now deprecated : {}", ATT_FOP_CONFIG_MODE_CLASS_LOADER_LEGACY );
203+
throw new ConfigException( "Depcreated config mode, see github fugerit-org/fj-doc repository, issue 65" );
213204
}
214205
}
215206

fj-doc-mod-fop/src/main/java/org/fugerit/java/doc/mod/fop/config/ClassLoaderResourceResolver.java

Lines changed: 0 additions & 69 deletions
This file was deleted.

fj-doc-mod-fop/src/main/java/org/fugerit/java/doc/mod/fop/config/FopConfigClassLoader.java

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package test.org.fugerit.java.doc.mod.fop;
2+
3+
import java.io.FileOutputStream;
4+
import java.io.InputStreamReader;
5+
6+
import org.fugerit.java.core.cfg.ConfigRuntimeException;
7+
import org.fugerit.java.core.lang.helpers.ClassHelper;
8+
import org.fugerit.java.core.xml.dom.DOMIO;
9+
import org.fugerit.java.doc.base.config.DocInput;
10+
import org.fugerit.java.doc.base.config.DocOutput;
11+
import org.fugerit.java.doc.base.config.DocTypeHandler;
12+
import org.fugerit.java.doc.mod.fop.FopConfig;
13+
import org.fugerit.java.doc.mod.fop.FopConfigDefault;
14+
import org.fugerit.java.doc.mod.fop.PdfFopTypeHandler;
15+
import org.junit.Assert;
16+
import org.junit.Test;
17+
import org.w3c.dom.Document;
18+
19+
import test.org.fugerit.java.BasicTest;
20+
21+
public class TestPdfFopTypeHandler extends BasicTest {
22+
23+
private boolean testHelper( DocTypeHandler handler ) {
24+
boolean ok = false;
25+
try ( InputStreamReader reader = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( "sample/doc_test_01.xml" ) );
26+
FileOutputStream fos = new FileOutputStream( "target/test"+System.currentTimeMillis()+"."+handler.getType() ) ) {
27+
handler.handle( DocInput.newInput( handler.getType(), reader ) , DocOutput.newOutput( fos ) );
28+
ok = true;
29+
} catch (Exception e) {
30+
this.failEx( e );
31+
}
32+
return ok;
33+
}
34+
35+
@Test
36+
public void test001Ok() {
37+
FopConfig config = new FopConfigDefault();
38+
PdfFopTypeHandler handler = new PdfFopTypeHandler();
39+
handler.setFopConfig( config );
40+
boolean ok = this.testHelper(handler);
41+
Assert.assertTrue(ok);
42+
}
43+
44+
private boolean configureHelper( String path ) {
45+
boolean ok = false;
46+
try ( InputStreamReader reader = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( path ) ) ) {
47+
Document doc = DOMIO.loadDOMDoc(reader);
48+
PdfFopTypeHandler handler = new PdfFopTypeHandler();
49+
handler.configure( doc.getDocumentElement() );
50+
ok = true;
51+
} catch (Exception e) {
52+
throw new ConfigRuntimeException( e );
53+
}
54+
return ok;
55+
}
56+
57+
@Test
58+
public void test002Ko() {
59+
Assert.assertThrows( ConfigRuntimeException.class , () -> {
60+
this.configureHelper( "config/test_config_err1.xml" );
61+
});
62+
}
63+
64+
65+
@Test
66+
public void test003Ok() {
67+
boolean ok = this.configureHelper( "config/test_config_ok.xml" );
68+
Assert.assertTrue(ok);
69+
}
70+
71+
@Test
72+
public void test004Ko() {
73+
Assert.assertThrows( ConfigRuntimeException.class , () -> {
74+
this.configureHelper( "config/test_config_err2.xml" );
75+
});
76+
}
77+
78+
79+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<docHandler id="pdf_a-fop" info="pdf" type="org.fugerit.java.doc.mod.fop.PdfFopTypeHandler">
2+
<docHandlerCustomConfig
3+
fop-config-mode="classloader-legacy"
4+
font-base-classloader-path="font/"/>
5+
</docHandler>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<docHandler id="pdf_a-fop" info="pdf" type="org.fugerit.java.doc.mod.fop.PdfFopTypeHandler">
2+
<docHandlerCustomConfig
3+
fop-config-classloader-path="."
4+
font-base-classloader-path="font/"/>
5+
</docHandler>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<docHandler id="pdf-fop" info="pdf" type="org.fugerit.java.doc.mod.fop.PdfFopTypeHandler">
2+
<docHandlerCustomConfig charset="UTF-8" fop-config-mode="classloader" fop-config-classloader-path="fop-config.xml" pdf-a-mode="PDF/A-1b" pdf-ua-mode="PDF/UA-1"/>
3+
</docHandler>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<fop version="1.0">
2+
3+
<!-- Strict user configuration -->
4+
<strict-configuration>true</strict-configuration>
5+
6+
<!-- Strict FO validation -->
7+
<strict-validation>true</strict-validation>
8+
9+
<!-- Base URL for resolving relative URLs -->
10+
<base>.</base>
11+
12+
<!-- Font Base URL for resolving relative font URLs -->
13+
<font-base>.</font-base>
14+
15+
<renderers>
16+
<renderer mime="application/pdf">
17+
</renderer>
18+
</renderers>
19+
20+
21+
<!-- Source resolution in dpi (dots/pixels per inch) for determining the size of pixels in SVG and bitmap images, default: 72dpi -->
22+
<source-resolution>72</source-resolution>
23+
<!-- Target resolution in dpi (dots/pixels per inch) for specifying the target resolution for generated bitmaps, default: 72dpi -->
24+
<target-resolution>72</target-resolution>
25+
26+
<!-- default page-height and page-width, in case
27+
value is specified as auto -->
28+
<default-page-settings height="11in" width="8.26in"/>
29+
30+
</fop>

0 commit comments

Comments
 (0)