Skip to content

Commit 16de7ef

Browse files
modularize
1 parent d934129 commit 16de7ef

File tree

30 files changed

+1055
-180
lines changed

30 files changed

+1055
-180
lines changed

api-core/pom.xml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
4+
Copyright 2019 Project OpenUBL, Inc. and/or its affiliates
5+
and other contributors as indicated by the @author tags.
6+
7+
Licensed under the Eclipse Public License - v 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
https://www.eclipse.org/legal/epl-2.0/
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
21+
xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
23+
<modelVersion>4.0.0</modelVersion>
24+
<parent>
25+
<groupId>io.github.project-openubl</groupId>
26+
<artifactId>xml-sender</artifactId>
27+
<version>1.0.0-SNAPSHOT</version>
28+
<relativePath>../pom.xml</relativePath>
29+
</parent>
30+
31+
<artifactId>xml-sender-api-core</artifactId>
32+
<name>XML Sender :: API Core</name>
33+
34+
<dependencies>
35+
<!--Quarkus-->
36+
<dependency>
37+
<groupId>io.quarkus</groupId>
38+
<artifactId>quarkus-core</artifactId>
39+
</dependency>
40+
<dependency>
41+
<groupId>io.quarkus</groupId>
42+
<artifactId>quarkus-resteasy</artifactId>
43+
</dependency>
44+
45+
<dependency>
46+
<groupId>io.quarkus</groupId>
47+
<artifactId>quarkus-smallrye-health</artifactId>
48+
</dependency>
49+
<dependency>
50+
<groupId>io.quarkus</groupId>
51+
<artifactId>quarkus-smallrye-openapi</artifactId>
52+
</dependency>
53+
54+
<!--Test-->
55+
<dependency>
56+
<groupId>io.quarkus</groupId>
57+
<artifactId>quarkus-junit5</artifactId>
58+
<scope>test</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>io.rest-assured</groupId>
62+
<artifactId>rest-assured</artifactId>
63+
<scope>test</scope>
64+
</dependency>
65+
</dependencies>
66+
</project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright 2019 Project OpenUBL, Inc. and/or its affiliates
3+
* and other contributors as indicated by the @author tags.
4+
*
5+
* Licensed under the Eclipse Public License - v 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.eclipse.org/legal/epl-2.0/
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package io.github.project.openubl.xmlsender.resources;
18+
19+
import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition;
20+
import org.eclipse.microprofile.openapi.annotations.info.Contact;
21+
import org.eclipse.microprofile.openapi.annotations.info.Info;
22+
import org.eclipse.microprofile.openapi.annotations.info.License;
23+
24+
import javax.ws.rs.ApplicationPath;
25+
import javax.ws.rs.core.Application;
26+
27+
@OpenAPIDefinition(
28+
info = @Info(
29+
title = "XML Sender API",
30+
version = "1.0.0",
31+
contact = @Contact(
32+
name = "XML Sender API Support",
33+
url = "https://github.com/project-openubl/xml-sender/issues",
34+
email = "projectopenubl+subscribe@googlegroups.com"
35+
),
36+
license = @License(
37+
name = "Eclipse Public License - v 2.0",
38+
url = "https://www.eclipse.org/legal/epl-2.0/"
39+
)
40+
)
41+
)
42+
@ApplicationPath(ApiApplication.API_BASE)
43+
public class ApiApplication extends Application {
44+
public static final String API_BASE = "/api";
45+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Copyright 2019 Project OpenUBL, Inc. and/or its affiliates
3+
* and other contributors as indicated by the @author tags.
4+
*
5+
* Licensed under the Eclipse Public License - v 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.eclipse.org/legal/epl-2.0/
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package io.github.project.openubl.xmlsender.resources;
18+
19+
import org.jboss.resteasy.api.validation.ResteasyConstraintViolation;
20+
import org.jboss.resteasy.api.validation.ResteasyViolationException;
21+
22+
import javax.ws.rs.core.MediaType;
23+
import javax.ws.rs.core.Response;
24+
import javax.ws.rs.ext.ExceptionMapper;
25+
import javax.ws.rs.ext.Provider;
26+
import java.util.HashMap;
27+
import java.util.Map;
28+
29+
@Provider
30+
public class ValidationExceptionHandler implements ExceptionMapper<ResteasyViolationException> {
31+
@Override
32+
public Response toResponse(ResteasyViolationException e) {
33+
Map<String, String> violationMessages = new HashMap<>();
34+
for (ResteasyConstraintViolation violation : e.getViolations()) {
35+
String key = violation.getPath();
36+
violationMessages.put(key, "[" + violation.getValue() + "] " + violation.getMessage());
37+
}
38+
39+
return Response.status(400)
40+
.type(MediaType.APPLICATION_JSON)
41+
.entity(violationMessages)
42+
.build();
43+
}
44+
}

api/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
<version>${sunat-web-services.version}</version>
3838
</dependency>
3939

40+
<dependency>
41+
<groupId>io.github.project-openubl</groupId>
42+
<artifactId>xml-sender-core</artifactId>
43+
</dependency>
44+
4045
<!--Quarkus-->
4146
<dependency>
4247
<groupId>io.quarkus</groupId>

api/src/main/java/io/github/project/openubl/xmlsender/routes/FilesystemRoute.java renamed to api/src/main/java/io/github/project/openubl/xmlsender/camel/FilesystemRoute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
package io.github.project.openubl.xmlsender.routes;
17+
package io.github.project.openubl.xmlsender.camel;
1818

1919
import io.github.project.openubl.xmlsender.models.FileType;
2020
import org.apache.camel.LoggingLevel;

api/src/main/java/io/github/project/openubl/xmlsender/routes/S3FilesRoute.java renamed to api/src/main/java/io/github/project/openubl/xmlsender/camel/S3FilesRoute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
package io.github.project.openubl.xmlsender.routes;
17+
package io.github.project.openubl.xmlsender.camel;
1818

1919
import com.amazonaws.ClientConfiguration;
2020
import com.amazonaws.auth.AWSStaticCredentialsProvider;

api/src/main/java/io/github/project/openubl/xmlsender/exceptions/StorageException.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
package io.github.project.openubl.xmlsender.exceptions;
1818

1919
public class StorageException extends Exception {
20-
public StorageException(Exception e) {
21-
super(e);
22-
}
23-
2420
public StorageException(String message) {
2521
super(message);
2622
}

api/src/main/java/io/github/project/openubl/xmlsender/exceptions/UnsupportedDocumentTypeException.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
package io.github.project.openubl.xmlsender.exceptions;
1818

1919
public class UnsupportedDocumentTypeException extends Exception {
20-
public UnsupportedDocumentTypeException(Exception e) {
21-
super(e);
22-
}
23-
2420
public UnsupportedDocumentTypeException(String messasge) {
2521
super(messasge);
2622
}

api/src/main/java/io/github/project/openubl/xmlsender/jms/SendFileQueueConsumer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import io.quarkus.runtime.StartupEvent;
2121
import org.eclipse.microprofile.config.inject.ConfigProperty;
2222
import org.jboss.logging.Logger;
23-
import io.github.project.openubl.xmlsender.providers.WSProvider;
23+
import io.github.project.openubl.xmlsender.ws.WSSunatClient;
2424

2525
import javax.enterprise.context.ApplicationScoped;
2626
import javax.enterprise.event.Observes;
@@ -36,7 +36,7 @@ public class SendFileQueueConsumer implements Runnable {
3636
private static final Logger LOG = Logger.getLogger(SendFileQueueConsumer.class);
3737

3838
@Inject
39-
WSProvider wsProvider;
39+
WSSunatClient wsSunatClient;
4040

4141
@Inject
4242
ConnectionFactory connectionFactory;
@@ -74,8 +74,8 @@ public void run() {
7474
return;
7575
}
7676

77-
String entityId = textMessage.getText();
78-
boolean result = wsProvider.sendFileDelivery(Long.valueOf(entityId));
77+
String documentId = textMessage.getText();
78+
boolean result = wsSunatClient.sendDocument(Long.valueOf(documentId));
7979

8080
if (result) {
8181
message.acknowledge();

api/src/main/java/io/github/project/openubl/xmlsender/jms/SendTicketQueueConsumer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import io.quarkus.runtime.StartupEvent;
2121
import org.eclipse.microprofile.config.inject.ConfigProperty;
2222
import org.jboss.logging.Logger;
23-
import io.github.project.openubl.xmlsender.providers.WSProvider;
23+
import io.github.project.openubl.xmlsender.ws.WSSunatClient;
2424

2525
import javax.enterprise.context.ApplicationScoped;
2626
import javax.enterprise.event.Observes;
@@ -36,7 +36,7 @@ public class SendTicketQueueConsumer implements Runnable {
3636
private static final Logger LOG = Logger.getLogger(SendTicketQueueConsumer.class);
3737

3838
@Inject
39-
WSProvider wsProvider;
39+
WSSunatClient wsSunatClient;
4040

4141
@Inject
4242
ConnectionFactory connectionFactory;
@@ -75,7 +75,7 @@ public void run() {
7575
}
7676

7777
String entityId = textMessage.getText();
78-
boolean result = wsProvider.checkTicket(Long.parseLong(entityId));
78+
boolean result = wsSunatClient.checkDocumentTicket(Long.parseLong(entityId));
7979

8080
if (result) {
8181
message.acknowledge();

0 commit comments

Comments
 (0)