public static String copyWSASWar(IProgressMonitor monitor, String wsasHome) throws FileNotFoundException, IOException { String tempWarFile = null; String tempWarLocation = null; String tempUnzipLocation = null; try { if (new File(WSASCoreUtils.tempWSASDirectory()).isDirectory()) { tempWarLocation = WSASCoreUtils.addAnotherNodeToPath( WSASCoreUtils.tempWSASDirectory(), WSASCoreUIMessages.DIR_TEMPWAR); File tempWarLocationFile = new File(tempWarLocation); if (tempWarLocationFile.exists()) { FileUtils.deleteDirectories(tempWarLocationFile); } tempWarLocationFile.mkdirs(); tempWarFile = WSASCoreUtils.addAnotherNodeToPath(tempWarLocation, WSASCoreUIMessages.FILE_WSAS_WAR); new File(tempWarFile).createNewFile(); Properties properties = new Properties(); // properties.load(new FileInputStream(WSASCoreUtils.tempWSASWebappFileLocation())); // if (properties.containsKey(WSASCoreUIMessages.PROPERTY_KEY_PATH)){ if (ServerModel.getWsasServerPath() != null) { String wsasWarFile = WSASCoreUtils.addAnotherNodeToPath( (ServerModel.getWsasServerPath() != null) ? ServerModel.getWsasServerPath() : properties.getProperty(WSASCoreUIMessages.PROPERTY_KEY_PATH), WSASCoreUIMessages.FILE_WSAS_WAR); FileChannel srcChannel = new FileInputStream(wsasWarFile).getChannel(); FileChannel dstChannel = new FileOutputStream(tempWarFile).getChannel(); // Copy file contents from source to destination dstChannel.transferFrom(srcChannel, 0, srcChannel.size()); // Close the channels srcChannel.close(); dstChannel.close(); // unzip this into another foulder tempUnzipLocation = FileUtils.addAnotherNodeToPath(tempWarLocation, WSASCoreUIMessages.DIR_UNZIP); File tempUnzipLocationFile = new File(tempUnzipLocation); if (!tempUnzipLocationFile.exists()) { tempUnzipLocationFile.mkdirs(); } unzipWSASWar(tempWarFile, tempUnzipLocation); } } else { // Throws an error message } } catch (FileNotFoundException e) { throw e; } catch (IOException e) { throw e; } return tempUnzipLocation; }
public static String[] getServerLibraryPaths(IServer server) throws Exception { String[] result = null; if (server != null) { IServerManager wsasServerManager = ServerController.getInstance().getServerManager(); HashMap<String, Object> operationParameters = new HashMap<String, Object>(); operationParameters.put( ICarbonOperationManager.PARAMETER_TYPE, ICarbonOperationManager.OPERATION_GET_LIBRARY_PATHS); Object r = wsasServerManager.executeOperationOnServer( server, operationParameters); // getWSDLConversionResultUrl(resourceFile); if (r instanceof String[]) { result = (String[]) r; IPath serverLocation = getServerHome(server); for (int i = 0; i < result.length; i++) { result[i] = FileUtils.addAnotherNodeToPath(serverLocation.toOSString(), result[i]); } } } return result; }