org.apache.maven.plugins
@@ -73,67 +43,10 @@
- io.swagger
- swagger-annotations
- ${swagger-annotations-version}
-
-
-
-
- com.google.code.findbugs
- jsr305
- 3.0.2
-
-
- org.openapitools
- jackson-databind-nullable
- ${jackson-databind-nullable-version}
-
-
-
-
- org.springframework
- spring-web
-
-
- org.springframework
- spring-context
+ ${project.groupId}
+ chat-client-java-lib
+ ${project.version}
-
-
-
- com.fasterxml.jackson.core
- jackson-core
-
-
- com.fasterxml.jackson.core
- jackson-annotations
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
- com.fasterxml.jackson.jaxrs
- jackson-jaxrs-json-provider
-
-
- com.fasterxml.jackson.datatype
- jackson-datatype-jsr310
-
-
- jakarta.annotation
- jakarta.annotation-api
- provided
-
-
-
- cz.muni.chat.client.Main
- 17
-
- 1.5.22
- 0.2.4
- 1.0.0
-
+
\ No newline at end of file
diff --git a/chat-client-java/src/main/java/cz/muni/chat/client/Main.java b/chat-client-java/src/main/java/cz/muni/chat/client/Main.java
index 4d5ad24..cbf3a60 100644
--- a/chat-client-java/src/main/java/cz/muni/chat/client/Main.java
+++ b/chat-client-java/src/main/java/cz/muni/chat/client/Main.java
@@ -1,34 +1,45 @@
package cz.muni.chat.client;
import cz.muni.chat.client.invoker.ApiClient;
+import cz.muni.chat.client.invoker.ApiException;
import cz.muni.chat.client.model.BackgroundColorEnum;
import cz.muni.chat.client.model.ChatMessage;
import cz.muni.chat.client.model.NewChatMessageRequest;
-import org.springframework.web.client.RestClientException;
import java.time.ZoneId;
+import java.util.Random;
public class Main {
- public static void main(String[] args) {
+ public static void main(String[] args) throws Exception {
System.out.println("starting");
ChatApi chat = new ChatApi(new ApiClient());
+ // list all messages
+ for (ChatMessage chatMessage : chat.getAllMessages()) {
+ System.out.println("chatMessage = " + chatMessage);
+ }
+
+ // create a new message
+ BackgroundColorEnum[] colors = BackgroundColorEnum.values();
+ BackgroundColorEnum bg = colors[new Random().nextInt(colors.length)];
+ ChatMessage message = chat.createMessage(
+ new NewChatMessageRequest()
+ .text("Hello!")
+ .textColor("black")
+ .backgroundColor(bg),
+ "me",
+ "UltraChat 1.0");
+
+ System.out.println("new message = " + message);
+ System.out.println("timestamp: " + message.getTimestamp().atZoneSameInstant(ZoneId.systemDefault()));
+
+ // deliberately make a wrong call to show catching an exception
try {
- for (ChatMessage chatMessage : chat.getAllMessages()) {
- System.out.println("chatMessage = " + chatMessage);
- }
-
- ChatMessage message = chat.createMessage(
- new NewChatMessageRequest().text("Hello!").textColor("black").backgroundColor(BackgroundColorEnum.AQUAMARINE),
- "me",
- null);
- System.out.println("new message = " + message);
- System.out.println("timestamp: "+ message.getTimestamp().atZoneSameInstant(ZoneId.systemDefault()));
-
- } catch (RestClientException ex) {
- ex.printStackTrace();
+ chat.getMessage("1");
+ } catch (ApiException ex) {
+ ChatException.from(ex).printStackTrace();
}
}
diff --git a/chat-server/src/main/resources/static/index.html b/chat-server/src/main/resources/static/index.html
index de84e9a..0ed699c 100644
--- a/chat-server/src/main/resources/static/index.html
+++ b/chat-server/src/main/resources/static/index.html
@@ -39,10 +39,5 @@ OpenAPI Description
Open the OpenAPI description in Swagger UI and try to call the service.
-Implementation
-
- This web service is implemented in Java using the Spring Boot framework.
-
-