Resolving project problems
authorVásáry Dániel <vasary@elgekko.net>
Wed, 6 Mar 2024 13:21:56 +0000 (14:21 +0100)
committerVásáry Dániel <vasary@elgekko.net>
Wed, 6 Mar 2024 13:21:56 +0000 (14:21 +0100)
deploy/application.yaml [new file with mode: 0644]
deploy/logback-prod.xml [new file with mode: 0644]
deploy/start.sh
sly-crm-app/src/main/resources/application-test.yaml
sly-crm-app/src/main/resources/keystore/lis-keystore.jks
sly-crm-app/src/test/java/hu/user/lis/RepositoryIT.java
sly-crm-app/src/test/java/hu/user/lis/workflow/TaxOfficeInvoiceApiIT.java
sly-crm-db/migrations/environments/test.properties
sly-crm-service/src/main/java/hu/user/lis/service/nav/RestTemplateSSLConfiguration.java
sly-crm-ui/src/main/java/hu/user/lis/ui/config/WebSecurityConfig.java
sly-crm-workflow/src/main/java/hu/user/lis/workflow/invoice/service/WorkflowManagerService.java

diff --git a/deploy/application.yaml b/deploy/application.yaml
new file mode 100644 (file)
index 0000000..fbb63df
--- /dev/null
@@ -0,0 +1,79 @@
+server:
+  port: 80
+  servlet:
+    context-path: /
+zk:
+  homepage: index
+  zul-view-resolver-enabled: true
+spring:
+  jpa:
+    show-sql: false
+    properties:
+      hibernate:
+        format_sql: true
+  main:
+    banner-mode: off
+  output:
+    ansi:
+      enabled: always
+  datasource:
+    type: com.zaxxer.hikari.HikariDataSource
+    url: jdbc:db2://localhost:50000/lis
+    username: db2admin
+    password: Salabakt3r
+camunda.bpm:
+  generic-properties.properties:
+    telemetry-reporter-activate: false
+  job-executor-acquire-by-priority: true
+  job-execution:
+    core-pool-size: 10
+    #lock-time-in-millis: 600000
+  database:
+    type: db2
+    schema-update: false
+    table-prefix: CAMUNDA.
+    schema-name: CAMUNDA
+  webapp:
+    enabled: true
+    index-redirect-enabled: false
+  admin-user:
+    id: kermit
+    password: password
+    firstName: Kermit
+  filter:
+    create: All tasks
+  job-execution.enabled: true
+logging:
+  config: logback-prod.xml
+  level:
+    org.hibernate.engine.jdbc.spi.SqlExceptionHelper: ERROR
+    org.springframework.web.clientRestTemplate: ERROR
+    logging.level.org.apache.http: ERROR
+    logging.level.httpclient.wire: ERROR
+application:
+  ui:
+    user-name:
+    password:
+    export-temp-path: /tmp
+    disable-profile-save: false
+  workflow:
+    import-invoice:
+      input-path: /temp/invoice-import
+      project-id-pattern: \d{4}-\d{4}
+      old-project-id-pattern: \d{8}
+service:
+  nav:
+    trust:
+      store: classpath:keystore/lis-keystore.jks
+      store.password: password
+    api:
+      url: https://api.onlineszamla.nav.gov.hu/invoiceService/v3
+      user: dufwfvhquolizk4
+      password: Pbd6Mnkt9g
+      sign-key: 05-967b-0e5227e11ca44GF1ZEUBSX8F
+      exchange-key: a5c24GF1ZEUBUGIK
+      sender-tax-number: 13799504
+      sender-company: USER RENDSZERHÁZ Informatikai Korlátolt Felelősségű Társaság
+      sender-country: HU
+      sender-contact: Kovács Géza
+      days-range: 34
\ No newline at end of file
diff --git a/deploy/logback-prod.xml b/deploy/logback-prod.xml
new file mode 100644 (file)
index 0000000..db740ef
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+
+    <property name="LOGS" value="./logs"/>
+
+    <appender name="Console"
+              class="ch.qos.logback.core.ConsoleAppender">
+        <layout class="ch.qos.logback.classic.PatternLayout">
+            <Pattern>
+                %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable
+            </Pattern>
+        </layout>
+    </appender>
+
+    <appender name="RollingFile"
+              class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${LOGS}/sly-crm.log</file>
+        <encoder
+                class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <Pattern>%d %p %C{1.} [%t] %m%n</Pattern>
+        </encoder>
+
+        <rollingPolicy
+                class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- rollover daily and when the file reaches 10 MegaBytes -->
+            <fileNamePattern>${LOGS}/archived/sly-crm-app-%d{yyyy-MM-dd}.%i.log
+            </fileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy
+                    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+    </appender>
+
+    <root level="info">
+        <appender-ref ref="RollingFile"/>
+        <appender-ref ref="Console"/>
+    </root>
+
+    <logger name="hu.user.lis" level="trace" additivity="false">
+        <appender-ref ref="RollingFile"/>
+        <appender-ref ref="Console"/>
+    </logger>
+
+</configuration>
\ No newline at end of file
index ce898950664a4b359c665caeba2d89e51efa45f2..a78c752e6bd79df8438ef57296021014ea3b1a6e 100644 (file)
@@ -1,2 +1,2 @@
 #!/bin/bash
