use of org.glassfish.admingui.common.util.RestResponse in project Payara by payara.
the class RestResponseTest method testGetCommand.
@Test
public void testGetCommand() {
RestResponse response = RestUtil.get(URL_UPTIME);
assertTrue(response.getResponseBody().contains("\"uptime AdminCommand\""));
}
use of org.glassfish.admingui.common.util.RestResponse in project Payara by payara.
the class RestResponseTest method testPostCommand.
@Test
public void testPostCommand() {
RestResponse response = RestUtil.get(URL_GENERATE_JVM_REPORT, new HashMap<String, Object>() {
{
put("type", "summary");
}
});
final String responseBody = response.getResponseBody();
System.err.println(responseBody);
assertTrue(responseBody.contains("Operating System Information"));
}
use of org.glassfish.admingui.common.util.RestResponse in project Payara by payara.
the class RestApiHandlers method createEntity.
/**
* REST-based version of createProxy
* @param handlerCtx
*/
@Handler(id = "gf.createEntity", input = { @HandlerInput(name = "endpoint", type = String.class, required = true), @HandlerInput(name = "attrs", type = Map.class, required = true), @HandlerInput(name = "skipAttrs", type = List.class), @HandlerInput(name = "onlyUseAttrs", type = List.class), @HandlerInput(name = "convertToFalse", type = List.class), @HandlerInput(name = "throwException", type = boolean.class, defaultValue = "true") }, output = { @HandlerOutput(name = "result", type = String.class) })
public static void createEntity(HandlerContext handlerCtx) {
Map<String, Object> attrs = (Map) handlerCtx.getInputValue("attrs");
if (attrs == null) {
attrs = new HashMap<String, Object>();
}
String endpoint = (String) handlerCtx.getInputValue("endpoint");
RestResponse response = sendCreateRequest(endpoint, attrs, (List) handlerCtx.getInputValue("skipAttrs"), (List) handlerCtx.getInputValue("onlyUseAttrs"), (List) handlerCtx.getInputValue("convertToFalse"));
boolean throwException = (Boolean) handlerCtx.getInputValue("throwException");
parseResponse(response, handlerCtx, endpoint, attrs, false, throwException);
// ??? I believe this should return a Map, whats the point of returning the endpoint that was passed in.
// But i haven't looked through all the code, so decide to leave it for now.
handlerCtx.setOutputValue("result", endpoint);
}
use of org.glassfish.admingui.common.util.RestResponse in project Payara by payara.
the class RestApiHandlers method updateEntity.
/**
* Create or update
*/
@Handler(id = "gf.updateEntity", input = { @HandlerInput(name = "endpoint", type = String.class, required = true), @HandlerInput(name = "attrs", type = Map.class, required = true), @HandlerInput(name = "skipAttrs", type = List.class), @HandlerInput(name = "onlyUseAttrs", type = List.class), @HandlerInput(name = "convertToFalse", type = List.class) }, output = { @HandlerOutput(name = "result", type = String.class) })
public static void updateEntity(HandlerContext handlerCtx) {
Map<String, Object> attrs = (Map) handlerCtx.getInputValue("attrs");
if (attrs == null) {
attrs = new HashMap<String, Object>();
}
String endpoint = (String) handlerCtx.getInputValue("endpoint");
RestResponse response = sendUpdateRequest(endpoint, attrs, (List) handlerCtx.getInputValue("skipAttrs"), (List) handlerCtx.getInputValue("onlyUseAttrs"), (List) handlerCtx.getInputValue("convertToFalse"));
if (!response.isSuccess()) {
GuiUtil.getLogger().log(Level.SEVERE, GuiUtil.getCommonMessage("LOG_UPDATE_ENTITY_FAILED", new Object[] { endpoint, attrs }));
GuiUtil.handleError(handlerCtx, GuiUtil.getMessage("msg.error.checkLog"));
return;
}
handlerCtx.setOutputValue("result", endpoint);
}
use of org.glassfish.admingui.common.util.RestResponse in project Payara by payara.
the class RestApiHandlers method deleteCascade.
/**
* // TODO: just these resources?
* deleteCascade handles delete for jdbc connection pool and connector connection pool
* The dependent resources jdbc resource and connector resource are deleted on deleting
* the pools
*/
@Handler(id = "gf.deleteCascade", input = { @HandlerInput(name = "endpoint", type = String.class, required = true), @HandlerInput(name = "selectedRows", type = List.class, required = true), @HandlerInput(name = "id", type = String.class, defaultValue = "name"), @HandlerInput(name = "cascade", type = String.class) })
public static void deleteCascade(HandlerContext handlerCtx) {
try {
Map<String, Object> payload = new HashMap<String, Object>();
String endpoint = (String) handlerCtx.getInputValue("endpoint");
String id = (String) handlerCtx.getInputValue("id");
String cascade = (String) handlerCtx.getInputValue("cascade");
if (cascade != null) {
payload.put("cascade", cascade);
}
for (Map oneRow : (List<Map>) handlerCtx.getInputValue("selectedRows")) {
RestResponse response = delete(endpoint + "/" + URLEncoder.encode((String) oneRow.get(id), "UTF-8"), payload);
if (!response.isSuccess()) {
GuiUtil.handleError(handlerCtx, "Unable to delete the resource " + (String) oneRow.get(id));
}
}
} catch (Exception ex) {
GuiUtil.handleException(handlerCtx, ex);
}
}
Aggregations