Search in sources :

Example 1 with EnvironmentInformationsVO

use of org.olat.restapi.system.vo.EnvironmentInformationsVO in project openolat by klemens.

the class SystemTest method testEnvironmentSystem.

@Test
public void testEnvironmentSystem() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI systemUri = conn.getContextURI().path("system").path("environment").build();
    EnvironmentInformationsVO envInfos = conn.get(systemUri, EnvironmentInformationsVO.class);
    assertNotNull(envInfos);
    assertNotNull(envInfos.getArch());
    assertTrue(envInfos.getAvailableProcessors() > 0);
    assertNotNull(envInfos.getOsName());
    assertNotNull(envInfos.getOsVersion());
    assertNotNull(envInfos.getRuntimeName());
    assertNotNull(envInfos.getVmName());
    assertNotNull(envInfos.getVmVendor());
    assertNotNull(envInfos.getVmVersion());
    conn.shutdown();
}
Also used : EnvironmentInformationsVO(org.olat.restapi.system.vo.EnvironmentInformationsVO) URI(java.net.URI) Test(org.junit.Test)

Example 2 with EnvironmentInformationsVO

use of org.olat.restapi.system.vo.EnvironmentInformationsVO in project OpenOLAT by OpenOLAT.

the class SystemWebService method getEnvironnementXml.

/**
 * Return some informations about the environment.
 * @response.representation.200.qname {http://www.example.com}environmentVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc A short summary of the number of classes
 * @response.representation.200.example {@link org.olat.restapi.system.vo.Examples#SAMPLE_ENVVO}
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @param request The HTTP request
 * @return The informations about the environment
 */
@GET
@Path("environment")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getEnvironnementXml(@Context HttpServletRequest request) {
    if (!isAdminOrSystem(request)) {
        return null;
    }
    OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
    RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
    EnvironmentInformationsVO vo = new EnvironmentInformationsVO(os, runtime);
    return Response.ok(vo).build();
}
Also used : EnvironmentInformationsVO(org.olat.restapi.system.vo.EnvironmentInformationsVO) RuntimeMXBean(java.lang.management.RuntimeMXBean) OperatingSystemMXBean(java.lang.management.OperatingSystemMXBean) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with EnvironmentInformationsVO

use of org.olat.restapi.system.vo.EnvironmentInformationsVO in project OpenOLAT by OpenOLAT.

the class SystemTest method testEnvironmentSystem.

@Test
public void testEnvironmentSystem() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI systemUri = conn.getContextURI().path("system").path("environment").build();
    EnvironmentInformationsVO envInfos = conn.get(systemUri, EnvironmentInformationsVO.class);
    assertNotNull(envInfos);
    assertNotNull(envInfos.getArch());
    assertTrue(envInfos.getAvailableProcessors() > 0);
    assertNotNull(envInfos.getOsName());
    assertNotNull(envInfos.getOsVersion());
    assertNotNull(envInfos.getRuntimeName());
    assertNotNull(envInfos.getVmName());
    assertNotNull(envInfos.getVmVendor());
    assertNotNull(envInfos.getVmVersion());
    conn.shutdown();
}
Also used : EnvironmentInformationsVO(org.olat.restapi.system.vo.EnvironmentInformationsVO) URI(java.net.URI) Test(org.junit.Test)

Example 4 with EnvironmentInformationsVO

use of org.olat.restapi.system.vo.EnvironmentInformationsVO in project openolat by klemens.

the class SystemWebService method getEnvironnementXml.

/**
 * Return some informations about the environment.
 * @response.representation.200.qname {http://www.example.com}environmentVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc A short summary of the number of classes
 * @response.representation.200.example {@link org.olat.restapi.system.vo.Examples#SAMPLE_ENVVO}
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @param request The HTTP request
 * @return The informations about the environment
 */
@GET
@Path("environment")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getEnvironnementXml(@Context HttpServletRequest request) {
    if (!isAdminOrSystem(request)) {
        return null;
    }
    OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
    RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
    EnvironmentInformationsVO vo = new EnvironmentInformationsVO(os, runtime);
    return Response.ok(vo).build();
}
Also used : EnvironmentInformationsVO(org.olat.restapi.system.vo.EnvironmentInformationsVO) RuntimeMXBean(java.lang.management.RuntimeMXBean) OperatingSystemMXBean(java.lang.management.OperatingSystemMXBean) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

EnvironmentInformationsVO (org.olat.restapi.system.vo.EnvironmentInformationsVO)4 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)2 RuntimeMXBean (java.lang.management.RuntimeMXBean)2 URI (java.net.URI)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Test (org.junit.Test)2