Subversion Repositories bacoAlunos

Compare Revisions

Ignore whitespace Rev 1797 → Rev 1798

/branches/v3/impl/src/java/pt/estgp/estgweb/services/courseunits/SaveCourseUnitProgram.java
14,6 → 14,7
import pt.estgp.estgweb.domain.dao.impl.CourseUnitDaoImpl;
import pt.estgp.estgweb.domain.views.CourseUnitProgramView;
import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum;
import pt.estgp.estgweb.services.data.IRepositoryFile;
import pt.estgp.estgweb.services.data.RepositoryService;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.utils.DatesUtils;
24,10 → 25,7
 
import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMSource;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
 
171,6 → 169,16
}
 
 
public void sendPdfIonlineOnly(CourseUnit cu, List<String> errors,UserSession u,List<String> warns) throws IOException, TransformerException, FOPException {
 
 
IRepositoryFile repoFileLastVersion = repositoryService.load(cu.getProgramStreamId(), null);
 
FTPClient nullClient = null;
sendPdfFtpIonline(cu, errors, u, repoFileLastVersion.getInput(), repoFileLastVersion.getSaveDate(), nullClient, warns);
}
 
 
public boolean sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u, FTPClient client, List<String> warns) throws IOException, TransformerException, FOPException
{
RepositoryService repositoryService = new RepositoryService();
186,7 → 194,7
 
SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd.HH_mm_ss");
 
private void sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u,String pdfPath,Date versionDate,FTPClient client,List<String> warnings) throws IOException, TransformerException, FOPException {
private void sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u,InputStream pdfPath,Date versionDate,FTPClient client,List<String> warnings) throws IOException, TransformerException, FOPException {
 
if(Globals.TEST_ENVIRONEMENT)
{
218,7 → 226,7
}
else
{
if(!client.storeFile(cu.getCode() + "_" + cu.getNormalizedName() + "_v" + sdf.format(versionDate) + ".pdf",new FileInputStream(pdfPath)))
if(!client.storeFile(cu.getCode() + "_" + cu.getNormalizedName() + "_v" + sdf.format(versionDate) + ".pdf",pdfPath))
{
errors.add("CANT store file in given time, probably timeout at " + Globals.FTP_DATA_STORE_TIMEOUT_SECONDS);
}
232,6 → 240,12
//
}
 
private void sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u,String pdfPath,Date versionDate,FTPClient client,List<String> warnings) throws IOException, TransformerException, FOPException {
 
sendPdfFtpIonline(cu,errors,u,new FileInputStream(pdfPath),versionDate,client,warnings);
//
}
 
private String generatePdfFile(CourseUnit cu, List<String> errors, UserSession u) throws TransformerException, IOException, FOPException {
 
CourseUnitProgramImpl cProgram = (CourseUnitProgramImpl) DaoFactory.getCourseUnitProgramDaoImpl().narrow(cu.getCourseUnitProgram());
469,6 → 483,8
logger.error(e, e);
} catch (FOPException e) {
e.printStackTrace();
}catch (Throwable e) {
e.printStackTrace();
}
 
AbstractDao.getCurrentSession().evict(next);