-java -DSLY-CRM-APPLICATION -jar /opt/slycrm/sly-crm-app.jar
+java -DSLY-CRM-APPLICATION -Dspring.profiles.active=prod -jar /opt/slycrm/sly-crm-app.jar
index 8206eeca03e1db42952b596fcd619142a44e0480..7398ac4485e214f853c234db503030019d794e3b 100644 (file)
@@ -22,7 +22,7 @@ spring:
     type: com.zaxxer.hikari.HikariDataSource
     url: jdbc:db2://dvdev.in.useribm.hu:50000/lis
     username: db2admin
-    password: password
+    password: Salabakt3r
 camunda.bpm:
   generic-properties.properties:
     telemetry-reporter-activate: false
@@ -66,9 +66,13 @@ service:
       store: classpath:keystore/lis-keystore.jks
       store.password: password
     api:
-      url: https://api-test.onlineszamla.nav.gov.hu/invoiceService/v3
-      user: vkvyibj5xgqpbp0
-      password: Salabakt3r
-      sign-key: fe-9d8b-971c878376204BQEWTHH2HI6
-      exchange-key: 3af24BQEWTHH4TSX
-      sender-tax-number: 13364937
+      url: https://api.onlineszamla.nav.gov.hu/invoiceService/v3
+      user: dufwfvhquolizk4
+      password: Pbd6Mnkt9g
+      sign-key: 05-967b-0e5227e11ca44GF1ZEUBSX8F
+      exchange-key: a5c24GF1ZEUBUGIK
+      sender-tax-number: 13799504
+      sender-company: USER RENDSZERHÁZ Informatikai Korlátolt Felel?sség? Társaság
+      sender-country: HU
+      sender-contact: Kovács Géza
+      days-range: 34
\ No newline at end of file
index 5c8c33577099485672e9d9ac51aa6b2e7d9b099c..d53b7436a4d773ffee12a87a94adcd0bd418b073 100644 (file)
Binary files a/sly-crm-app/src/main/resources/keystore/lis-keystore.jks and b/sly-crm-app/src/main/resources/keystore/lis-keystore.jks differ
index 64753718d8cc38cae0642eea913d574619630925..864451295fa63755e062fb3c2f30970b8fb87078 100644 (file)
@@ -5,8 +5,18 @@
 
 package hu.user.lis;
 
