Commit f0d0479ea359b40794fd8fe9483bb32b83cb0eee

Authored by Neocortexxx
1 parent 8277e827

JSONRequester first code

docker/wildfly/volumes/conf/beuthbot.properties
1 -WEB_URL = https://ovizkyvdft.localtunnel.me 1 +WEB_URL = https://tlhiuqrvbl.localtunnel.me
2 2
3 3
4 # Webhook token you set in the Facebook App Settings 4 # Webhook token you set in the Facebook App Settings
5 -FACEBOOK_WEBHOOK_TOKEN = bhtchatbot 5 +FACEBOOK_WEBHOOK_TOKEN = local-beuth-bot
6 6
7 # Facebook Message Token for your page 7 # Facebook Message Token for your page
8 -FACEBOOK_BOT_TOKEN = XXXXX  
9 -  
10 -FACEBOOK_ACCESS_TOKEN = XXXXX|XXXXX-XXXXX 8 +FACEBOOK_BOT_TOKEN = EAAX3bENbCzcBAGESpNG7XBqXiZBvOzwX7quURCwBlzpjFuWyd0JH8HFUrhmu167IjWBMPcSki8ZCtZAZBR0CS4ZAV1r4nAZCqayLZAbPxvJVIxVw0NHm9gG7f6qahc18Wh0IZCKkTUqYLPfGbZAbAUMHsbAAcbZBeTbBmVS6ydHtxLyvSCwXJgh1ob
11 9
  10 +FACEBOOK_ACCESS_TOKEN = 1679419242122039|XVLpgA2YMXcwWQCg1Sj_hGKuNwM
12 11
13 12
14 # API.ai client token 13 # API.ai client token
@@ -18,10 +17,9 @@ API_AI_TOKEN = XXXXX @@ -18,10 +17,9 @@ API_AI_TOKEN = XXXXX
18 # Your WebHook URL e.g.: https://yourdomain.com/webhook/ 17 # Your WebHook URL e.g.: https://yourdomain.com/webhook/
19 TELEGRAM_WEBHOOK_URL = /telegram/getUpdates 18 TELEGRAM_WEBHOOK_URL = /telegram/getUpdates
20 19
21 -  
22 # Your Bot Token e.g.: 000000000:AAAAa0aAA_aaA-Aaaa0A0Aa_a0aa0A0AAAA 20 # Your Bot Token e.g.: 000000000:AAAAa0aAA_aaA-Aaaa0A0Aa_a0aa0A0AAAA
23 -TELEGRAM_BOT_TOKEN = 451726698:AAH2qwZaWOgn1IU1CjJU-HjHDMODG6DEkN0  
24 - 21 +TELEGRAM_BOT_TOKEN = 452768505:AAHNXEYi9nSHcmVc4b3799I00uTZmK53wl4\
  22 +
