Rev 1782 | Rev 1800 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1782 | Rev 1798 | ||
---|---|---|---|
Line 12... | Line 12... | ||
12 | import pt.estgp.estgweb.domain.*; |
12 | import pt.estgp.estgweb.domain.*; |
13 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
13 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
14 | import pt.estgp.estgweb.domain.dao.impl.CourseUnitDaoImpl; |
14 | import pt.estgp.estgweb.domain.dao.impl.CourseUnitDaoImpl; |
15 | import pt.estgp.estgweb.domain.views.CourseUnitProgramView; |
15 | import pt.estgp.estgweb.domain.views.CourseUnitProgramView; |
16 | import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum; |
16 | import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum; |
- | 17 | import pt.estgp.estgweb.services.data.IRepositoryFile; |
|
17 | import pt.estgp.estgweb.services.data.RepositoryService; |
18 | import pt.estgp.estgweb.services.data.RepositoryService; |
18 | import pt.estgp.estgweb.services.expceptions.ServiceException; |
19 | import pt.estgp.estgweb.services.expceptions.ServiceException; |
19 | import pt.estgp.estgweb.utils.DatesUtils; |
20 | import pt.estgp.estgweb.utils.DatesUtils; |
20 | import pt.estgp.estgweb.utils.Dom4jUtil; |
21 | import pt.estgp.estgweb.utils.Dom4jUtil; |
21 | import pt.estgp.estgweb.utils.StringsUtils; |
22 | import pt.estgp.estgweb.utils.StringsUtils; |
22 | import pt.estgp.estgweb.web.FtpServer; |
23 | import pt.estgp.estgweb.web.FtpServer; |
23 | import pt.utl.ist.berserk.logic.serviceManager.IService; |
24 | import pt.utl.ist.berserk.logic.serviceManager.IService; |
24 | 25 | ||
25 | import javax.xml.transform.TransformerException; |
26 | import javax.xml.transform.TransformerException; |
26 | import javax.xml.transform.dom.DOMSource; |
27 | import javax.xml.transform.dom.DOMSource; |
27 | import java.io.File; |
28 | import java.io.*; |
28 | import java.io.FileInputStream; |
- | |
29 | import java.io.FileOutputStream; |
- | |
30 | import java.io.IOException; |
- | |
31 | import java.text.SimpleDateFormat; |
29 | import java.text.SimpleDateFormat; |
32 | import java.util.*; |
30 | import java.util.*; |
33 | 31 | ||
34 | /* |
32 | /* |
35 | * @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt |
33 | * @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt |
Line 169... | Line 167... | ||
169 | RepositoryFileImpl repoFile = repositoryService.loadView(cu.getProgramStreamId()); |
167 | RepositoryFileImpl repoFile = repositoryService.loadView(cu.getProgramStreamId()); |
170 | sendPdfFtpIonline(cu,errors,u,path,repoFile.getLastVersion().getSaveDate(),null,warns); |
168 | sendPdfFtpIonline(cu,errors,u,path,repoFile.getLastVersion().getSaveDate(),null,warns); |
171 | } |
169 | } |
172 | 170 | ||
173 | 171 | ||
- | 172 | public void sendPdfIonlineOnly(CourseUnit cu, List<String> errors,UserSession u,List<String> warns) throws 1.5.0/docs/api/java/io/IOException.html">IOException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, FOPException { |
|
- | 173 | ||
- | 174 | ||
- | 175 | IRepositoryFile repoFileLastVersion = repositoryService.load(cu.getProgramStreamId(), null); |
|
- | 176 | ||
- | 177 | FTPClient nullClient = null; |
|
- | 178 | sendPdfFtpIonline(cu, errors, u, repoFileLastVersion.getInput(), repoFileLastVersion.getSaveDate(), nullClient, warns); |
|
- | 179 | } |
|
- | 180 | ||
- | 181 | ||
174 | public boolean sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u, FTPClient client, List<String> warns) throws 1.5.0/docs/api/java/io/IOException.html">IOException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, FOPException |
182 | public boolean sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u, FTPClient client, List<String> warns) throws 1.5.0/docs/api/java/io/IOException.html">IOException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, FOPException |
175 | { |
183 | { |
176 | RepositoryService repositoryService = new RepositoryService(); |
184 | RepositoryService repositoryService = new RepositoryService(); |
177 | if(cu.getProgramStreamId() != null && cu.getProgramStreamId().length()> 0) |
185 | if(cu.getProgramStreamId() != null && cu.getProgramStreamId().length()> 0) |
178 | { |
186 | { |
Line 184... | Line 192... | ||
184 | return false; |
192 | return false; |
185 | } |
193 | } |
186 | 194 | ||
187 | 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat sdf = new 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat("yyyy_MM_dd.HH_mm_ss"); |
195 | 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat sdf = new 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat("yyyy_MM_dd.HH_mm_ss"); |
188 | 196 | ||
189 | private void sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u,1.5.0/docs/api/java/lang/String.html">String pdfPath,5+0%2Fdocs%2Fapi+Date">Date versionDate,FTPClient client,List<String> warnings) throws 1.5.0/docs/api/java/io/IOException.html">IOException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, FOPException { |
197 | private void sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u,5+0%2Fdocs%2Fapi+InputStream">InputStream pdfPath,5+0%2Fdocs%2Fapi+Date">Date versionDate,FTPClient client,List<String> warnings) throws 1.5.0/docs/api/java/io/IOException.html">IOException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, FOPException { |
190 | 198 | ||
191 | if(Globals.TEST_ENVIRONEMENT) |
199 | if(Globals.TEST_ENVIRONEMENT) |
192 | { |
200 | { |
193 | 1.5.0/docs/api/java/lang/String.html">String warn = "System in TEST Environement - will NOT send file to ionline test.control.var.DontSendIonlineFiles = true"; |
201 | 1.5.0/docs/api/java/lang/String.html">String warn = "System in TEST Environement - will NOT send file to ionline test.control.var.DontSendIonlineFiles = true"; |
194 | if(warnings != null) |
202 | if(warnings != null) |
Line 216... | Line 224... | ||
216 | { |
224 | { |
217 | logger.error("FTP CANT CHANGE TO PATH: " + pastaFichaCurricular); |
225 | logger.error("FTP CANT CHANGE TO PATH: " + pastaFichaCurricular); |
218 | } |
226 | } |
219 | else |
227 | else |
220 | { |
228 | { |
221 | if(!client.storeFile(cu.getCode() + "_" + cu.getNormalizedName() + "_v" + sdf.format(versionDate) + ".pdf",new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(pdfPath))) |
229 | if(!client.storeFile(cu.getCode() + "_" + cu.getNormalizedName() + "_v" + sdf.format(versionDate) + ".pdf",pdfPath)) |
222 | { |
230 | { |
223 | errors.add("CANT store file in given time, probably timeout at " + Globals.FTP_DATA_STORE_TIMEOUT_SECONDS); |
231 | errors.add("CANT store file in given time, probably timeout at " + Globals.FTP_DATA_STORE_TIMEOUT_SECONDS); |
224 | } |
232 | } |
225 | 233 | ||
226 | if(server != null) |
234 | if(server != null) |
Line 230... | Line 238... | ||
230 | } |
238 | } |
231 | } |
239 | } |
232 | // |
240 | // |
233 | } |
241 | } |
234 | 242 | ||
- | 243 | private void sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u,1.5.0/docs/api/java/lang/String.html">String pdfPath,5+0%2Fdocs%2Fapi+Date">Date versionDate,FTPClient client,List<String> warnings) throws 1.5.0/docs/api/java/io/IOException.html">IOException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, FOPException { |
|
- | 244 | ||
- | 245 | sendPdfFtpIonline(cu,errors,u,new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(pdfPath),versionDate,client,warnings); |
|
- | 246 | // |
|
- | 247 | } |
|
- | 248 | ||
235 | private 1.5.0/docs/api/java/lang/String.html">String generatePdfFile(CourseUnit cu, List<String> errors, UserSession u) throws 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, 1.5.0/docs/api/java/io/IOException.html">IOException, FOPException { |
249 | private 1.5.0/docs/api/java/lang/String.html">String generatePdfFile(CourseUnit cu, List<String> errors, UserSession u) throws 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, 1.5.0/docs/api/java/io/IOException.html">IOException, FOPException { |
236 | 250 | ||
237 | CourseUnitProgramImpl cProgram = (CourseUnitProgramImpl) DaoFactory.getCourseUnitProgramDaoImpl().narrow(cu.getCourseUnitProgram()); |
251 | CourseUnitProgramImpl cProgram = (CourseUnitProgramImpl) DaoFactory.getCourseUnitProgramDaoImpl().narrow(cu.getCourseUnitProgram()); |
238 | cProgram.consistNullValues(); |
252 | cProgram.consistNullValues(); |
239 | 253 | ||
Line 467... | Line 481... | ||
467 | logger.error(e,e); |
481 | logger.error(e,e); |
468 | } catch (1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException e) { |
482 | } catch (1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException e) { |
469 | logger.error(e, e); |
483 | logger.error(e, e); |
470 | } catch (FOPException e) { |
484 | } catch (FOPException e) { |
471 | e.printStackTrace(); |
485 | e.printStackTrace(); |
- | 486 | }catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) { |
|
- | 487 | e.printStackTrace(); |
|
472 | } |
488 | } |
473 | 489 | ||
474 | AbstractDao.getCurrentSession().evict(next); |
490 | AbstractDao.getCurrentSession().evict(next); |
475 | } |
491 | } |
476 | client.quit(); |
492 | client.quit(); |