Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 1997, 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
*/
/*
* DeploymentHandler.java
*
*/
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.SyntaxException;
import com.sun.jsftemplating.layout.descriptors.handler.HandlerContext;
import com.sun.jsftemplating.layout.template.TemplateParser;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.glassfish.admingui.common.util.AppUtil;
import org.glassfish.admingui.common.util.DeployUtil;
import org.glassfish.admingui.common.util.GuiUtil;
import org.glassfish.admingui.common.util.RestUtil;
import org.glassfish.admingui.common.util.TargetUtil;
/**
*
*/
public class DeploymentHandler {
@Handler(id = "deploy",
input = {
@HandlerInput(name = "filePath", type = String.class),
@HandlerInput(name = "origPath", type = String.class),
@HandlerInput(name = "allMaps", type = Map.class),
@HandlerInput(name = "appType", type = String.class),
@HandlerInput(name="targets", type=String[].class, required=true ),
@HandlerInput(name = "propertyList", type = List.class)
})
public static void deploy(HandlerContext handlerCtx) {
String appType = (String) handlerCtx.getInputValue("appType");
String origPath = (String) handlerCtx.getInputValue("origPath");
String filePath = (String) handlerCtx.getInputValue("filePath");
Map allMaps = (Map) handlerCtx.getInputValue("allMaps");
Map attrMap = new HashMap((Map) allMaps.get(appType));
Map payload = new HashMap();
List appRefs = new ArrayList();
if (GuiUtil.isEmpty(origPath)) {
GuiUtil.getLogger().info("deploy(): origPath is NULL");
String mesg = GuiUtil.getMessage("msg.deploy.nullArchiveError");
GuiUtil.handleError(handlerCtx, mesg);
return;
}
try{
String decodedName = URLDecoder.decode((String)attrMap.get("name"), "UTF-8");
attrMap.put("name", decodedName);
}catch(Exception ex){
//ignore
}
/* Take care some special properties, such as VS */
//do not send VS if user didn't specify, refer to bug#6542276
String[] vs = (String[]) attrMap.get("virtualservers");
if (vs != null && vs.length > 0) {
if (!GuiUtil.isEmpty(vs[0])) {
String vsTargets = GuiUtil.arrayToString(vs, ",");
payload.put("virtualservers", vsTargets);
}
}
attrMap.remove("virtualservers");
//Take care of checkBox
List convertToFalseList = (List) attrMap.get("convertToFalseList");
if (convertToFalseList != null) {
for (String one : convertToFalseList) {
if (attrMap.get(one) == null) {
attrMap.put(one, "false");
}
}
attrMap.remove("convertToFalseList");
}
StringBuilder sb = new StringBuilder();
String sep = "";
Properties props = new Properties();
for (Object attr : attrMap.keySet()) {
String key = (String) attr;
String prefix = "PROPERTY-";
String value = (String) attrMap.get(key);
if (value == null) {
continue;
}
if (key.startsWith(prefix)) {
if (! value.equals("")){
props.setProperty(key.substring(prefix.length()), value);
sb.append(sep).append(key.substring(prefix.length())).append("=").append(value);
sep=":";
}
} else {
payload.put(key, value);
}
}
// include any additional property that user enters
List