
org.glassfish.admingui.common.handlers.RestUtilHandlers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of console-common Show documentation
Show all versions of console-common Show documentation
This bundle contains common code that may be shared across plugins.
The newest version!
/*
* Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
/*
* RestUitlHandlers.java
*
* Created on July 1,2010 9:32 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
/**
*
* @author anilam
*/
package org.glassfish.admingui.common.handlers;
import com.sun.jsftemplating.annotation.Handler;
import com.sun.jsftemplating.annotation.HandlerInput;
import com.sun.jsftemplating.annotation.HandlerOutput;
import com.sun.jsftemplating.layout.descriptors.handler.HandlerContext;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.glassfish.admingui.common.util.GuiUtil;
import org.glassfish.admingui.common.util.RestUtil;
public class RestUtilHandlers {
public RestUtilHandlers() {
}
@Handler(id = "gf.callRestAndExtractMsgProps",
input = {
@HandlerInput(name="endpoint", type=String.class, required=true),
@HandlerInput(name="attrs", type=Map.class, required=false),
@HandlerInput(name="method", type=String.class, defaultValue="post"),
@HandlerInput(name="index", type=Integer.class, defaultValue="0")
},
output = {
@HandlerOutput(name = "keyList", type = List.class),
@HandlerOutput(name = "propsMap", type = Map.class),
@HandlerOutput(name = "listEmpty", type = Boolean.class)
})
public static void callRestAndExtractMsgProps(HandlerContext handlerCtx) {
Map attrs = (Map) handlerCtx.getInputValue("attrs");
String endpoint = (String) handlerCtx.getInputValue("endpoint");
String method = ((String) handlerCtx.getInputValue("method")).toLowerCase(GuiUtil.guiLocale);
int index = (Integer) handlerCtx.getInputValue("index");
try{
Map responseMap = RestUtil.restRequest( endpoint , attrs, method , handlerCtx, false);
ArrayList messages = (ArrayList) responseMap.get("messages");
if (messages != null) {
Map message = (Map) messages.get(index);
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy