summaryrefslogtreecommitdiffstats
path: root/ems/boco/target/site/jacoco-ut/org.onap.vfc.nfvo.emsdriver.commons.ftp/FTPSrv.java.html
diff options
context:
space:
mode:
Diffstat (limited to 'ems/boco/target/site/jacoco-ut/org.onap.vfc.nfvo.emsdriver.commons.ftp/FTPSrv.java.html')
-rw-r--r--ems/boco/target/site/jacoco-ut/org.onap.vfc.nfvo.emsdriver.commons.ftp/FTPSrv.java.html200
1 files changed, 0 insertions, 200 deletions
diff --git a/ems/boco/target/site/jacoco-ut/org.onap.vfc.nfvo.emsdriver.commons.ftp/FTPSrv.java.html b/ems/boco/target/site/jacoco-ut/org.onap.vfc.nfvo.emsdriver.commons.ftp/FTPSrv.java.html
deleted file mode 100644
index 2729c76..0000000
--- a/ems/boco/target/site/jacoco-ut/org.onap.vfc.nfvo.emsdriver.commons.ftp/FTPSrv.java.html
+++ /dev/null
@@ -1,200 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>FTPSrv.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">vfc-nfvo-driver-ems-ems-boco</a> &gt; <a href="index.source.html" class="el_package">org.onap.vfc.nfvo.emsdriver.commons.ftp</a> &gt; <span class="el_source">FTPSrv.java</span></div><h1>FTPSrv.java</h1><pre class="source lang-java linenums">/**
- * Copyright 2017 BOCO Corporation. CMCC Technologies Co., Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
- * 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 &quot;AS IS&quot; 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.
- */
-package org.onap.vfc.nfvo.emsdriver.commons.ftp;
-
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.TimeZone;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.net.ftp.FTP;
-import org.apache.commons.net.ftp.FTPClient;
-import org.apache.commons.net.ftp.FTPClientConfig;
-import org.apache.commons.net.ftp.FTPFile;
-import org.apache.commons.net.ftp.FTPReply;
-import org.onap.vfc.nfvo.emsdriver.commons.utils.StringUtil;
-
-
-<span class="nc" id="L33">public class FTPSrv implements FTPInterface{</span>
-<span class="nc" id="L34"> private Log log = LogFactory.getLog(FTPSrv.class);</span>
-<span class="nc" id="L35"> private FTPClient ftpClient = null;</span>
-
-
- /**
- * login FTP
- * @param host
- * @param port
- * @param user
- * @param pwd
- * @param encode
- * @param timeout
- * @throws Exception
- */
- public void login(String host, int port, String user, String pwd, String encode, boolean isPassiveMode,int timeout) throws Exception {
-<span class="nc" id="L49"> ftpClient = new FTPClient();</span>
-
-<span class="nc" id="L51"> FTPClientConfig ftpClientConfig = new FTPClientConfig();</span>
-<span class="nc" id="L52"> ftpClientConfig.setServerTimeZoneId(TimeZone.getDefault().getID());</span>
-<span class="nc" id="L53"> this.ftpClient.setControlEncoding(&quot;GBK&quot;);</span>
-<span class="nc" id="L54"> this.ftpClient.configure(ftpClientConfig);</span>
-// ftpClient.setParserFactory(new ExtendsDefaultFTPFileEntryParserFactory());
-
-<span class="nc bnc" id="L57" title="All 4 branches missed."> if(encode!=null &amp;&amp; encode.length()&gt;0){</span>
-<span class="nc" id="L58"> ftpClient.setControlEncoding(encode);</span>
- }
-
-<span class="nc" id="L61"> ftpClient.connect(host, port);</span>
-<span class="nc" id="L62"> int reply = this.ftpClient.getReplyCode();</span>
-<span class="nc bnc" id="L63" title="All 2 branches missed."> if (!FTPReply.isPositiveCompletion(reply)) {</span>
-<span class="nc" id="L64"> this.ftpClient.disconnect();</span>
-<span class="nc" id="L65"> return ;</span>
- }
-
-<span class="nc bnc" id="L68" title="All 2 branches missed."> if(!ftpClient.login(user, pwd)){</span>
-<span class="nc" id="L69"> throw new Exception(&quot;login[&quot;+host+&quot;],port[&quot;+port+&quot;] fail, please check user and password&quot;);</span>
- }
-<span class="nc bnc" id="L71" title="All 2 branches missed."> if(isPassiveMode){</span>
-<span class="nc" id="L72"> ftpClient.enterLocalPassiveMode();</span>
- }else{
-<span class="nc" id="L74"> ftpClient.enterLocalActiveMode();</span>
- }
-<span class="nc" id="L76"> ftpClient.setFileType(FTP.BINARY_FILE_TYPE);</span>
-<span class="nc" id="L77"> this.ftpClient.setBufferSize(1024 * 2);</span>
-<span class="nc" id="L78"> this.ftpClient.setDataTimeout(3*60 * 1000);</span>
- try{
-<span class="nc" id="L80"> this.ftpClient.setSoTimeout(timeout);</span>
-<span class="nc" id="L81"> }catch(Exception e){</span>
-<span class="nc" id="L82"> e.printStackTrace();</span>
-<span class="nc" id="L83"> }</span>
-<span class="nc" id="L84"> }</span>
-
-
- /**
- * logout
- */
- public void logout(){
-<span class="nc bnc" id="L91" title="All 2 branches missed."> if(ftpClient != null){</span>
- try {
-<span class="nc" id="L93"> ftpClient.logout();</span>
-<span class="nc" id="L94"> ftpClient.disconnect();</span>
-<span class="nc" id="L95"> }catch(Exception e){</span>
-<span class="nc" id="L96"> }</span>
-<span class="nc" id="L97"> ftpClient = null;</span>
- }
-<span class="nc" id="L99"> }</span>
-
-
- public boolean chdir(String dir) {
-<span class="nc" id="L103"> boolean sucess = false;</span>
- try {
-<span class="nc bnc" id="L105" title="All 2 branches missed."> if(ftpClient.changeWorkingDirectory(dir)){</span>
-<span class="nc" id="L106"> sucess = true;</span>
- }else{
-<span class="nc" id="L108"> sucess = false;</span>
- }
-<span class="nc" id="L110"> } catch (IOException e) {</span>
-<span class="nc" id="L111"> log.error(&quot;chdir dir =&quot;+dir+&quot; is error&quot;+StringUtil.getStackTrace(e));</span>
-<span class="nc" id="L112"> sucess = false;</span>
-<span class="nc" id="L113"> }</span>
-
-<span class="nc" id="L115"> return sucess;</span>
- }
-
-
- public boolean downloadFile(String remoteFile, String localFile) {
-<span class="nc" id="L120"> boolean sucess = false;</span>
-<span class="nc" id="L121"> BufferedOutputStream toLfileOutput = null;</span>
- try {
-<span class="nc" id="L123"> toLfileOutput = new BufferedOutputStream(new FileOutputStream(localFile));</span>
-<span class="nc" id="L124"> ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);</span>
-<span class="nc bnc" id="L125" title="All 2 branches missed."> if (ftpClient.retrieveFile(remoteFile, toLfileOutput)){</span>
-<span class="nc" id="L126"> sucess = true;</span>
- }else{
-<span class="nc" id="L128"> sucess = false;</span>
- }
-<span class="nc" id="L130"> } catch (Exception ioe) {</span>
-<span class="nc" id="L131"> sucess = false;</span>
-<span class="nc" id="L132"> log.error(&quot;downloadFile remoteFile =&quot;+remoteFile +&quot; is fail &quot;,ioe);</span>
- } finally {
-<span class="nc bnc" id="L134" title="All 6 branches missed."> if (toLfileOutput != null)</span>
- try {
-<span class="nc" id="L136"> toLfileOutput.close();</span>
-<span class="nc" id="L137"> } catch (IOException e) {</span>
-<span class="nc" id="L138"> }</span>
-<span class="nc" id="L139"> }</span>
-
-<span class="nc" id="L141"> return sucess;</span>
- }
-
-
- public RemoteFile[] list() {
-<span class="nc" id="L146"> AFtpRemoteFile[] ftpRemoteFiles = null;</span>
-<span class="nc" id="L147"> String currdir = null;</span>
- try {
-<span class="nc" id="L149"> currdir = ftpClient.printWorkingDirectory();</span>
-<span class="nc bnc" id="L150" title="All 2 branches missed."> if (currdir.endsWith(&quot;/&quot;) == false) {</span>
-<span class="nc" id="L151"> currdir = currdir + &quot;/&quot;;</span>
- }
-<span class="nc" id="L153"> FTPFile[] rfileList = null;</span>
-<span class="nc" id="L154"> rfileList = ftpClient.listFiles(currdir);</span>
-<span class="nc" id="L155"> ftpRemoteFiles = new AFtpRemoteFile[rfileList.length];</span>
-<span class="nc bnc" id="L156" title="All 2 branches missed."> for (int i=0; i&lt;rfileList.length; i++){</span>
-<span class="nc" id="L157"> ftpRemoteFiles[i] = new AFtpRemoteFile(rfileList[i], ftpClient, currdir);</span>
- }
-<span class="nc" id="L159"> } catch (IOException e) {</span>
-<span class="nc" id="L160"> log.error(&quot;Ftp list currdir = &quot;+currdir+&quot; is fail &quot;+StringUtil.getStackTrace(e));</span>
-<span class="nc" id="L161"> }</span>
-<span class="nc" id="L162"> return ftpRemoteFiles;</span>
- }
-
-
- @Override
- public String pwd() throws IOException {
-<span class="nc" id="L168"> String returnValue = ftpClient.printWorkingDirectory();</span>
-<span class="nc" id="L169"> return returnValue;</span>
- }
-
-// public boolean store(String localFile, String remoteFile) {
-//
-// boolean sucess = false;
-// FileInputStream lfileInput = null;
-// try {
-// lfileInput = new FileInputStream(localFile);
-// ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
-//
-// if (ftpClient.storeFile(remoteFile, lfileInput)){
-// sucess = true;
-// }else{
-// sucess = false;
-// }
-// } catch (Exception ioe) {
-// sucess = false;
-// log.error(&quot;store localFile = &quot;+localFile+&quot; is fail &quot;+StringUtil.getStackTrace(ioe));
-// } finally {
-// if (lfileInput != null)
-// try {
-// lfileInput.close();
-// } catch (IOException e) {
-// }
-// }
-// return sucess;
-// }
-
-}
-
-</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.7.201606060606</span></div></body></html> \ No newline at end of file