Search in sources :

Example 11 with JsonParseException

use of org.neo4j.server.rest.domain.JsonParseException in project neo4j by neo4j.

the class JmxService method queryBeans.

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Path(QUERY_PATH)
@SuppressWarnings("unchecked")
public Response queryBeans(String query) {
    try {
        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
        String json = dodgeStartingUnicodeMarker(query);
        Collection<Object> queries = (Collection<Object>) JsonHelper.readJson(json);
        ArrayList<JmxMBeanRepresentation> beans = new ArrayList<JmxMBeanRepresentation>();
        for (Object queryObj : queries) {
            assert queryObj instanceof String;
            for (Object objName : server.queryNames(new ObjectName((String) queryObj), null)) {
                beans.add(new JmxMBeanRepresentation((ObjectName) objName));
            }
        }
        return output.ok(new ListRepresentation("jmxBean", beans));
    } catch (JsonParseException e) {
        return output.badRequest(e);
    } catch (MalformedObjectNameException e) {
        return output.badRequest(e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) ArrayList(java.util.ArrayList) Collection(java.util.Collection) JmxMBeanRepresentation(org.neo4j.server.rest.management.repr.JmxMBeanRepresentation) JsonParseException(org.neo4j.server.rest.domain.JsonParseException) ListRepresentation(org.neo4j.server.rest.repr.ListRepresentation) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 12 with JsonParseException

use of org.neo4j.server.rest.domain.JsonParseException in project neo4j by neo4j.

the class RowFormatMetaFieldTest method setUp.

@Before
public void setUp() {
    // begin
    Response begin = http.POST("/db/data/transaction");
    assertThat(begin.status(), equalTo(201));
    assertHasTxLocation(begin);
    try {
        commitResource = begin.stringFromContent("commit");
    } catch (JsonParseException e) {
        fail("Exception caught when setting up test: " + e.getMessage());
    }
    assertThat(commitResource, equalTo(begin.location() + "/commit"));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) JsonParseException(org.neo4j.server.rest.domain.JsonParseException) Before(org.junit.Before)

Aggregations

JsonParseException (org.neo4j.server.rest.domain.JsonParseException)12 JsonNode (org.codehaus.jackson.JsonNode)8 Description (org.hamcrest.Description)7 TypeSafeMatcher (org.hamcrest.TypeSafeMatcher)7 HTTP (org.neo4j.test.server.HTTP)7 Response (org.neo4j.test.server.HTTP.Response)3 Before (org.junit.Before)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 MBeanServer (javax.management.MBeanServer)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 ObjectName (javax.management.ObjectName)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Status (org.neo4j.kernel.api.exceptions.Status)1 JmxMBeanRepresentation (org.neo4j.server.rest.management.repr.JmxMBeanRepresentation)1 ListRepresentation (org.neo4j.server.rest.repr.ListRepresentation)1