public TBXSynchronousOperation createWPSSyncOperation(File newServicePath, String processingName) throws Exception { TBXSynchronousOperation operationShellDescr = WPSOperation.newWPSSyncOperation(processingName); FileInputStream topStream, bottomStream; SequenceInputStream seqStream; /*Vector<InputStream> streams; topStream=new FileInputStream(new File(newServicePath,EXECUTE_ENVIRONMENT_TXT_FILE_TOP)); bottomStream=new FileInputStream(new File(newServicePath,EXECUTE_ENVIRONMENT_TXT_FILE_BOTTOM)); streams=new Vector<InputStream>(); streams.add(topStream);*/ File shellScriptFolder = new File(newServicePath, SHELL_SCRIPT_PATH); shellScriptFolder.mkdirs(); IOUtil.copy( shellStream, new FileOutputStream( new File( shellScriptFolder, SHELL_SCRIPT_FILE_PREFIX + processingName + "_original.sh"))); /*streams.add(new FileInputStream(new File(shellScriptFolder,SHELL_SCRIPT_FILE_PREFIX+processingName+"_original.sh"))); String shellOutpManager=IOUtil.inputToString(new FileInputStream(new File(newServicePath,SHELL_SCRIPT_PATH+"/"+SHELL_SCRIPT_FILE_PREFIX+processingName+"_outputManager.tmp"))); shellOutpManager=shellOutpManager.replaceAll("<", "<"); shellOutpManager=shellOutpManager.replaceAll(">", ">"); shellOutpManager=shellOutpManager.replaceAll("&", "&"); streams.add(new ByteArrayInputStream(shellOutpManager.getBytes())); streams.add(bottomStream); seqStream=new SequenceInputStream(streams.elements()); String shellScript=IOUtil.inputToString(seqStream); FileOutputStream shellScriptOutputStream=new FileOutputStream(new File(newServicePath,EXECUTE_ENVIRONMENT_XSL_FILE_PATH)); shellScriptOutputStream.write(shellScript.getBytes()); shellScriptOutputStream.close();*/ String shellOutpManager = IOUtil.loadString( new File( newServicePath, SHELL_SCRIPT_PATH + "/" + SHELL_SCRIPT_FILE_PREFIX + processingName + "_outputManager.tmp")); String shellProcessScript = IOUtil.inputToString( new FileInputStream( new File( shellScriptFolder, SHELL_SCRIPT_FILE_PREFIX + processingName + "_original.sh"))) + shellOutpManager; FileOutputStream shellScriptOutputStream = new FileOutputStream( new File(newServicePath, getScriptPathforProcessingName(processingName))); shellScriptOutputStream.write(shellProcessScript.getBytes()); shellScriptOutputStream.close(); operationShellDescr.setScripts( getExecuteScriptDescriptorSync(newServicePath, EXECUTE_OPERATION_PREFIX + processingName)); operationShellDescr.setAdmittedHosts(""); return operationShellDescr; }
public void updateScriptEngine(File newServicePath, String processingName, Object script) throws Exception { FileInputStream topStream, bottomStream; SequenceInputStream seqStream; shellStream = (InputStream) script; /*Vector<InputStream> streams; topStream=new FileInputStream(new File(newServicePath,EXECUTE_ENVIRONMENT_TXT_FILE_TOP)); bottomStream=new FileInputStream(new File(newServicePath,EXECUTE_ENVIRONMENT_TXT_FILE_BOTTOM)); streams=new Vector<InputStream>(); streams.add(topStream);*/ File shellScriptFolder = new File(newServicePath, SHELL_SCRIPT_PATH); shellScriptFolder.mkdirs(); IOUtil.copy( shellStream, new FileOutputStream( new File( shellScriptFolder, SHELL_SCRIPT_FILE_PREFIX + processingName + "_original.sh"))); // streams.add(new FileInputStream(new // File(shellScriptFolder,SHELL_SCRIPT_FILE_PREFIX+processingName+"_original.sh"))); /*String shellOutpManager=IOUtil.inputToString(new FileInputStream(new File(newServicePath,SHELL_SCRIPT_PATH+"/"+SHELL_SCRIPT_FILE_PREFIX+processingName+"_outputManager.tmp"))); shellOutpManager=shellOutpManager.replaceAll("<", "<"); shellOutpManager=shellOutpManager.replaceAll(">", ">"); shellOutpManager=shellOutpManager.replaceAll("&", "&"); streams.add(new ByteArrayInputStream(shellOutpManager.getBytes())); streams.add(bottomStream); seqStream=new SequenceInputStream(streams.elements()); String shellScript=IOUtil.inputToString(seqStream); FileOutputStream shellScriptOutputStream=new FileOutputStream(new File(newServicePath,EXECUTE_ENVIRONMENT_XSL_FILE_PATH)); shellScriptOutputStream.write(shellScript.getBytes()); shellScriptOutputStream.close();*/ String shellOutpManager = IOUtil.loadString( new File( newServicePath, SHELL_SCRIPT_PATH + "/" + SHELL_SCRIPT_FILE_PREFIX + processingName + "_outputManager.tmp")); String shellProcessScript = IOUtil.inputToString( new FileInputStream( new File( shellScriptFolder, SHELL_SCRIPT_FILE_PREFIX + processingName + "_original.sh"))) + shellOutpManager; FileOutputStream shellScriptOutputStream = new FileOutputStream( new File(newServicePath, getScriptPathforProcessingName(processingName))); shellScriptOutputStream.write(shellProcessScript.getBytes()); shellScriptOutputStream.close(); }
public String generateEngineTemplate( File newServicePath, Document describeDocument, String processingName) throws Exception { Document xslDocument; String shellTemplate = null; File stylesheet = new File(newServicePath, SHELL_TEMPLATE_XSLT_PATH); File shellScriptFolder = new File(newServicePath, SHELL_SCRIPT_PATH); shellScriptFolder.mkdirs(); if (stylesheet.exists()) { xslDocument = domUtil.fileToDocument(stylesheet); transformer = TransformerFactory.newInstance().newTransformer(new DOMSource(xslDocument)); transformer.transform( new StreamSource(DOMUtil.getDocumentAsInputStream(describeDocument)), new StreamResult( new FileOutputStream( new File( shellScriptFolder, SHELL_SCRIPT_FILE_PREFIX + processingName + "_template.sh")))); shellTemplate = IOUtil.loadString( new File( shellScriptFolder, SHELL_SCRIPT_FILE_PREFIX + processingName + "_template.sh")); } return shellTemplate; }