Search in sources :

Example 21 with DateTimeImpl

use of lucee.runtime.type.dt.DateTimeImpl in project Lucee by lucee.

the class Cache method doStartTag.

@Override
public int doStartTag() throws PageException {
    now = new DateTimeImpl(pageContext.getConfig());
    if (action == CACHE && hasBody)
        action = CONTENT;
    try {
        if (action == CACHE) {
            doClientCache();
            doServerCache();
        } else if (action == CACHE_CLIENT)
            doClientCache();
        else if (action == CACHE_SERVER)
            doServerCache();
        else if (action == FLUSH)
            doFlush();
        else if (action == CONTENT)
            return doContentCache();
        else if (action == GET)
            doGet();
        else if (action == PUT)
            doPut();
        return EVAL_PAGE;
    } catch (Exception e) {
        throw Caster.toPageException(e);
    }
}
Also used : DateTimeImpl(lucee.runtime.type.dt.DateTimeImpl) DeprecatedException(lucee.runtime.exp.DeprecatedException) PageException(lucee.runtime.exp.PageException) IOException(java.io.IOException) ExpressionException(lucee.runtime.exp.ExpressionException) ApplicationException(lucee.runtime.exp.ApplicationException) TemplateException(lucee.runtime.exp.TemplateException)

Example 22 with DateTimeImpl

use of lucee.runtime.type.dt.DateTimeImpl in project Lucee by lucee.

the class FileTag method getInfo.

public static Struct getInfo(PageContext pc, Resource file, String serverPassword) throws PageException {
    SecurityManager sm = pc.getConfig().getSecurityManager();
    checkFile(pc, sm, file, serverPassword, false, false, false, false);
    Struct sct = new StructImpl();
    // fill data to query
    sct.setEL(KeyConstants._name, file.getName());
    sct.setEL(KeyConstants._size, Long.valueOf(file.length()));
    sct.setEL(KeyConstants._type, file.isDirectory() ? "Dir" : "File");
    sct.setEL("dateLastModified", new DateTimeImpl(pc, file.lastModified(), false));
    sct.setEL("attributes", getFileAttribute(file));
    if (SystemUtil.isUnix())
        sct.setEL(KeyConstants._mode, new ModeObjectWrap(file));
    try {
        sct.setEL(KeyConstants._checksum, Hash.md5(file));
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
    }
    try {
        BufferedImage bi = ImageUtil.toBufferedImage(file, null);
        if (bi != null) {
            Struct img = new StructImpl();
            img.setEL(KeyConstants._width, new Double(bi.getWidth()));
            img.setEL(KeyConstants._height, new Double(bi.getHeight()));
            sct.setEL(KeyConstants._img, img);
        }
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
    }
    return sct;
}
Also used : ModeObjectWrap(lucee.commons.io.res.util.ModeObjectWrap) StructImpl(lucee.runtime.type.StructImpl) SecurityManager(lucee.runtime.security.SecurityManager) DateTimeImpl(lucee.runtime.type.dt.DateTimeImpl) BufferedImage(java.awt.image.BufferedImage) Struct(lucee.runtime.type.Struct)

Example 23 with DateTimeImpl

use of lucee.runtime.type.dt.DateTimeImpl in project Lucee by lucee.

the class ServerImpl method reload.

