Search in sources :

Example 1 with RoomDTO

use of io.fabric8.letschat.RoomDTO in project fabric8 by fabric8io.

the class DevOpsConnector method getChatRoomLink.

protected String getChatRoomLink(LetsChatClient letschat) {
    if (letschat != null) {
        try {
            String url = letschat.getAddress();
            String slug = evaluateRoomExpression(letschatRoomExpression);
            if (Strings.isNotBlank(url) && Strings.isNotBlank(slug)) {
                RoomDTO room = letschat.getOrCreateRoom(slug);
                if (room != null) {
                    String roomId = room.getId();
                    if (Strings.isNotBlank(roomId)) {
                        return URLUtils.pathJoin(url, "/#!/room/" + roomId);
                    }
                }
            }
        } catch (Exception e) {
            getLog().error("Failed to get the link to the chat room: " + e, e);
        }
    }
    return null;
}
Also used : RoomDTO(io.fabric8.letschat.RoomDTO) SAXException(org.xml.sax.SAXException) WebApplicationException(javax.ws.rs.WebApplicationException) AuthenticationException(org.apache.http.auth.AuthenticationException) ConnectException(java.net.ConnectException) MalformedChallengeException(org.apache.http.auth.MalformedChallengeException) HttpResponseException(org.apache.http.client.HttpResponseException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 2 with RoomDTO

use of io.fabric8.letschat.RoomDTO in project fabric8 by fabric8io.

the class Example method main.

public static void main(String[] args) {
    String roomName = "fabric8_default";
    if (args.length > 0) {
        roomName = args[0];
    }
    try {
        KubernetesClient kubernetes = new DefaultKubernetesClient();
        LetsChatClient letschat = LetsChatKubernetes.createLetsChat(kubernetes);
        System.out.println("Connecting to letschat on: " + letschat.getAddress());
        List<RoomDTO> rooms = letschat.getRooms();
        for (RoomDTO room : rooms) {
            System.out.println("Room " + room.getId() + " has slug: " + room.getSlug() + " name " + room.getName());
        }
        // looking up a room
        RoomDTO myRoom = letschat.getRoom(roomName);
        System.out.println("Found room: " + myRoom + " by slug: " + roomName);
        RoomDTO notExist = letschat.getRoom("does-not-exist");
        System.out.println("Found non existing room: " + notExist);
        // lets try lazily create a room if it doesn't exist
        RoomDTO newRoom = letschat.getOrCreateRoom("my_new_room_slug");
        System.out.println("Found/created room: " + newRoom);
    } catch (Exception e) {
        System.out.println("Caught: " + e);
        e.printStackTrace();
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Aggregations

DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)1 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)1 RoomDTO (io.fabric8.letschat.RoomDTO)1 IOException (java.io.IOException)1 ConnectException (java.net.ConnectException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 AuthenticationException (org.apache.http.auth.AuthenticationException)1 MalformedChallengeException (org.apache.http.auth.MalformedChallengeException)1 HttpResponseException (org.apache.http.client.HttpResponseException)1 SAXException (org.xml.sax.SAXException)1