Skip to content

Commit b40eee6

Browse files
committed
[fj-doc-playground-quarkus] quarkus-info extension
1 parent a7e07f7 commit b40eee6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1054
-977
lines changed

CHANGELOG.md

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

1010
### Changed
1111

12+
- [fj-doc-playground-quarkus] quarkus-info extension
1213
- concurrency setup for GitHub workflows
1314

1415
### Fixed

fj-doc-playground-quarkus/pom.xml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<?xml version="1.0"?>
2-
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44
<parent>
55
<groupId>org.fugerit.java</groupId>
@@ -73,6 +73,10 @@
7373
<groupId>io.quarkus</groupId>
7474
<artifactId>quarkus-builder</artifactId>
7575
</dependency>
76+
<dependency>
77+
<groupId>io.quarkus</groupId>
78+
<artifactId>quarkus-info</artifactId>
79+
</dependency>
7680
<dependency>
7781
<groupId>io.quarkus</groupId>
7882
<artifactId>quarkus-junit5</artifactId>
@@ -82,7 +86,7 @@
8286
<groupId>io.rest-assured</groupId>
8387
<artifactId>rest-assured</artifactId>
8488
<scope>test</scope>
85-
</dependency>
89+
</dependency>
8690
<dependency>
8791
<groupId>org.fugerit.java</groupId>
8892
<artifactId>fj-doc-sample</artifactId>
@@ -93,15 +97,15 @@
9397
<groupId>xml-apis</groupId>
9498
</exclusion>
9599
</exclusions>
96-
</dependency>
100+
</dependency>
97101
<dependency>
98102
<groupId>org.fugerit.java</groupId>
99103
<artifactId>fj-doc-val</artifactId>
100104
<exclusions>
101-
<exclusion>
102-
<artifactId>xml-apis</artifactId>
103-
<groupId>xml-apis</groupId>
104-
</exclusion>
105+
<exclusion>
106+
<artifactId>xml-apis</artifactId>
107+
<groupId>xml-apis</groupId>
108+
</exclusion>
105109
</exclusions>
106110
</dependency>
107111
<dependency>
@@ -110,8 +114,8 @@
110114
<version>${fj-doc-version}</version>
111115
<exclusions>
112116
<exclusion>
113-
<artifactId>*</artifactId>
114117
<groupId>*</groupId>
118+
<artifactId>*</artifactId>
115119
</exclusion>
116120
</exclusions>
117121
</dependency>
@@ -408,9 +412,9 @@
408412
<pdf-theme>basic</pdf-theme>
409413
<pdf-themesdir>${project.basedir}/src/main/docs/asciidoc/resources/themes</pdf-themesdir>
410414
<icons>font</icons>
411-
<pagenums/>
412-
<toc/>
413-
<idprefix/>
415+
<pagenums />
416+
<toc />
417+
<idprefix />
414418
<idseparator>-</idseparator>
415419
</attributes>
416420
</configuration>
@@ -437,10 +441,10 @@
437441
<source-highlighter>rouge</source-highlighter>
438442
<imagesdir>resources/images</imagesdir>
439443
<icons>font</icons>
440-
<no-toc/>
444+
<no-toc />
441445
<sectanchors>true</sectanchors>
442446
<!-- set the idprefix to blank -->
443-
<idprefix/>
447+
<idprefix />
444448
<idseparator>-</idseparator>
445449
<docinfo1>true</docinfo1>
446450
</attributes>
@@ -462,7 +466,7 @@
462466
<toc>left</toc>
463467
<sectanchors>true</sectanchors>
464468
<!-- set the idprefix to blank -->
465-
<idprefix/>
469+
<idprefix />
466470
<idseparator>-</idseparator>
467471
<docinfo1>true</docinfo1>
468472
</attributes>
@@ -546,11 +550,11 @@
546550
</goals>
547551
<configuration>
548552
<target>
549-
<delete dir="${fe.dist.dir}"/>
550-
<mkdir dir="${fe.dist.dir}"/>
553+
<delete dir="${fe.dist.dir}" />
554+
<mkdir dir="${fe.dist.dir}" />
551555
<copy todir="${fe.dist.dir}">
552556
<fileset dir="${src.react}/dist">
553-
<include name="**/*.*"/>
557+
<include name="**/*.*" />
554558
</fileset>
555559
</copy>
556560
</target>

fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/InitPlayground.java

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,26 @@
1313
@Slf4j
1414
@ApplicationScoped
1515
public class InitPlayground {
16-
17-
public static final String OUTPUT_FORMAT_PDF_A = "pdfa";
18-
19-
private static final FreemarkerDocProcessConfig PROCESS_CONFIG = FreemarkerDocProcessConfigFacade.loadConfigSafe( "cl://playground-config/fm-playground-doc-process.xml" );
20-
21-
public static final DocTypeHandler PDF_FOP_TYPE_HANDLER = PROCESS_CONFIG.getFacade().findHandler( "pdf-fop" );
22-
23-
public static final DocTypeHandler PDFA_FOP_TYPE_HANDLER = PROCESS_CONFIG.getFacade().findHandler( "PDF/A-1a" );
24-
25-
void onStart(@Observes StartupEvent ev) {
26-
log.info( "InitPlayground start {}", ev );
27-
InitHandler.initDocAsync( PDF_FOP_TYPE_HANDLER );
28-
log.info( "InitPlayground PDF_FOP_TYPE_HANDLER -> {}", PDF_FOP_TYPE_HANDLER );
29-
log.info( "InitPlayground PDFA_FOP_TYPE_HANDLER -> {}", PDFA_FOP_TYPE_HANDLER );
30-
log.info( "InitPlayground end" );
31-
}
32-
33-
public static DocTypeHandler findHandler( String id ) {
34-
return PROCESS_CONFIG.getFacade().findHandler( id );
35-
}
36-
16+
17+
public static final String OUTPUT_FORMAT_PDF_A = "pdfa";
18+
19+
private static final FreemarkerDocProcessConfig PROCESS_CONFIG = FreemarkerDocProcessConfigFacade
20+
.loadConfigSafe("cl://playground-config/fm-playground-doc-process.xml");
21+
22+
public static final DocTypeHandler PDF_FOP_TYPE_HANDLER = PROCESS_CONFIG.getFacade().findHandler("pdf-fop");
23+
24+
public static final DocTypeHandler PDFA_FOP_TYPE_HANDLER = PROCESS_CONFIG.getFacade().findHandler("PDF/A-1a");
25+
26+
void onStart(@Observes StartupEvent ev) {
27+
log.info("InitPlayground start {}", ev);
28+
InitHandler.initDocAsync(PDF_FOP_TYPE_HANDLER);
29+
log.info("InitPlayground PDF_FOP_TYPE_HANDLER -> {}", PDF_FOP_TYPE_HANDLER);
30+
log.info("InitPlayground PDFA_FOP_TYPE_HANDLER -> {}", PDFA_FOP_TYPE_HANDLER);
31+
log.info("InitPlayground end");
32+
}
33+
34+
public static DocTypeHandler findHandler(String id) {
35+
return PROCESS_CONFIG.getFacade().findHandler(id);
36+
}
37+
3738
}

fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/RestHelper.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,25 @@
88
@Slf4j
99
public class RestHelper {
1010

11-
private RestHelper() {}
11+
private RestHelper() {
12+
}
1213

13-
public static Throwable findCause( Throwable o ) {
14-
return o.getCause() != null ? findCause( o.getCause() ) : o;
15-
}
14+
public static Throwable findCause(Throwable o) {
15+
return o.getCause() != null ? findCause(o.getCause()) : o;
16+
}
17+
18+
public static Response defaultHandle(UnsafeSupplier<Response, Exception> fun) {
19+
Response res = null;
20+
try {
21+
res = fun.get();
22+
if (res == null) {
23+
res = Response.status(Response.Status.BAD_REQUEST).build();
24+
}
25+
} catch (Exception e) {
26+
log.info("Error : " + e, e);
27+
res = Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
28+
}
29+
return res;
30+
}
1631

17-
public static Response defaultHandle( UnsafeSupplier<Response, Exception> fun ) {
18-
Response res = null;
19-
try {
20-
res = fun.get();
21-
if ( res == null ) {
22-
res = Response.status(Response.Status.BAD_REQUEST).build();
23-
}
24-
} catch (Exception e) {
25-
log.info("Error : " + e, e);
26-
res = Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
27-
}
28-
return res;
29-
}
30-
3132
}

fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/catalog/CatalogOutput.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
@JsonInclude(Include.NON_NULL)
1212
public class CatalogOutput extends BasicOutput {
1313

14-
@Getter @Setter private String docOutput;
14+
@Getter
15+
@Setter
16+
private String docOutput;
17+
18+
@Getter
19+
@Setter
20+
private String jsonData;
1521

16-
@Getter @Setter private String jsonData;
17-
1822
}

fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/catalog/CatalogRest.java

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -25,62 +25,62 @@
2525
@Path("/catalog")
2626
public class CatalogRest {
2727

28-
@GET
29-
@Produces(MediaType.APPLICATION_JSON)
30-
@Path("/list/type/{type}")
31-
public Response catalogListFilterType( @PathParam("type") String type ) {
28+
@GET
29+
@Produces(MediaType.APPLICATION_JSON)
30+
@Path("/list/type/{type}")
31+
public Response catalogListFilterType(@PathParam("type") String type) {
3232

33-
return RestHelper.defaultHandle( () -> Response.ok().entity(
34-
DocCatalogSample.getInstance().getPlaygroundCoreCatalog()
35-
.stream().filter( e -> type.equalsIgnoreCase( e.getType() ) ).map(
36-
e -> new OptionItem( e.getId(), e.getDescription() )
37-
).toList() ).build()
38-
);
39-
}
40-
41-
@GET
42-
@Produces(MediaType.APPLICATION_JSON)
43-
@Path("/list")
44-
public Response catalogList() {
45-
return RestHelper.defaultHandle( () -> Response.ok().entity(
46-
DocCatalogSample.getInstance().getPlaygroundCoreCatalog()
47-
.stream().map(
48-
e -> new OptionItem( e.getId(), e.getDescription() )
49-
).toList() ).build()
50-
);
51-
}
52-
53-
@GET
54-
@Produces(MediaType.APPLICATION_JSON)
55-
@Path("/entry/{id}")
56-
public Response catalogEntry( @PathParam("id") String id ) {
57-
return RestHelper.defaultHandle( () -> {
58-
DocCatalogSample catalog = DocCatalogSample.getInstance();
59-
DocCatalogEntry entry = catalog.getPlaygroundCoreCatalog().get( id );
60-
try ( Reader reader = catalog.entryReader( entry ) ) {
61-
CatalogOutput output = new CatalogOutput();
62-
output.setDocOutput( StreamIO.readString( reader ) );
63-
if ( StringUtils.isNotEmpty( entry.getJsonDataPath() ) ) {
64-
output.setJsonData( StreamIO.readString( catalog.entryReaderJsonData( entry ) ) );
65-
}
66-
return Response.ok().entity( output ).build();
67-
}
68-
} );
69-
}
33+
return RestHelper.defaultHandle(() -> Response.ok().entity(
34+
DocCatalogSample.getInstance().getPlaygroundCoreCatalog()
35+
.stream().filter(e -> type.equalsIgnoreCase(e.getType())).map(
36+
e -> new OptionItem(e.getId(), e.getDescription()))
37+
.toList())
38+
.build());
39+
}
40+
41+
@GET
42+
@Produces(MediaType.APPLICATION_JSON)
43+
@Path("/list")
44+
public Response catalogList() {
45+
return RestHelper.defaultHandle(() -> Response.ok().entity(
46+
DocCatalogSample.getInstance().getPlaygroundCoreCatalog()
47+
.stream().map(
48+
e -> new OptionItem(e.getId(), e.getDescription()))
49+
.toList())
50+
.build());
51+
}
52+
53+
@GET
54+
@Produces(MediaType.APPLICATION_JSON)
55+
@Path("/entry/{id}")
56+
public Response catalogEntry(@PathParam("id") String id) {
57+
return RestHelper.defaultHandle(() -> {
58+
DocCatalogSample catalog = DocCatalogSample.getInstance();
59+
DocCatalogEntry entry = catalog.getPlaygroundCoreCatalog().get(id);
60+
try (Reader reader = catalog.entryReader(entry)) {
61+
CatalogOutput output = new CatalogOutput();
62+
output.setDocOutput(StreamIO.readString(reader));
63+
if (StringUtils.isNotEmpty(entry.getJsonDataPath())) {
64+
output.setJsonData(StreamIO.readString(catalog.entryReaderJsonData(entry)));
65+
}
66+
return Response.ok().entity(output).build();
67+
}
68+
});
69+
}
70+
71+
@GET
72+
@Produces(MediaType.TEXT_PLAIN)
73+
@Path("/res/{id}")
74+
public Response catalogRes(@PathParam("id") String id) {
75+
return RestHelper.defaultHandle(() -> {
76+
try (InputStream is = ClassHelper.loadFromDefaultClassLoader("catalog_res/" + id)) {
77+
if (is == null) {
78+
return Response.status(Response.Status.NOT_FOUND).build();
79+
} else {
80+
return Response.ok().entity(StreamIO.readString(is)).build();
81+
}
82+
}
83+
});
84+
}
7085

71-
@GET
72-
@Produces(MediaType.TEXT_PLAIN)
73-
@Path("/res/{id}")
74-
public Response catalogRes( @PathParam("id") String id ) {
75-
return RestHelper.defaultHandle( () -> {
76-
try (InputStream is = ClassHelper.loadFromDefaultClassLoader( "catalog_res/"+id )) {
77-
if ( is == null ) {
78-
return Response.status(Response.Status.NOT_FOUND).build();
79-
} else {
80-
return Response.ok().entity( StreamIO.readString( is ) ).build();
81-
}
82-
}
83-
} );
84-
}
85-
8686
}

fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/config/ConvertConfigFacade.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
@ApplicationScoped
1313
public class ConvertConfigFacade {
1414

15-
public String convertHelper(ConvertConfigInput input) throws Exception {
16-
String result = null;
17-
if ( input.getDocContent() != null && input.getFreemarkerJsonData() != null ) {
18-
try (StringReader paramsReader = new StringReader( input.getFreemarkerJsonData() );
19-
InputStream reader = new ByteArrayInputStream( input.getDocContent().getBytes( StandardCharsets.UTF_8 ) );
20-
Writer writer = new StringWriter() ) {
21-
Properties params = new Properties();
22-
params.load( paramsReader );
23-
GenerateStub.generate( writer, params, reader );
24-
result = writer.toString();
25-
}
26-
}
27-
return result;
28-
}
15+
public String convertHelper(ConvertConfigInput input) throws Exception {
16+
String result = null;
17+
if (input.getDocContent() != null && input.getFreemarkerJsonData() != null) {
18+
try (StringReader paramsReader = new StringReader(input.getFreemarkerJsonData());
19+
InputStream reader = new ByteArrayInputStream(input.getDocContent().getBytes(StandardCharsets.UTF_8));
20+
Writer writer = new StringWriter()) {
21+
Properties params = new Properties();
22+
params.load(paramsReader);
23+
GenerateStub.generate(writer, params, reader);
24+
result = writer.toString();
25+
}
26+
}
27+
return result;
28+
}
2929

3030
}

fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/config/ConvertConfigInput.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import org.fugerit.java.doc.playground.facade.BasicInput;
66

77
public class ConvertConfigInput extends BasicInput {
8-
9-
@Setter @Getter private String freemarkerJsonData;
10-
8+
9+
@Setter
10+
@Getter
11+
private String freemarkerJsonData;
12+
1113
}

0 commit comments

Comments
 (0)