This repository has been archived by the owner on Jul 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08c512d
commit ce13b24
Showing
17 changed files
with
372 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Steps: | ||
- Init Wildfly | ||
- Deploy your app | ||
|
||
```shell | ||
mvn wildfly:deploy -f xbuilder-jee-vanilla/ | ||
``` | ||
|
||
- Open [http://localhost:8080/xbuilder-jee-vanilla](http://localhost:8080/xbuilder-jee-vanilla) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Execute Main.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Steps: | ||
- Init Wildfly | ||
- Deploy your app | ||
|
||
```shell | ||
mvn wildfly:deploy -f xsender-jee-vanilla/ | ||
``` | ||
|
||
- Open [http://localhost:8080/xsender-jee-vanilla](http://localhost:8080/xsender-jee-vanilla) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
Copyright 2019 Project OpenUBL, Inc. and/or its affiliates | ||
and other contributors as indicated by the @author tags. | ||
Licensed under the Eclipse Public License - v 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
https://www.eclipse.org/legal/epl-2.0/ | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.github.project-openubl</groupId> | ||
<artifactId>openubl-quickstarts</artifactId> | ||
<version>3.0.2-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>xsender-jee-vanilla</artifactId> | ||
<name>XSender JEE vanilla</name> | ||
<packaging>war</packaging> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<!-- importing the jakartaee8-with-tools BOM adds specs and other useful artifacts as managed dependencies --> | ||
<dependency> | ||
<groupId>org.wildfly.bom</groupId> | ||
<artifactId>wildfly-jakartaee8-with-tools</artifactId> | ||
<version>${version.server.bom}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.github.project-openubl</groupId> | ||
<artifactId>xsender</artifactId> | ||
<version>${xsender.version}</version> | ||
</dependency> | ||
|
||
<!-- Import the CDI API, we use provided scope as the API is included in JBoss EAP --> | ||
<dependency> | ||
<groupId>jakarta.enterprise</groupId> | ||
<artifactId>jakarta.enterprise.cdi-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Import the Common Annotations API (JSR-250), we use provided | ||
scope as the API is included in JBoss EAP --> | ||
<dependency> | ||
<groupId>org.jboss.spec.javax.annotation</groupId> | ||
<artifactId>jboss-annotations-api_1.3_spec</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Import the JAX-RS API, we use provided scope as the API is included in JBoss EAP. --> | ||
<dependency> | ||
<groupId>org.jboss.spec.javax.ws.rs</groupId> | ||
<artifactId>jboss-jaxrs-api_2.1_spec</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-jaxrs</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-multipart-provider</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.6</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>${project.artifactId}</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.wildfly.plugins</groupId> | ||
<artifactId>wildfly-maven-plugin</artifactId> | ||
<version>${version.wildfly.maven.plugin}</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
77 changes: 77 additions & 0 deletions
77
...r-jee-vanilla/src/main/java/io/github/project/openubl/quickstart/xsender/UBLResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* Copyright 2019 Project OpenUBL, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Eclipse Public License - v 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.github.project.openubl.quickstart.xsender; | ||
|
||
import io.github.project.openubl.xmlsenderws.webservices.exceptions.InvalidXMLFileException; | ||
import io.github.project.openubl.xmlsenderws.webservices.exceptions.UnsupportedDocumentTypeException; | ||
import io.github.project.openubl.xmlsenderws.webservices.managers.smart.SmartBillServiceModel; | ||
import org.apache.commons.io.IOUtils; | ||
import org.jboss.resteasy.plugins.providers.multipart.InputPart; | ||
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MultivaluedMap; | ||
import javax.ws.rs.core.Response; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Path("/file") | ||
public class UBLResource { | ||
|
||
@Inject | ||
UBLService ublService; | ||
|
||
@POST | ||
@Path("/upload") | ||
@Consumes("multipart/form-data") | ||
@Produces("text/plain") | ||
public Response uploadFile(MultipartFormDataInput input) { | ||
Map<String, List<InputPart>> uploadForm = input.getFormDataMap(); | ||
List<InputPart> inputParts = uploadForm.get("file"); | ||
|
||
for (InputPart inputPart : inputParts) { | ||
try { | ||
|
||
MultivaluedMap<String, String> header = inputPart.getHeaders(); | ||
|
||
//convert the uploaded file to inputstream | ||
InputStream inputStream = inputPart.getBody(InputStream.class, null); | ||
|
||
byte[] bytes = IOUtils.toByteArray(inputStream); | ||
|
||
|
||
SmartBillServiceModel result = ublService.sendToSUNAT(bytes); | ||
String message = result.getXmlContentModel().getDocumentType() + " " + result.getBillServiceModel().getStatus(); | ||
|
||
return Response.status(200) | ||
.entity(message).build(); | ||
} catch (IOException | InvalidXMLFileException | UnsupportedDocumentTypeException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
|
||
return Response.serverError().build(); | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...er-jee-vanilla/src/main/java/io/github/project/openubl/quickstart/xsender/UBLService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright 2019 Project OpenUBL, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Eclipse Public License - v 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.github.project.openubl.quickstart.xsender; | ||
|
||
import io.github.project.openubl.xmlsenderws.webservices.exceptions.InvalidXMLFileException; | ||
import io.github.project.openubl.xmlsenderws.webservices.exceptions.UnsupportedDocumentTypeException; | ||
import io.github.project.openubl.xmlsenderws.webservices.managers.smart.SmartBillServiceConfig; | ||
import io.github.project.openubl.xmlsenderws.webservices.managers.smart.SmartBillServiceManager; | ||
import io.github.project.openubl.xmlsenderws.webservices.managers.smart.SmartBillServiceModel; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
@ApplicationScoped | ||
public class UBLService { | ||
private final String username = "12345678912MODDATOS"; | ||
private final String password = "MODDATOS"; | ||
|
||
@PostConstruct | ||
private void init() { | ||
SmartBillServiceConfig.getInstance() | ||
.withInvoiceAndNoteDeliveryURL("https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService") | ||
.withPerceptionAndRetentionDeliveryURL("https://e-beta.sunat.gob.pe/ol-ti-itemision-otroscpe-gem-beta/billService") | ||
.withDespatchAdviceDeliveryURL("https://e-beta.sunat.gob.pe/ol-ti-itemision-guia-gem-beta/billService"); | ||
} | ||
|
||
public SmartBillServiceModel sendToSUNAT(byte[] file) throws InvalidXMLFileException, UnsupportedDocumentTypeException { | ||
return SmartBillServiceManager.send(file, username, password); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2019 Project OpenUBL, Inc. and/or its affiliates | ||
and other contributors as indicated by the @author tags. | ||
Licensed under the Eclipse Public License - v 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
https://www.eclipse.org/legal/epl-2.0/ | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<!-- Marker file indicating CDI should be enabled --> | ||
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation=" | ||
http://xmlns.jcp.org/xml/ns/javaee | ||
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" | ||
bean-discovery-mode="all"> | ||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!-- | ||
Copyright 2019 Project OpenUBL, Inc. and/or its affiliates | ||
and other contributors as indicated by the @author tags. | ||
Licensed under the Eclipse Public License - v 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
https://www.eclipse.org/legal/epl-2.0/ | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> | ||
<!-- One of the ways of activating REST Services is adding these lines. | ||
The server is responsible for adding the corresponding servlet automatically. | ||
The class org.jboss.as.quickstarts.html5rest.HelloWorld class has the | ||
annotation @Path("/") to receive the REST invocation --> | ||
<servlet-mapping> | ||
<servlet-name>javax.ws.rs.core.Application</servlet-name> | ||
<url-pattern>/api/*</url-pattern> | ||
</servlet-mapping> | ||
</web-app> |
Oops, something went wrong.