public void reload(PageContext pc, Boolean jsr223) {
    Info info = pc.getConfig().getFactory().getEngine().getInfo();
    ReadOnlyStruct coldfusion = new ReadOnlyStruct();
    coldfusion.setEL(PRODUCT_LEVEL, info.getLevel());
    // coldfusion.setEL(PRODUCT_VERSION,"11,0,07,296330");
    coldfusion.setEL(PRODUCT_VERSION, "2016,0,03,300357");
    coldfusion.setEL(SERIAL_NUMBER, "0");
    coldfusion.setEL(PRODUCT_NAME, "Lucee");
    // TODO scope server missing values
    // Jrun
    coldfusion.setEL(KeyConstants._appserver, "");
    // 
    coldfusion.setEL(EXPIRATION, expired);
    // 
    coldfusion.setEL(INSTALL_KIT, "");
    String rootdir = "";
    try {
        rootdir = ThreadLocalPageContext.getConfig(pc).getRootDirectory().getAbsolutePath();
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
    }
    // 
    coldfusion.setEL(ROOT_DIR, rootdir);
    // 
    coldfusion.setEL(SUPPORTED_LOCALES, LocaleFactory.getLocaleList());
    coldfusion.setReadOnly(true);
    super.setEL(KeyConstants._coldfusion, coldfusion);
    ReadOnlyStruct os = new ReadOnlyStruct();
    os.setEL(KeyConstants._name, System.getProperty("os.name"));
    os.setEL(ARCH, System.getProperty("os.arch"));
    os.setEL(MAC_ADDRESS, SystemUtil.getMacAddressAsWrap());
    int arch = SystemUtil.getOSArch();
    if (arch != SystemUtil.ARCH_UNKNOW)
        os.setEL(ARCH_MODEL, new Double(arch));
    os.setEL(KeyConstants._version, System.getProperty("os.version"));
    os.setEL(ADDITIONAL_INFORMATION, "");
    os.setEL(BUILD_NUMBER, "");
    os.setEL(HOST_NAME, SystemUtil.getLocalHostName());
    os.setReadOnly(true);
    super.setEL(KeyConstants._os, os);
    ReadOnlyStruct lucee = new ReadOnlyStruct();
    lucee.setEL(KeyConstants._version, info.getVersion().toString());
    lucee.setEL(VERSION_NAME, info.getVersionName());
    lucee.setEL(VERSION_NAME_EXPLANATION, info.getVersionNameExplanation());
    lucee.setEL(KeyConstants._state, getStateAsString(info.getVersion()));
    lucee.setEL(RELEASE_DATE, new DateTimeImpl(info.getRealeaseTime(), false));
    lucee.setEL(LOADER_VERSION, Caster.toDouble(SystemUtil.getLoaderVersion()));
    lucee.setEL(LOADER_PATH, ClassUtil.getSourcePathForClass("lucee.loader.servlet.CFMLServlet", ""));
    lucee.setEL(ENVIRONMENT, jsr223 != null && jsr223.booleanValue() ? "jsr223" : "servlet");
    lucee.setReadOnly(true);
    super.setEL(KeyConstants._lucee, lucee);
    ReadOnlyStruct separator = new ReadOnlyStruct();
    separator.setEL(KeyConstants._path, System.getProperty("path.separator"));
    separator.setEL(KeyConstants._file, System.getProperty("file.separator"));
    separator.setEL(KeyConstants._line, System.getProperty("line.separator"));
    separator.setReadOnly(true);
    super.setEL(KeyConstants._separator, separator);
    ReadOnlyStruct java = new ReadOnlyStruct();
    java.setEL(KeyConstants._version, System.getProperty("java.version"));
    java.setEL(VENDOR, System.getProperty("java.vendor"));
    arch = SystemUtil.getJREArch();
    if (arch != SystemUtil.ARCH_UNKNOW)
        java.setEL(ARCH_MODEL, new Double(arch));
    Runtime rt = Runtime.getRuntime();
    java.setEL(FREE_MEMORY, new Double(rt.freeMemory()));
    java.setEL(TOTAL_MEMORY, new Double(rt.totalMemory()));
    java.setEL(MAX_MEMORY, new Double(rt.maxMemory()));
    java.setEL(JAVA_AGENT_SUPPORTED, Boolean.TRUE);
    if (jep == null) {
        String temp = System.getProperty("user.dir", "");
        if (!StringUtil.isEmpty(temp) && !temp.endsWith(File.separator))
            temp = temp + File.separator;
        jep = temp;
    }
    java.setEL(JAVA_EXECUTION_PATH, jep);
    java.setReadOnly(true);
    super.setEL(KeyConstants._java, java);
    ReadOnlyStruct servlet = new ReadOnlyStruct();
    String name = "";
    try {
        name = pc.getServletContext().getServerInfo();
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
    }
    servlet.setEL(KeyConstants._name, name);
    servlet.setReadOnly(true);
    super.setEL(KeyConstants._servlet, servlet);
    ReadOnlyStruct system = new ReadOnlyStruct();
    system.setEL(KeyConstants._properties, SystemPropStruct.getInstance());
    system.setEL(KeyConstants._environment, EnvStruct.getInstance());
    system.setReadOnly(true);
    super.setEL(KeyConstants._system, system);
}
Also used : ReadOnlyStruct(lucee.runtime.type.ReadOnlyStruct) DateTimeImpl(lucee.runtime.type.dt.DateTimeImpl) Info(lucee.Info)

