use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class UpdateCenterHandlers method getUpdateComponentCount.
@Handler(id = "getUpdateComponentCount")
public static void getUpdateComponentCount(HandlerContext handlerCtx) {
boolean donotPing = false;
// If user set NO_NETWORK system properties, don't try to do anything.
boolean noNetwork = (Boolean) GuiUtil.getSessionValue("_noNetwork");
if (noNetwork) {
GuiUtil.getLogger().info(GuiUtil.getMessage(BUNDLE, "noNetworkDetected"));
donotPing = true;
} else {
UpdateCheckFrequency userPreference = SystemInfo.getUpdateCheckFrequency();
if (userPreference == UpdateCheckFrequency.NEVER) {
GuiUtil.getLogger().info(GuiUtil.getMessage(BUNDLE, "noCheckPerformed"));
GuiUtil.setSessionValue("_doNotPing", "true");
donotPing = true;
}
}
if (donotPing) {
GuiUtil.setSessionValue("_hideUpdateMsg", Boolean.TRUE);
return;
}
GuiUtil.setSessionValue("_hideUpdateMsg", Boolean.FALSE);
GuiUtil.setSessionValue("_updateCountMsg", "");
UcThread thread = new UcThread((HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false));
thread.start();
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class UpdateCenterHandlers method setProxyInfo.
@Handler(id = "setProxyInfo", input = { @HandlerInput(name = "connection", type = String.class), @HandlerInput(name = "host", type = String.class), @HandlerInput(name = "port", type = String.class) })
public static void setProxyInfo(HandlerContext handlerCtx) {
String connection = (String) handlerCtx.getInputValue("connection");
String host = (String) handlerCtx.getInputValue("host");
String port = (String) handlerCtx.getInputValue("port");
try {
Image image = getUpdateCenterImage();
if (image == null) {
String ucDir = (String) GuiUtil.getSessionValue("topDir");
GuiUtil.handleError(handlerCtx, GuiUtil.getMessage(BUNDLE, "NoImage", new String[] { ucDir }));
return;
}
if (connection.equals("useProxy")) {
int portNo = Integer.parseInt(port);
SocketAddress address = new InetSocketAddress(host, portNo);
image.setProxy(new Proxy(Proxy.Type.HTTP, address));
String url = "http://" + host + ":" + portNo;
Properties prop = new Properties();
prop.setProperty("proxy.URL", url);
SystemInfo.initUpdateToolProps(prop);
} else {
image.setProxy(null);
Properties prop = new Properties();
prop.setProperty("proxy.URL", "");
SystemInfo.initUpdateToolProps(prop);
}
} catch (Exception ex) {
GuiUtil.handleException(handlerCtx, ex);
}
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class UpdateCenterHandlers method getPkgDetailsInfo.
@Handler(id = "getPkgDetailsInfo", input = { @HandlerInput(name = "fmriStr", type = String.class, required = true), @HandlerInput(name = "auth", type = String.class, required = true) }, output = { @HandlerOutput(name = "details", type = java.util.Map.class) })
public static void getPkgDetailsInfo(HandlerContext handlerCtx) {
String fmriStr = (String) handlerCtx.getInputValue("fmriStr");
// Called by the intiPage and don't need to process. When we can use beforeCreate to do this, we can remove this check.
if (fmriStr == null) {
handlerCtx.setOutputValue("details", new HashMap());
return;
}
Fmri fmri = new Fmri(fmriStr);
Map details = new HashMap();
Image img = getUpdateCenterImage();
try {
details.put("pkgName", fmri.getName());
details.put("uid", fmri.toString());
details.put("version", getPkgVersion(fmri.getVersion()));
details.put("date", fmri.getVersion().getPublishDate());
details.put("auth", (String) handlerCtx.getInputValue("auth"));
details.put("url", fmri.getURLPath());
if (img != null) {
Manifest manifest = img.getManifest(fmri);
details.put("category", getCategory(manifest));
details.put("bytes", "" + manifest.getPackageSize());
details.put("pkgSize", getPkgSize(manifest));
// look for description in the following order:
// pkg.description, description_long, pkg.summary, description
// since description_long and description has been deprecated.
String desc = manifest.getAttribute(PKG_DESC);
if (GuiUtil.isEmpty(desc)) {
desc = manifest.getAttribute(DESC_LONG);
if (GuiUtil.isEmpty(desc)) {
desc = manifest.getAttribute(PKG_SUMMARY);
if (GuiUtil.isEmpty(desc))
desc = manifest.getAttribute(DESC);
}
}
details.put("desc", desc);
}
} catch (Exception ex) {
ex.printStackTrace();
}
handlerCtx.setOutputValue("details", details);
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class WebHandlers method changeNetworkListenersInVS.
@Handler(id = "changeNetworkListenersInVS", input = { @HandlerInput(name = "vsAttrs", type = Map.class, required = true), @HandlerInput(name = "listenerName", type = String.class, required = true), @HandlerInput(name = "addFlag", type = Boolean.class, required = true) }, output = { @HandlerOutput(name = "result", type = Map.class) })
public static void changeNetworkListenersInVS(HandlerContext handlerCtx) {
// get the virtual server and add this network listener to it.
Map vsAttrs = (HashMap) handlerCtx.getInputValue("vsAttrs");
String listenerName = (String) handlerCtx.getInputValue("listenerName");
Boolean addFlag = (Boolean) handlerCtx.getInputValue("addFlag");
String nwListeners = (String) vsAttrs.get("networkListeners");
List<String> listeners = GuiUtil.parseStringList(nwListeners, ",");
if (addFlag.equals(Boolean.TRUE)) {
if (!listeners.contains(listenerName)) {
listeners.add(listenerName);
}
} else {
if (listeners.contains(listenerName)) {
listeners.remove(listenerName);
}
}
String ll = GuiUtil.listToString(listeners, ",");
vsAttrs.put("networkListeners", ll);
handlerCtx.setOutputValue("result", vsAttrs);
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class RestUtil2 method sendRequestToCollectionResource.
@Handler(id = "rest.list", input = { @HandlerInput(name = "endpoint", type = String.class, required = true), @HandlerInput(name = "attrs", type = Map.class, required = false) }, output = { @HandlerOutput(name = "result", type = List.class) })
public static void sendRequestToCollectionResource(HandlerContext handlerCtx) {
// Map<String, Object> attrs = (Map<String, Object>) handlerCtx.getInputValue("attrs");
String endpoint = fixEndpoint((String) handlerCtx.getInputValue("endpoint"));
Response resp = RestUtil.getJerseyClient().target(endpoint).request(RestUtil.RESPONSE_TYPE).cookie(new Cookie(RestUtil.REST_TOKEN_COOKIE, RestUtil.getRestToken())).get(Response.class);
if (!isSuccess(resp.getStatus())) {
throw new RuntimeException(resp.readEntity(String.class));
}
List list = resp.readEntity(List.class);
handlerCtx.setOutputValue("result", list);
}
Aggregations