-import hu.user.lis.db.*;
-import hu.user.lis.db.repository.*;
+import hu.user.lis.db.Currency;
+import hu.user.lis.db.IncomingInvoice;
+import hu.user.lis.db.Invoice;
+import hu.user.lis.db.InvoiceImport;
+import hu.user.lis.db.Project;
+import hu.user.lis.db.ServiceRecord;
+import hu.user.lis.db.Treasury;
+import hu.user.lis.db.repository.InvoiceImportRepository;
+import hu.user.lis.db.repository.InvoiceRepository;
+import hu.user.lis.db.repository.ProjectRepository;
+import hu.user.lis.db.repository.ServiceRecordRepository;
+import hu.user.lis.db.repository.TreasuryRepository;
 import hu.user.lis.service.data.ProjectService;
 import hu.user.lis.service.data.TreasuryService;
 import lombok.extern.log4j.Log4j2;
@@ -22,6 +32,7 @@ import org.springframework.test.context.junit4.SpringRunner;
 import javax.persistence.EntityNotFoundException;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Optional;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -53,6 +64,7 @@ public class RepositoryIT {
     @Autowired
     private InvoiceRepository invoiceRepository;
 
+
     @Test
     public void testRepositoryCapabilities() {
         List<ServiceRecord> allItems = serviceRecordRepository.findAll();
@@ -128,4 +140,10 @@ public class RepositoryIT {
         invoiceImportRepository.delete(invoiceImport);
 
     }
+
+    @Test
+    public void testImportInvoiceInvoiceCreateDate() {
+        Optional<InvoiceImport> importDate = invoiceImportRepository.findTopByOrderByInvoiceCreateDateDesc();
+        log.info(importDate);
+    }
 }
index 34753ed54c1e89880629ff2c8916e45b65e6f4d8..06d874206d7a2165a5c1655f53973c5eb83c665c 100644 (file)
@@ -7,7 +7,11 @@ package hu.user.lis.workflow;
 
 import hu.gov.nav.schemas.ntca._1_0.common.BasicResultType;
 import hu.gov.nav.schemas.ntca._1_0.common.FunctionCodeType;
-import hu.gov.nav.schemas.osa._3_0.api.*;
+import hu.gov.nav.schemas.osa._3_0.api.InvoiceDigestResultType;
+import hu.gov.nav.schemas.osa._3_0.api.InvoiceDigestType;
+import hu.gov.nav.schemas.osa._3_0.api.InvoiceDirectionType;
+import hu.gov.nav.schemas.osa._3_0.api.QueryInvoiceDigestRequest;
+import hu.gov.nav.schemas.osa._3_0.api.QueryInvoiceDigestResponse;
 import hu.gov.nav.schemas.osa._3_0.data.InvoiceData;
 import hu.user.lis.db.IncomingInvoice;
 import hu.user.lis.service.nav.TaxOfficeInvoiceService;
@@ -48,7 +52,7 @@ import java.util.concurrent.TimeUnit;
 @Log4j2
 @SpringBootTest
 @RunWith(SpringRunner.class)
-@ActiveProfiles("test")
+@ActiveProfiles("dev")
 @ComponentScan("hu.user.lis")
 //@TestPropertySource("classpath:application-test.yaml")
 public class TaxOfficeInvoiceApiIT {
@@ -157,7 +161,7 @@ public class TaxOfficeInvoiceApiIT {
         int availablePages = 1;
         int currentPage = 1;
         while (currentPage <= availablePages) {
-            Optional<QueryInvoiceDigestResponse> response = taxOfficeInvoiceService.queryInboundInvoices(currentPage, 5, 34);
+            Optional<QueryInvoiceDigestResponse> response = taxOfficeInvoiceService.queryInboundInvoices(currentPage, 0, 5);
             if (!response.isPresent()) {
                 break;
             }
index c5d02a9ac7147e3418bfeab8f1e86d3ba9f1c55b..8618bd6963ba5cd263f93e5a186b2abf23cca2e2 100644 (file)
@@ -6,7 +6,7 @@ script_char_set=UTF-8
 driver=com.ibm.db2.jcc.DB2Driver
 url=jdbc:db2://dvdev.in.useribm.hu:50000/lis
 username=db2admin
-password=password
+password=Salabakt3r
 #
 # A NOTE ON STORED PROCEDURES AND DELIMITERS
 #
index 67c434e504a3ee4675a081fc4d8261975c8d926b..2a13a8eda2ff79599fc9d6cb7c193553ddba9cf6 100644 (file)
@@ -1,9 +1,11 @@
 package hu.user.lis.service.nav;
 
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
 import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.ssl.SSLContextBuilder;
+import org.apache.http.ssl.TrustStrategy;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -32,17 +34,9 @@ public class RestTemplateSSLConfiguration {
     public RestTemplate restTemplate() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException,
             CertificateException, IOException {
 
+
         SSLContext sslContext = new SSLContextBuilder()
                 .loadTrustMaterial(trustStore.getURL(), trustStorePassword.toCharArray()).build();
-
-//        TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
-//        SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom()
-//                .loadTrustMaterial(null, acceptingTrustStrategy)
-//                .build();
-
-//        SSLConnectionSocketFactory sslConFactory = new SSLConnectionSocketFactory(sslContext,
-//                new String[]{"TLSv1.2", "TLSv1.1"}, null,
-//                (hostname, session) -> true);
         SSLConnectionSocketFactory sslConFactory = new SSLConnectionSocketFactory(sslContext);
 
         CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslConFactory).build();
@@ -50,4 +44,16 @@ public class RestTemplateSSLConfiguration {
 
         return new RestTemplate(requestFactory);
     }
+
+    @Bean
+    public RestTemplate restTemplate2() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException,
+            CertificateException, IOException {
+        TrustStrategy acceptingTrustStrategy = (x509Certificates, s) -> true;
+        SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
+        SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier());
+        CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(csf).build();
+        HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
+        requestFactory.setHttpClient(httpClient);
+        return new RestTemplate(requestFactory);
+    }
 }
\ No newline at end of file
index 7b3f8014fcde8d2997cc11e69f665645256c79f5..bfbadbacca479aad19f3f5fc0cf940e730355838 100644 (file)
@@ -22,7 +22,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
     public static final String REMOVE_DESKTOP_REGEX = "/zkau\\?dtid=.*&cmd_0=rmDesktop&.*";
 
 
-    public static final String[] ZK_RESOURCES = {"/zkau/web/**/js/**", "/zkau/web/**/zul/css/**", "/zkau/web/**/zul/less/**", "/zkau/web/**/img/**", "/zkau/web/**/static/**"};
+    public static final String[] ZK_RESOURCES = {"/zkau/web/**/js/**", "/zkau/web/**/zul/css/**", "/zkau/web/**/zul/less/**", "/zkau/web/**/img/**", "/zkau/web/**/static/**", "/engine-rest/**"};
     @Autowired
     LocalAuthProvider localAuthProvider;
 
index 00e1cf56f644ecf86768d0138febccaec08eb69e..afcac63252d03d1a28b2a7b09da1c1693470f7d8 100644 (file)
@@ -77,16 +77,16 @@ public class WorkflowManagerService {
     }
 
     public void cancelInvoiceImportProcess(boolean onlyImport) {
-        List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list();
+        List<ProcessInstance> processInstances;
+        if (onlyImport) {
+            processInstances = runtimeService.createProcessInstanceQuery().processDefinitionKey(IMPORT_INCOMING_INVOICES).active().list();
+        } else {
+            processInstances = runtimeService.createProcessInstanceQuery().active().list();
+        }
+        log.info("Found process instance count {}", (long) processInstances.size());
         processInstances.forEach(p -> {
             log.info("Found process instance {} {} {}", p.getProcessInstanceId(), p.getProcessDefinitionId(), p.isSuspended());
-            if (onlyImport) {
-                if (IMPORT_INCOMING_INVOICES.equals(p.getProcessDefinitionId())) {
-                    killProcess(p);
-                }
-            } else {
-                killProcess(p);
-            }
+            killProcess(p);
         });
     }