Search in sources :

Example 6 with FileStorage

use of org.olat.core.util.vfs.FileStorage in project openolat by klemens.

the class CertificatesManagerImpl method afterPropertiesSet.

@Override
public void afterPropertiesSet() {
    // create the folders
    getCertificateTemplatesRoot();
    templatesStorage = new FileStorage(getCertificateTemplatesRootContainer());
    getCertificateRoot();
    usersStorage = new FileStorage(getCertificateRootContainer());
    Properties p = null;
    try {
        velocityEngine = new VelocityEngine();
        p = new Properties();
        p.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.SimpleLog4JLogSystem");
        p.setProperty("runtime.log.logsystem.log4j.category", "syslog");
        velocityEngine.init(p);
    } catch (Exception e) {
        throw new RuntimeException("config error " + p.toString());
    }
    // deploy script
    try (InputStream inRasteriez = CertificatesManager.class.getResourceAsStream("rasterize.js")) {
        Path rasterizePath = getRasterizePath();
        Files.copy(inRasteriez, rasterizePath, StandardCopyOption.REPLACE_EXISTING);
    } catch (Exception e) {
        log.error("Can not read rasterize.js library for PhantomJS PDF generation", e);
    }
    try (InputStream inQRCodeLib = CertificatesManager.class.getResourceAsStream("qrcode.min.js")) {
        Path qrCodeLibPath = getQRCodeLibPath();
        Files.copy(inQRCodeLib, qrCodeLibPath, StandardCopyOption.REPLACE_EXISTING);
    } catch (Exception e) {
        log.error("Can not read qrcode.min.js for QR Code PDF generation", e);
    }
    // start the queues
    try {
        startQueue();
    } catch (JMSException e) {
        log.error("", e);
    }
}
Also used : Path(java.nio.file.Path) VelocityEngine(org.apache.velocity.app.VelocityEngine) InputStream(java.io.InputStream) FileStorage(org.olat.core.util.vfs.FileStorage) JMSException(javax.jms.JMSException) Properties(java.util.Properties) CorruptedCourseException(org.olat.course.CorruptedCourseException) IOException(java.io.IOException) JMSException(javax.jms.JMSException)

Aggregations

FileStorage (org.olat.core.util.vfs.FileStorage)6 IOException (java.io.IOException)4 Properties (java.util.Properties)4 VelocityEngine (org.apache.velocity.app.VelocityEngine)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 FileNotFoundException (java.io.FileNotFoundException)2 InputStream (java.io.InputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Path (java.nio.file.Path)2 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)2 PostConstruct (javax.annotation.PostConstruct)2 JMSException (javax.jms.JMSException)2 MessagingException (javax.mail.MessagingException)2 SendFailedException (javax.mail.SendFailedException)2 AddressException (javax.mail.internet.AddressException)2 MethodInvocationException (org.apache.velocity.exception.MethodInvocationException)2 ParseErrorException (org.apache.velocity.exception.ParseErrorException)2 ResourceNotFoundException (org.apache.velocity.exception.ResourceNotFoundException)2 PublisherData (org.olat.core.commons.services.notifications.PublisherData)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2