25 23
26 24
27 BING_SPEECH_LOCALE = global 25 BING_SPEECH_LOCALE = global
services/Common/src/main/java/de/bht/beuthbot/model/Intent.java
@@ -5,9 +5,16 @@ package de.bht.beuthbot.model; @@ -5,9 +5,16 @@ package de.bht.beuthbot.model;
5 */ 5 */
6 public enum Intent { 6 public enum Intent {
7 7
8 - SHOW_FOOD("showFood"), HELLO("Hello"), GREET("greet"), BYE("Bye"),  
9 - GOODBYE("goodbye"), RESTAURANT_SEARCH("restaurant_search"), START("Start"),  
10 - SHOW_PRICE("showPrice"), FALLBACK("Fallback"); 8 + START("Start"),
  9 + HELLO("Hello"),
  10 + GREET("greet"),
  11 + BYE("Bye"),
  12 + GOODBYE("goodbye"),
  13 +
  14 + RESTAURANT_SEARCH("restaurant_search"),
  15 + SHOW_FOOD("showFood"),
  16 + SHOW_PRICE("showPrice"),
  17 + FALLBACK("Fallback");
11 18
12 private String text; 19 private String text;
13 20
services/FaceBook/build.gradle
@@ -2,26 +2,24 @@ apply plugin: 'java' @@ -2,26 +2,24 @@ apply plugin: 'java'
2 apply plugin: 'war' 2 apply plugin: 'war'
3 apply plugin: 'checkstyle' 3 apply plugin: 'checkstyle'
4 4
  5 +sourceCompatibility = 1.8
  6 +
5 repositories { 7 repositories {
6 mavenCentral() 8 mavenCentral()
7 } 9 }
8 10
9 dependencies { 11 dependencies {
10 -  
11 compile project(':services:Common'), 12 compile project(':services:Common'),
12 "org.jboss.spec:jboss-javaee-7.0:1.1.0.Final", 13 "org.jboss.spec:jboss-javaee-7.0:1.1.0.Final",
13 "org.apache.httpcomponents:httpclient:4.5.3", 14 "org.apache.httpcomponents:httpclient:4.5.3",
14 "org.apache.httpcomponents:httpmime:4.3.1", 15 "org.apache.httpcomponents:httpmime:4.3.1",
15 "org.json:json:20160810" 16 "org.json:json:20160810"
16 -  
17 providedCompile "org.slf4j:slf4j-api:1.7.25", 17 providedCompile "org.slf4j:slf4j-api:1.7.25",
18 "org.jboss.resteasy:resteasy-client:3.1.3.Final", 18 "org.jboss.resteasy:resteasy-client:3.1.3.Final",
19 "org.jboss.resteasy:resteasy-jaxrs-all:3.1.3.Final" 19 "org.jboss.resteasy:resteasy-jaxrs-all:3.1.3.Final"
20 20
21 } 21 }
22 22
23 -sourceCompatibility = 1.8  
24 -  
25 war { 23 war {
26 destinationDir new File(project.rootProject.projectDir, 'docker/wildfly/volumes/deployments/') 24 destinationDir new File(project.rootProject.projectDir, 'docker/wildfly/volumes/deployments/')
27 archiveName "facebook.war" 25 archiveName "facebook.war"
services/FaceBook/src/main/java/de/bht/beuthbot/messenger/facebook/FacebookReceiveAdapter.java
@@ -106,7 +106,6 @@ public class FacebookReceiveAdapter { @@ -106,7 +106,6 @@ public class FacebookReceiveAdapter {
106 processQueue.route(new TaskMessage(facebookBotMessage)); 106 processQueue.route(new TaskMessage(facebookBotMessage));
107 107
108 } 108 }
109 -  
110 } 109 }
111 110
112 return "\nReceived\n"; 111 return "\nReceived\n";
services/JSONRequester/build.gradle 0 โ†’ 100644
  1 +apply plugin: 'java'
  2 +apply plugin: 'war'
  3 +apply plugin: 'checkstyle'
  4 +
  5 +sourceCompatibility = 1.8
  6 +
  7 +repositories {
  8 + mavenCentral()
  9 +}
  10 +
  11 +dependencies {
  12 + compile project(':services:Common'),
  13 + "org.jboss.spec:jboss-javaee-7.0:1.1.0.Final",
  14 + "org.apache.httpcomponents:httpclient:4.5.3",
  15 + "org.apache.httpcomponents:httpmime:4.3.1",
  16 + "org.json:json:20160810"
  17 + providedCompile "org.slf4j:slf4j-api:1.7.25",
  18 + "org.jboss.resteasy:resteasy-client:3.1.3.Final",
  19 + "org.jboss.resteasy:resteasy-jaxrs-all:3.1.3.Final"
  20 +}
  21 +
  22 +war {
  23 + destinationDir new File(project.rootProject.projectDir, 'docker/wildfly/volumes/deployments/')
  24 + archiveName "jsonrequester.war"
  25 +}
0 \ No newline at end of file 26 \ No newline at end of file
services/JSONRequester/src/main/java/de/bht/beuthbot/JSONRequester/JSONRequester.java
1 package de.bht.beuthbot.JSONRequester; 1 package de.bht.beuthbot.JSONRequester;
2 2
  3 +import de.bht.beuthbot.attachments.AttachmentStore;
  4 +import de.bht.beuthbot.jms.ProcessQueue;
  5 +import javafx.application.Application;
  6 +
  7 +import javax.annotation.PostConstruct;
  8 +import javax.annotation.Resource;
  9 +import javax.ejb.Singleton;
  10 +import javax.ejb.Startup;
  11 +
  12 +@Singleton
  13 +@Startup
3 public class JSONRequester { 14 public class JSONRequester {
  15 +
  16 + //private final Logger logger = LoggerFactory.getLogger(JSONRequester.class);
  17 +
  18 + /** Injected JMS MessageQueue */
  19 + @Resource(lookup = "java:global/global/ProcessQueueBean")
  20 + private ProcessQueue processQueue;
  21 +
  22 + /** Injected AttachmentStore */
  23 + @Resource(lookup = "java:global/global/AttachmentStoreBean")
  24 + private AttachmentStore attachmentStore;
  25 +
  26 + /** BeuthBot Application Bean */
  27 + @Resource(lookup = "java:global/global/ApplicationBean")
  28 + private Application application;
  29 +
  30 + //CONSTRUCTOR
  31 + @PostConstruct
  32 + public void init(){
  33 + //logger.debug("JSONRequester initiated!");
  34 + }
  35 +
  36 + public String getJSONForURL(de.bht.beuthbot.JSONRequester.JSONRequestObject requestObject) {
  37 + //ResteasyClient client = new ResteasyClientBuilder().build();
  38 + //ResteasyWebTarget target = client.target(UriBuilder.fromPath(requestObject.getRequestUrl()));
  39 + //JSONRequestInterface jsonProxy = target.proxy(JSONRequestInterface.class);
  40 +
  41 + //Response response = jsonProxy.sendRequest();
  42 +
  43 + //String responseAsString = response.readEntity(String.class);
  44 +
  45 + return "";
  46 + }
4 } 47 }
services/Scheduler/src/main/java/de/bht/beuthbot/scheduler/SchedulerBean.java
@@ -3,8 +3,8 @@ package de.bht.beuthbot.scheduler; @@ -3,8 +3,8 @@ package de.bht.beuthbot.scheduler;
3 import de.bht.beuthbot.attachments.AttachmentStore; 3 import de.bht.beuthbot.attachments.AttachmentStore;
4 import de.bht.beuthbot.scheduler.model.Reminder; 4 import de.bht.beuthbot.scheduler.model.Reminder;
5 import de.bht.beuthbot.scheduler.model.ReminderCycle; 5 import de.bht.beuthbot.scheduler.model.ReminderCycle;
6 -import org.slf4j.Logger;  
7 -import org.slf4j.LoggerFactory; 6 +//import org.slf4j.Logger;
  7 +//import org.slf4j.LoggerFactory;
8 8
9 import de.bht.beuthbot.conf.Application; 9 import de.bht.beuthbot.conf.Application;
10 import de.bht.beuthbot.conf.Configuration; 10 import de.bht.beuthbot.conf.Configuration;
@@ -15,9 +15,6 @@ import java.util.*; @@ -15,9 +15,6 @@ import java.util.*;
15 import javax.annotation.PostConstruct; 15 import javax.annotation.PostConstruct;
16 import javax.annotation.Resource; 16 import javax.annotation.Resource;
17 import javax.ejb.*; 17 import javax.ejb.*;
18 -import javax.ejb.Timer;  
19 -import javax.ws.rs.GET;  
20 -import javax.ws.rs.Path;  
21 18
22 @Singleton 19 @Singleton
23 @Startup 20 @Startup
@@ -25,8 +22,8 @@ public class SchedulerBean { @@ -25,8 +22,8 @@ public class SchedulerBean {
25 /** 22 /**
26 * slf4j Logger 23 * slf4j Logger
27 */ 24 */
28 - private final Logger logger = LoggerFactory.getLogger(SchedulerBean.class);  
29 - //Timer object for call cycling 25 + //private final Logger logger = LoggerFactory.getLogger(SchedulerBean.class);
  26 + //Timer object forg call cycling
30 @Resource 27 @Resource
31 TimerService timerService; 28 TimerService timerService;
32 /** Injected JMS MessageQueue */ 29 /** Injected JMS MessageQueue */
@@ -47,19 +44,18 @@ public class SchedulerBean { @@ -47,19 +44,18 @@ public class SchedulerBean {
47 //CONSTRUCTOR 44 //CONSTRUCTOR
48 @PostConstruct 45 @PostConstruct
49 public void init(){ 46 public void init(){
50 - logger.debug("SchedulerBean initiated!"); 47 + //logger.debug("SchedulerBean initiated!");
51 } 48 }
52 49
53 @Schedule(hour="*", minute="*") 50 @Schedule(hour="*", minute="*")
54 public void fetchReminders() { 51 public void fetchReminders() {
55 //TODO: Establish DB connection and retrieve list of reminders 52 //TODO: Establish DB connection and retrieve list of reminders
56 - logger.debug("SchedulerBean fired!");  
57 -  
58 - 53 + //logger.debug("SchedulerBean fired!");
59 } 54 }
60 55
61 public void createReminder(Long userID, ReminderCycle reminderCycle, Date cycleDate) { 56 public void createReminder(Long userID, ReminderCycle reminderCycle, Date cycleDate) {
62 Reminder newReminder = new Reminder(userID, reminderCycle, cycleDate); 57 Reminder newReminder = new Reminder(userID, reminderCycle, cycleDate);
  58 + _reminders.add(newReminder);
63 //TODO: Insert the new Reminder into Database 59 //TODO: Insert the new Reminder into Database
64 60
65 } 61 }
services/Telegram/build.gradle
@@ -2,6 +2,8 @@ apply plugin: 'java' @@ -2,6 +2,8 @@ apply plugin: 'java'
2 apply plugin: 'war' 2 apply plugin: 'war'
3 apply plugin: 'checkstyle' 3 apply plugin: 'checkstyle'
4 4
  5 +sourceCompatibility = 1.8
  6 +
5 repositories { 7 repositories {
6 mavenCentral() 8 mavenCentral()
7 } 9 }
@@ -20,8 +22,6 @@ dependencies { @@ -20,8 +22,6 @@ dependencies {
20 22
21 } 23 }
22 24
23 -sourceCompatibility = 1.8  
24 -  
25 war { 25 war {
26 destinationDir new File(project.rootProject.projectDir, 'docker/wildfly/volumes/deployments/') 26 destinationDir new File(project.rootProject.projectDir, 'docker/wildfly/volumes/deployments/')
27 archiveName "telegram.war" 27 archiveName "telegram.war"
settings.gradle
@@ -8,9 +8,9 @@ include ( @@ -8,9 +8,9 @@ include (
8 'services:MainBot', 8 'services:MainBot',
9 'services:LoggingStatistics', 9 'services:LoggingStatistics',
10 'services:Telegram', 10 'services:Telegram',
11 - 'services:Scheduler' 11 + 'services:Scheduler',
  12 + 'services:JSONRequester'
12 ) 13 )
13 -findProject(':services:Scheduler')?.name = 'Scheduler'  
14 -include 'services:JSONRequester'  
15 -findProject(':services:JSONRequester')?.name = 'JSONRequester' 14 +//findProject(':services:Scheduler')?.name = 'Scheduler'
  15 +//findProject(':services:JSONRequester')?.name = 'JSONRequester'
16 16