Skip to content

Commit

Permalink
added rest api endpoint
Browse files Browse the repository at this point in the history
Issue #4
  • Loading branch information
rsoika committed Aug 28, 2021
1 parent 54035ff commit 8167206
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 4 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,23 @@ to start the container run:
$ docker run \
-e TZ="CET" \
-e LANG="en_US.UTF-8" \
-v $PWD/docker/configuration/config.xml:/opt/jboss/wildfly/config.xml \
-v $PWD/docker/configuration/config.xml:/opt/jboss/config.xml \
-p "8080:8080" \
imixs/muluk:latest

**Note:** The MULUK_CONFIG_FILE must point to your local config.xml file




## Rest API

You can request the current config state with the Rest API endpoint:

http://localhos:8080/api/config

This will return the XML object including the latest monitoring data.

## Local Development

During development you can build a dev version providing debugging mode. To build the dev version run:
Expand All @@ -115,7 +126,7 @@ to start the container in dev mode run:
-e TZ="CET" \
-e LANG="en_US.UTF-8" \
-v $PWD/docker/deployments:/opt/jboss/wildfly/standalone/deployments/ \
-v $PWD/docker/configuration/config.xml:/opt/jboss/wildfly/config.xml \
-v $PWD/docker/configuration/config.xml:/opt/jboss/config.xml \
-p "8080:8080" \
-p "8787:8787" \
imixs/muluk:latest
Expand Down
87 changes: 87 additions & 0 deletions src/main/java/org/imixs/muluk/RestService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* Imixs-Workflow
*
* Copyright (C) 2001-2020 Imixs Software Solutions GmbH,
* http://www.imixs.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You can receive a copy of the GNU General Public
* License at http://www.gnu.org/licenses/gpl.html
*
* Project:
* https://www.imixs.org
* https://github.com/imixs/imixs-workflow
*
* Contributors:
* Imixs Software Solutions GmbH - Project Management
* Ralph Soika - Software Developer
*/

package org.imixs.muluk;

import java.io.IOException;
import java.io.OutputStream;

import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;

/**
* The RestService provides the api to get the current config
*
* @author rsoika
*
*/
@Path("/")
@Produces({ MediaType.APPLICATION_XML, MediaType.TEXT_XML })
@Stateless
public class RestService {

@Inject
MonitorService monitorService;

@GET
@Produces(MediaType.APPLICATION_XHTML_XML)
public StreamingOutput getRoot() {

return new StreamingOutput() {
public void write(OutputStream out) throws IOException, WebApplicationException {

out.write("<div class=\"root\">".getBytes());
out.write("<a href=\"/config\" type=\"application/xml\" rel=\"documents\"/>".getBytes());
out.write("</div>".getBytes());
}
};
}

/**
* Method to invalidate the current user session
* <p>
* Should be called by a client
*
* @return
*/
@GET
@Path("/config")
public Response convertResultList() {
return Response.ok(monitorService.getConfig()).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML)
.build();
}

}
5 changes: 4 additions & 1 deletion src/main/webapp/css/dark/muluk.css
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,12 @@ body {

#imixs-footer {
width: 100%;
margin-top:50px;
padding: 10px 30px 10px 210px;
text-align: right;
border-top: 1px solid #ccc;
border-top: 1px solid #999;
color: #999;
font-size:0.8em;
}

#imixs-footer a {
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/layout/template.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
</f:view>

<!-- FOOTER -->
<div id="imixs-footer"><a href="https://github.com/imixs/muluk">Github</a></div>
<div id="imixs-footer"> <a href="/api/config" style="margin-right:20px;">Rest API</a> <a href="https://github.com/imixs/muluk">Github</a></div>
</div>
</h:body>
</html>

0 comments on commit 8167206

Please sign in to comment.