Coverage Report - org.jtheque.films.services.impl.PublicationService
 
Classes in this File Line Coverage Branch Coverage Complexity
PublicationService
0 %
0/15
0 %
0/2
2
 
 1  
 package org.jtheque.films.services.impl;
 2  
 
 3  
 import org.jtheque.core.managers.Managers;
 4  
 import org.jtheque.core.managers.view.able.IViewManager;
 5  
 import org.jtheque.core.utils.Response;
 6  
 import org.jtheque.core.utils.SystemProperty;
 7  
 import org.jtheque.films.persistence.od.able.Film;
 8  
 import org.jtheque.films.services.able.IFilmsService;
 9  
 import org.jtheque.films.services.able.IPublicationService;
 10  
 import org.jtheque.films.services.impl.utils.file.FTPConnectionInfos;
 11  
 import org.jtheque.films.services.impl.utils.file.FTPManager;
 12  
 import org.jtheque.films.services.impl.utils.file.exports.Exporter;
 13  
 import org.jtheque.films.services.impl.utils.file.exports.ExporterFactory;
 14  
 import org.jtheque.films.utils.Constants;
 15  
 
 16  
 import javax.annotation.Resource;
 17  
 
 18  
 /*
 19  
  * This file is part of JTheque.
 20  
  *
 21  
  * JTheque is free software: you can redistribute it and/or modify
 22  
  * it under the terms of the GNU General Public License as published by
 23  
  * the Free Software Foundation, either version 3 of the License.
 24  
  *
 25  
  * JTheque is distributed in the hope that it will be useful,
 26  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 27  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 28  
  * GNU General Public License for more details.
 29  
  *
 30  
  * You should have received a copy of the GNU General Public License
 31  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 32  
  */
 33  
 
 34  
 /**
 35  
  * @author Baptiste Wicht
 36  
  */
 37  0
 public final class PublicationService implements IPublicationService {
 38  
     @Resource
 39  
     private IFilmsService filmsService;
 40  
 
 41  
     @Override
 42  
     public void uploadListOfFilms(FTPConnectionInfos infos) {
 43  0
         String local = SystemProperty.JAVA_IO_TMP_DIR.get() + "/index.html";
 44  
 
 45  0
         Exporter<Film> exporter = ExporterFactory.getExporter(Constants.Files.FileType.HTML);
 46  
 
 47  0
         exporter.setDatas(filmsService.getFilms());
 48  
 
 49  0
         exporter.export(local);
 50  
 
 51  0
         String remote = infos.getPath() + "index.html";
 52  
 
 53  0
         FTPManager ftp = new FTPManager(infos);
 54  
 
 55  0
         Response connection = ftp.connect();
 56  
 
 57  0
         if (connection.isOk()) {
 58  0
             Response store = ftp.upload(local, remote);
 59  
 
 60  0
             Managers.getManager(IViewManager.class).displayText(store.getMessage());
 61  0
         } else {
 62  0
             Managers.getManager(IViewManager.class).displayText(connection.getMessage());
 63  
         }
 64  
 
 65  0
         ftp.disconnect();
 66  0
     }
 67  
 }