[Carbon-dev] svn commit r16676 -
trunk/carbon-orbit/org.wso2.carbon.jar.upload/resources/web
svn at wso2.org
svn at wso2.org
Thu May 8 01:10:58 PDT 2008
Author: sandakith
Date: Thu May 8 01:10:54 2008
New Revision: 16676
Log:
Added the forount end for the carbon driver upload tool
Added:
trunk/carbon-orbit/org.wso2.carbon.jar.upload/resources/web/jarUpload.jsp
Modified:
trunk/carbon-orbit/org.wso2.carbon.jar.upload/resources/web/index.jsp
Modified: trunk/carbon-orbit/org.wso2.carbon.jar.upload/resources/web/index.jsp
==============================================================================
--- trunk/carbon-orbit/org.wso2.carbon.jar.upload/resources/web/index.jsp (original)
+++ trunk/carbon-orbit/org.wso2.carbon.jar.upload/resources/web/index.jsp Thu May 8 01:10:54 2008
@@ -1,28 +1,43 @@
-/*
- * Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<title>Insert title here</title>
-</head>
-<body>
-</body>
-</html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Carbon Jar Upload Tool</title>
+ </head>
+
+ <body>
+ <h3>Carbon Driver Upload Tool </h3>
+ <h4>Select the Carbon Home and Third Party Driver Location, Then Click Upload Driver</h4>
+ <form method=post action="jarUpload.jsp">
+ <table border="0">
+ <tr>
+ <td>Carbon Home</td>
+ <td><input type=text name=carbon_home size=70 /> </td>
+ </tr>
+ <tr>
+ <td>Driver Location</td>
+ <td><input type=text name=driver_location size=70 /></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ </tr>
+ </table>
+ <input type=submit value="Upload Driver"/>
+ <input type=reset value="Clear" />
+ </form>
+ </body>
+
+</html>
\ No newline at end of file
Added: trunk/carbon-orbit/org.wso2.carbon.jar.upload/resources/web/jarUpload.jsp
==============================================================================
--- (empty file)
+++ trunk/carbon-orbit/org.wso2.carbon.jar.upload/resources/web/jarUpload.jsp Thu May 8 01:10:54 2008
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<%@page import = "org.wso2.carbon.jar.upload.CarbonJarUploadUtil"%>
+<%@page import="java.io.File"%>
+<%@page import="org.wso2.carbon.jar.upload.CarbonJarUploadConstant"%>
+<%@page import="org.w3c.dom.Document"%>
+<%@page import="java.io.IOException"%>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Carbon Jar Upload Tool</title>
+ </head>
+
+
+ <body>
+ <h3>Carbon Driver Upload Tool Results</h3>
+ <%
+ String carbonHome = request.getParameter("carbon_home");
+ String driverLocation = request.getParameter("driver_location");
+ boolean validationResult = false;
+ boolean driverUploadResults = false;
+ boolean webXMLReplacementResult = false;
+
+ // Retrieve the carbon Home and validate it.
+ CarbonJarUploadUtil carbonJarUploadUtil = new CarbonJarUploadUtil();
+ validationResult = carbonJarUploadUtil.validateCarbonHome(new File(carbonHome));
+
+ StringBuffer packageList = null;
+ // Add the jar to the carbon lib.
+ //copyJarToCarbonLib(carbonHome,driverLocation);
+ File libWebXMLLocation = new File(carbonHome +
+ File.separator + CarbonJarUploadConstant.webappsFolder +
+ File.separator + CarbonJarUploadConstant.rootFolder +
+ File.separator + CarbonJarUploadConstant.webinfFolder +
+ File.separator + CarbonJarUploadConstant.libFolder +
+ File.separator + "model.jar"
+ );
+ if (libWebXMLLocation.exists()) {
+ libWebXMLLocation.delete();
+ }
+ driverUploadResults = carbonJarUploadUtil.copyFileToAnotherLocation(new File(driverLocation), libWebXMLLocation);
+
+ // Get the package list from the jar file.
+ try {
+ packageList = carbonJarUploadUtil.createPackageListFromJar(driverLocation,",");
+ // Load the web.xml and append the entries.
+ File webXmlLoation = new File(
+ carbonHome +
+ File.separator + CarbonJarUploadConstant.webappsFolder +
+ File.separator + CarbonJarUploadConstant.rootFolder +
+ File.separator + CarbonJarUploadConstant.webinfFolder +
+ File.separator + CarbonJarUploadConstant.webXML
+ );
+ Document newWebXML = carbonJarUploadUtil.addExternalPackagesToWebXML(
+ webXmlLoation,
+ packageList.toString());
+
+ // Backup the web.xml and Replace the web.xml with the new modified one
+ //File backupDir = createBackupdirectory();
+ File backupDirectory = new File("resources/backup");
+ if (!backupDirectory.exists()) {
+ backupDirectory.mkdirs();
+ }
+ File newWebXmlBackupFile = new File(backupDirectory + File.separator
+ + CarbonJarUploadConstant.webXML
+ + System.currentTimeMillis());
+
+ if (!newWebXmlBackupFile.exists()) {
+ newWebXmlBackupFile.createNewFile();
+ }
+ carbonJarUploadUtil.copyFileToAnotherLocation(webXmlLoation,newWebXmlBackupFile);
+ webXMLReplacementResult = carbonJarUploadUtil.writeXmlFile(newWebXML, webXmlLoation.getAbsolutePath());
+
+ // TODO the below will be done in carbon component
+ // Signal carbon to restart.
+ // Write the JSP for obtaining Carbon_Home and jar and call back end.
+ // TODO the above will be done in carbon component
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ %>
+
+ <p>Carbon Home Validation Process Result : <%= validationResult %></p>
+ <p>Driver Upload Results Process Result : <%= driverUploadResults %></p>
+ <p>Web XML File Package List Addition Result : <%= webXMLReplacementResult %></p>
+
+ </body>
+
+</html>
More information about the Carbon-dev
mailing list