Search in sources :

Example 21 with Resource

use of lucee.commons.io.res.Resource in project Lucee by lucee.

the class TaskFileFilter method createId.

private String createId(SpoolerTask task) {
    Resource dir = getPersisDirectory().getRealResource(task.closed() ? "closed" : "open");
    dir.mkdirs();
    String id = null;
    do {
        id = StringUtil.addZeros(++count, 8);
    } while (dir.getRealResource(id + ".tsk").exists());
    return id;
}
Also used : Resource(lucee.commons.io.res.Resource)

Example 22 with Resource

use of lucee.commons.io.res.Resource in project Lucee by lucee.

the class TaskFileFilter method store.

private void store(SpoolerTask task) {
    ObjectOutputStream oos = null;
    Resource persis = getFile(task);
    if (persis.exists())
        persis.delete();
    try {
        oos = new ObjectOutputStream(persis.getOutputStream());
        oos.writeObject(task);
    } catch (IOException e) {
        SystemOut.printDate(e);
    } finally {
        IOUtil.closeEL(oos);
    }
}
Also used : Resource(lucee.commons.io.res.Resource) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream)

Example 23 with Resource

use of lucee.commons.io.res.Resource in project Lucee by lucee.

the class Admin method getSSLCertificate.

public static Query getSSLCertificate(Config config, String host, int port) throws PageException {
    Resource cacerts = config.getSecurityDirectory();
    CertificateInstaller installer;
    try {
        installer = new CertificateInstaller(cacerts, host, port);
    } catch (Exception e) {
        throw Caster.toPageException(e);
    }
    X509Certificate[] certs = installer.getCertificates();
    X509Certificate cert;
    Query qry = new QueryImpl(new String[] { "subject", "issuer" }, certs.length, "certificates");
    for (int i = 0; i < certs.length; i++) {
        cert = certs[i];
        qry.setAtEL("subject", i + 1, cert.getSubjectDN().getName());
        qry.setAtEL("issuer", i + 1, cert.getIssuerDN().getName());
    }
    return qry;
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Query(lucee.runtime.type.Query) Resource(lucee.commons.io.res.Resource) PageException(lucee.runtime.exp.PageException) SecurityException(lucee.runtime.exp.SecurityException) IOException(java.io.IOException) DeprecatedException(lucee.runtime.exp.DeprecatedException) BundleException(org.osgi.framework.BundleException) MalformedURLException(java.net.MalformedURLException) SMTPException(lucee.runtime.net.mail.SMTPException) ApplicationException(lucee.runtime.exp.ApplicationException) X509Certificate(java.security.cert.X509Certificate) CertificateInstaller(lucee.runtime.net.http.CertificateInstaller)

Example 24 with Resource

use of lucee.commons.io.res.Resource in project Lucee by lucee.

the class Admin method doReadBundle.

private void doReadBundle() throws PageException {
    String ret = getString("admin", action, "returnvariable");
    Resource res = ResourceUtil.toResourceExisting(pageContext, getString("admin", action, "bundle"));
    if (!res.isFile())
        throw new ApplicationException("[" + res + "] is not a file");
    try {
        Struct sct = new StructImpl();
        pageContext.setVariable(ret, new BundleFile(res).info());
    } catch (Exception e) {
        throw Caster.toPageException(e);
    }
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) StructImpl(lucee.runtime.type.StructImpl) Resource(lucee.commons.io.res.Resource) BundleFile(lucee.runtime.osgi.BundleFile) PageException(lucee.runtime.exp.PageException) SecurityException(lucee.runtime.exp.SecurityException) IOException(java.io.IOException) DeprecatedException(lucee.runtime.exp.DeprecatedException) BundleException(org.osgi.framework.BundleException) MalformedURLException(java.net.MalformedURLException) SMTPException(lucee.runtime.net.mail.SMTPException) ApplicationException(lucee.runtime.exp.ApplicationException) Struct(lucee.runtime.type.Struct)

Example 25 with Resource

use of lucee.commons.io.res.Resource in project Lucee by lucee.

the class Admin method doHeapDump.

private void doHeapDump() throws PageException {
    String strDestination = getString("admin", action, "destination");
    boolean live = getBoolV("live", true);
    Resource destination = ResourceUtil.toResourceNotExisting(pageContext, strDestination);
    try {
        HeapDumper.dumpTo(destination, live);
    } catch (IOException e) {
        throw Caster.toPageException(e);
    }
}
Also used : Resource(lucee.commons.io.res.Resource) IOException(java.io.IOException)

Aggregations

Resource (lucee.commons.io.res.Resource)309 IOException (java.io.IOException)100 ApplicationException (lucee.runtime.exp.ApplicationException)54 PageException (lucee.runtime.exp.PageException)40 ArrayList (java.util.ArrayList)31 Struct (lucee.runtime.type.Struct)28 ByteArrayInputStream (java.io.ByteArrayInputStream)21 InputStream (java.io.InputStream)21 ExpressionException (lucee.runtime.exp.ExpressionException)19 StructImpl (lucee.runtime.type.StructImpl)18 MalformedURLException (java.net.MalformedURLException)17 PageContextImpl (lucee.runtime.PageContextImpl)17 PageSource (lucee.runtime.PageSource)16 FileResource (lucee.commons.io.res.type.file.FileResource)15 SecurityException (lucee.runtime.exp.SecurityException)15 BundleException (org.osgi.framework.BundleException)15 ZipEntry (java.util.zip.ZipEntry)13 ExtensionResourceFilter (lucee.commons.io.res.filter.ExtensionResourceFilter)13 Array (lucee.runtime.type.Array)13 File (java.io.File)12