Example 24 with DateTimeImpl

use of lucee.runtime.type.dt.DateTimeImpl in project Lucee by lucee.

the class IKStorageScopeSupport method touchBeforeRequest.

@Override
public void touchBeforeRequest(PageContext pc) {
    hasChanges = false;
    setTimeSpan(pc);
    // lastvisit=System.currentTimeMillis();
    if (data == null)
        data = new ConcurrentHashMapPro<Collection.Key, IKStorageScopeItem>();
    data.put(KeyConstants._cfid, new IKStorageScopeItem(pc.getCFID()));
    data.put(KeyConstants._cftoken, new IKStorageScopeItem(pc.getCFToken()));
    data.put(URLTOKEN, new IKStorageScopeItem(pc.getURLToken()));
    data.put(LASTVISIT, new IKStorageScopeItem(_lastvisit));
    _lastvisit = new DateTimeImpl(pc.getConfig());
    lastvisit = System.currentTimeMillis();
    if (type == SCOPE_CLIENT) {
        data.put(HITCOUNT, new IKStorageScopeItem(new Double(hitcount++)));
    } else {
        data.put(SESSION_ID, new IKStorageScopeItem(pc.getApplicationContext().getName() + "_" + pc.getCFID() + "_" + pc.getCFToken()));
    }
    data.put(TIMECREATED, new IKStorageScopeItem(timecreated));
}
Also used : Collection(lucee.runtime.type.Collection) DateTimeImpl(lucee.runtime.type.dt.DateTimeImpl) ConcurrentHashMapPro(lucee.commons.collection.concurrent.ConcurrentHashMapPro)

Example 25 with DateTimeImpl

use of lucee.runtime.type.dt.DateTimeImpl in project Lucee by lucee.

the class StorageScopeImpl method touch.

@Override
public void touch() {
    lastvisit = System.currentTimeMillis();
    _lastvisit = new DateTimeImpl(ThreadLocalPageContext.getConfig());
}
Also used : DateTimeImpl(lucee.runtime.type.dt.DateTimeImpl)

Aggregations

DateTimeImpl (lucee.runtime.type.dt.DateTimeImpl)41 Struct (lucee.runtime.type.Struct)12 StructImpl (lucee.runtime.type.StructImpl)11 Date (java.util.Date)7 PageException (lucee.runtime.exp.PageException)6 Calendar (java.util.Calendar)5 Resource (lucee.commons.io.res.Resource)5 Collection (lucee.runtime.type.Collection)5 QueryImpl (lucee.runtime.type.QueryImpl)5 IOException (java.io.IOException)4 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)4 TimeZone (java.util.TimeZone)3 PageContextImpl (lucee.runtime.PageContextImpl)3 ExpressionException (lucee.runtime.exp.ExpressionException)3 Array (lucee.runtime.type.Array)3 ArrayImpl (lucee.runtime.type.ArrayImpl)3 DateTime (lucee.runtime.type.dt.DateTime)3 File (java.io.File)2 Method (java.lang.reflect.Method)2 DateFormat (java.text.DateFormat)2