forked from altran/Valuereporter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2 List implemented prefixes at http://localhost:4901/reporter/observ…
…e/implementedprefix
- Loading branch information
Showing
8 changed files
with
168 additions
and
26 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/main/java/org/valuereporter/gui/ImplementedController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.valuereporter.gui; | ||
|
||
import org.slf4j.Logger; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.servlet.ModelAndView; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
/** | ||
* Created by baardl on 29.07.15. | ||
*/ | ||
@Controller | ||
public class ImplementedController { | ||
private static final Logger log = getLogger(ImplementedController.class); | ||
public static final String PREFIX = "prefix"; | ||
public static final String METHOD_NAME = "methodName"; | ||
public static final String FROM = "from"; | ||
public static final String TO = "to"; | ||
|
||
@RequestMapping("/implemented") | ||
public ModelAndView showSlaGraph(@RequestParam(value = PREFIX, required = true) String prefix, @RequestParam(value = METHOD_NAME, required = true) String methodName) { | ||
Map model = new HashMap<String,String>(); | ||
model.put(PREFIX, prefix); | ||
model.put(METHOD_NAME, methodName); | ||
log.trace("Input prefix {}, methodName {}", prefix,methodName); | ||
return new ModelAndView("implemented", "model", model); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/main/java/org/valuereporter/implemented/ImplementedPrefixResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.valuereporter.implemented; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.slf4j.Logger; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
import java.io.IOException; | ||
import java.io.StringWriter; | ||
import java.io.Writer; | ||
import java.util.List; | ||
|
||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
/** | ||
* Created by baardl on 29.07.15. | ||
*/ | ||
@Component | ||
@Path("/implementedprefix") | ||
public class ImplementedPrefixResource { | ||
private static final Logger log = getLogger(ImplementedPrefixResource.class); | ||
|
||
private final QueryOperations queryOperations; | ||
private final WriteOperations writeOperations; | ||
private final ObjectMapper mapper; | ||
|
||
@Autowired | ||
public ImplementedPrefixResource(ObjectMapper mapper, QueryOperations queryOperations, WriteOperations writeOperations) { | ||
this.mapper = mapper; | ||
this.queryOperations = queryOperations; | ||
this.writeOperations = writeOperations; | ||
} | ||
|
||
//http://localhost:4901/reporter/observe/implementedprefix | ||
/** | ||
* List prefixes registered in the database | ||
* | ||
* @return List of ImplementedPrefix'es | ||
*/ | ||
@GET | ||
@Path("/") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Response findAllPrefixes() { | ||
final List<String> implementedPrefixes; | ||
|
||
implementedPrefixes = queryOperations.findImplementedPrefixes(); | ||
|
||
Writer strWriter = new StringWriter(); | ||
try { | ||
mapper.writeValue(strWriter, implementedPrefixes); | ||
} catch (IOException e) { | ||
log.error("Could not convert {} ImplementedPrefixes to JSON.", implementedPrefixes.size(), e); | ||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Error converting to requested format.").build(); | ||
} | ||
return Response.ok(strWriter.toString()).build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters