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.
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/*
* DeploymentHandler.java
*
*/
package org.glassfish.admingui.common.handlers;
import java.util.List;
import java.util.Map;
import java.util.Properties;
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.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