Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/maven.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build

on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]
release:
types: [ released ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: corretto
cache: maven

- name: Build with Maven
run: mvn -B --no-transfer-progress clean package

- name: Upload artifact [uber-jar]
uses: actions/upload-artifact@v4
with:
name: uber-jar
path: target/*-jar-with-dependencies.jar
if-no-files-found: error
retention-days: 7

- name: Build and push docker image [edge]
run: docker buildx build --push -t ghcr.io/${{ github.repository }}:edge --platform linux/amd64,linux/arm64 .
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Fetch the application jar from the target directory and rename it to application.jar
FROM amazoncorretto:21-al2023-headless AS fetch

COPY target /target
RUN mv /target/*-with-dependencies.jar /target/application.jar


# Actual image to run the application
FROM amazoncorretto:21-al2023-headless

EXPOSE 8082

COPY --from=fetch /target/application.jar /work/application.jar

CMD ["java", "-jar", "/work/application.jar"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ serverPort=<Pick a free port for example 8081>

From project root:
```shell
mvn clean install
mvn clean package
java -jar target/cake-redux-0.1-SNAPSHOT-jar-with-dependencies.jar <config file location>
```

Expand Down
111 changes: 44 additions & 67 deletions src/main/java/no/javazone/cake/redux/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

public class Configuration {

private Map<String,String> properties = null;
private static Configuration instance = new Configuration();
private static final Configuration instance = new Configuration();

private Configuration() {

Expand All @@ -28,18 +27,24 @@ private static String readConfigFile(String filename) {
}
}

private static String getProperty(String key) {
public static void setProps(Map<String,String> props) {
instance.properties = props;
}

private static String getProperty(String prop, String env) {
if (instance.properties == null) {
instance.loadProps();
if (instance.properties == null) {
throw new IllegalStateException("Properties not initalized getting " +key);
throw new IllegalStateException("Properties not initalized getting " +prop);
}
}
return instance.properties.get(key);
return instance.properties.getOrDefault(prop, System.getenv(env));

}


private static String readConf(String prop, String env, String defaultValue) {
return Optional.ofNullable(getProperty(prop, env)).orElse(defaultValue);
}

private synchronized void loadProps() {
Map<String,String> readProps = new HashMap<>();
Expand All @@ -58,169 +63,141 @@ private synchronized void loadProps() {
}

public static String getEmsUser() {
return getProperty("emsUser");
return getProperty("emsUser", "EMS_USER");
}

public static String getEmsPassword() {
return getProperty("emsPassword");
return getProperty("emsPassword", "EMS_PASSWORD");
}

public static String getGoogleClientId() {
return getProperty("googleClientId");
return getProperty("googleClientId", "GOOGLE_CLIENT_ID");
}

public static String getGoogleClientSecret() {
return getProperty("googleClientSecret");
return getProperty("googleClientSecret", "GOOGLE_CLIENT_SECRET");
}

public static String getGoogleRedirectUrl() {
return getProperty("googleRedirectUrl");
return getProperty("googleRedirectUrl", "GOOGLE_REDIRECT_URL");
}

public static String getAutorizedUsers() {
String authorizedUsers = getProperty("authorizedUsers");
String authorizedUsers = getProperty("authorizedUsers", "AUTHORIZED_USERS");
if (authorizedUsers == null) {
return "";
}
return authorizedUsers;
}

public static String autorizedUserFile() {
return getProperty("autorizedUserFile");
return getProperty("autorizedUserFile", "AUTORIZED_USER_FILE");
}

public static String fullUsers() {
return getProperty("fullUsers");
return getProperty("fullUsers", "FULL_USERS");
}

public static boolean noAuthMode() {
return "true".equals(getProperty("noAuthMode"));
return "true".equals(getProperty("noAuthMode", "NO_AUTH_MODE"));
}

public static String emsEventLocation() {
return getProperty("emsEventLocation");
return getProperty("emsEventLocation", "EMS_EVENT_LOCATION");
}

public static String submititLocation() {
return getProperty("submititLocation");
return getProperty("submititLocation", "SUBMITIT_LOCATION");
}

public static Integer serverPort() {
String serverPortStr = getProperty("serverPort");
String serverPortStr = getProperty("serverPort", "SERVER_PORT");
if (serverPortStr == null || serverPortStr.isEmpty()) {
return null;
}
return Integer.parseInt(serverPortStr);
}

public static String mailSenderImplementation() {
return readConf("mailSenderImplementation","smtp");
}

public static String smtpServer() {
return getProperty("smthost");
}

public static int smtpPort() {
return Integer.parseInt(getProperty("smtpport"));
}

public static boolean useMailSSL() {
return "true".equals(getProperty("mailSsl"));
}

public static String mailUser() {
return getProperty("mailUser");
}

public static String mailPassword() {
return getProperty("mailPassword");
return readConf("mailSenderImplementation", "MAIL_SENDER_IMPLEMENTATION","smtp");
}

public static String cakeLocation() {
return getProperty("cakeLocation");
}

private static String readConf(String prop,String defaultValue) {
return Optional.ofNullable(getProperty(prop)).orElse(defaultValue);
return getProperty("cakeLocation", "CAKE_LOCATION");
}

public static boolean whydaSupported() {
return "true".equals(readConf("supportWhyda","false"));
return "true".equals(readConf("supportWhyda", "SUPPORT_WHYDA","false"));
}

public static String logonRedirectUrl() {
return readConf("logonRedirectUrl", "http://localhost:9997/sso/login?redirectURI=http://localhost:8088/admin/");
return readConf("logonRedirectUrl", "LOGON_REDIRECT_URL", "http://localhost:9997/sso/login?redirectURI=http://localhost:8088/admin/");
}

public static String tokenServiceUrl() {
return readConf("tokenServiceUrl", "http://localhost:9998/tokenservice");
return readConf("tokenServiceUrl", "TOKEN_SERIVCE_URL","http://localhost:9998/tokenservice");
}

public static String applicationId() {
return readConf("applicationId", "99");
return readConf("applicationId", "APPLICATION_ID", "99");
}

public static String feedbackStoreFilename() {
return readConf("feedbackStoreFilename",null);
return readConf("feedbackStoreFilename", "FEEDBACK_STORE_FILENAME",null);
}

public static String applicationSecret() { return readConf("applicationSecret", "33879936R6Jr47D4Hj5R6p9qT");}

public static void setProps(Map<String,String> props) {
instance.properties = props;
}
public static String applicationSecret() { return readConf("applicationSecret", "APPLICATION_SECRET", "33879936R6Jr47D4Hj5R6p9qT");}

public static long emailSleepTime() {
return Long.parseLong(readConf("emailSleepTime","5000"));
return Long.parseLong(readConf("emailSleepTime", "EMAIL_SLEEP_TIME","5000"));
}

public static String sleepingPillBaseLocation() {
return readConf("sleepingPillBaseLocation","http://localhost:8082");
return readConf("sleepingPillBaseLocation", "SLEEPINGPILL_BASE_LOCATION","http://localhost:8082");
}

public static String sleepingpillUser() {
return readConf("sleepingpillUser",null);
return readConf("sleepingpillUser", "SLEEPINGPILL_USER",null);
}

public static String sleepingpillPassword() {
return readConf("sleepingpillPassword",null);
return readConf("sleepingpillPassword", "SLEEPINGPILL_PASSWORD",null);
}

public static String feedbackDaoImpl() {
return readConf("feedbackDaoImpl","sleepingpill");
return readConf("feedbackDaoImpl", "FEEDBACK_DAO_IMPL","sleepingpill");
}

public static String videoAdminPassword() {
return readConf("videoAdminPassword","dummy:bingo");
return readConf("videoAdminPassword", "VIDEO_ADMIN_PASSWORD","dummy:bingo");
}

public static String videoAdminConference() {
return readConf("videoAdminConference","30d5c2f1cb214fc8b0649a44fdf3b4bf");
return readConf("videoAdminConference", "VIDEO_ADMIN_CONFERENCE","30d5c2f1cb214fc8b0649a44fdf3b4bf");
}

public static String sendGridKey() {
return readConf("sendGridKey",null);
return readConf("sendGridKey", "SENDGRID_KEY",null);
}

public static String slackAppId() {
return readConf("slackAppId",null);
return readConf("slackAppId", "SLACK_APP_ID", null);
}

public static String slackClientSecret() {
return readConf("slackClientSecret",null);
return readConf("slackClientSecret", "SLACK_CLIENT_SECRET",null);
}

public static String slackAuthChannel() {
return readConf("slackAuthChannel",null);
return readConf("slackAuthChannel", "SLACK_AUTH_CHANNEL",null);
}

public static String slackApiToken() {
return readConf("slackApiToken",null);
return readConf("slackApiToken", "SLACK_API_TOKEN",null);
}

public static LocalDate conferenceWednesday() {
return LocalDate.parse(readConf("conferenceWednesday","2019-09-11"));
return LocalDate.parse(readConf("conferenceWednesday", "CONFERENCE_WEDNESDAY","2019-09-11"));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public void shouldHandleOtherValues() throws Exception {

@Test
public void shouldHandleSlot() throws Exception {
JsonObject roomObj = JsonParser.parseToObject("{\"ref\":\"dgdg\",\"name\":\"Room 5\"}");
JsonObject slotObj = JsonParser.parseToObject("{\"ref\":\"dgdg\",\"start\":\"2017-09-07T13:00\",\"end\":\"2017-09-07T13:20\"}");
JsonObject jsonTalk = JsonFactory.jsonObject().put("slot",slotObj);
String message = acceptorSetter.generateMessage("This is #slot# hoi", null, null, null, null, null, jsonTalk, encodedTalkRef);
Expand Down