Package railo.commons.io.log

Examples of railo.commons.io.log.LogAndSource


      if(hasVar)Dump.call(pageContext, value, var);
     
    }
   
    // log
    LogAndSource log = pageContext.getConfig().getTraceLogger();
    StringBuffer msg=new StringBuffer();
    msg.append("["+trace.getTime()+" ms "+total+"] ");
    msg.append("["+trace.getTemplate()+" @ line: "+trace.getLine()+"]");
    if(hasCat || hasText || hasVar) msg.append("- ");
    if(hasCat)msg.append("["+trace.getCategory()+"] ");
    if(hasVar)msg.append("["+var+"="+varValue+"] ");
    if(hasText)msg.append(" "+trace.getText()+" ");
    log.log(trace.getType(), "cftrace", msg.toString());
   
    // abort
    if(abort) throw new Abort(Abort.SCOPE_REQUEST);
   
  }
View Full Code Here


  public static Resource getDeployDirectory(Config config) {
    return config.getConfigDir().getRealResource("deploy");
  }

  private static void deployArchive(Config config,Resource archive) throws ZipException, IOException {
    LogAndSource log = ((ConfigImpl)config).getDeployLogger();
    String type=null,virtual=null,name=null;
    boolean readOnly,topLevel,hidden,physicalFirst;
    short inspect;
    InputStream is = null;
    ZipFile file=null;
    try {
    file=new ZipFile(FileWrapper.toFile(archive));
    ZipEntry entry = file.getEntry("META-INF/MANIFEST.MF");
   
    // no manifest
    if(entry==null) {
      log.error("archive","cannot deploy Railo Archive ["+archive+"], file is to old, the file does not have a MANIFEST.");
      moveToFailedFolder(archive);
      return;
    }
   
      is = file.getInputStream(entry);
      Manifest manifest = new Manifest(is);
        Attributes attr = manifest.getMainAttributes();
       
        //id = unwrap(attr.getValue("mapping-id"));
        type = unwrap(attr.getValue("mapping-type"));
        virtual = unwrap(attr.getValue("mapping-virtual-path"));
        name = ListUtil.trim(virtual, "/");
        readOnly = Caster.toBooleanValue(unwrap(attr.getValue("mapping-readonly")),false);
        topLevel = Caster.toBooleanValue(unwrap(attr.getValue("mapping-top-level")),false);
        inspect = ConfigWebUtil.inspectTemplate(unwrap(attr.getValue("mapping-inspect")), ConfigImpl.INSPECT_UNDEFINED);
        if(inspect==ConfigImpl.INSPECT_UNDEFINED) {
          Boolean trusted = Caster.toBoolean(unwrap(attr.getValue("mapping-trusted")),null);
          if(trusted!=null) {
            if(trusted.booleanValue()) inspect=ConfigImpl.INSPECT_NEVER;
            else inspect=ConfigImpl.INSPECT_ALWAYS;
         
        }
        hidden = Caster.toBooleanValue(unwrap(attr.getValue("mapping-hidden")),false);
        physicalFirst = Caster.toBooleanValue(unwrap(attr.getValue("mapping-physical-first")),false);
    }
    finally{
      IOUtil.closeEL(is);
      ZipUtil.close(file);
    }
    Resource trgDir = config.getConfigDir().getRealResource("archives").getRealResource(type).getRealResource(name);
    Resource trgFile = trgDir.getRealResource(archive.getName());
    trgDir.mkdirs();
   
    // delete existing files
   
    try {
      ResourceUtil.deleteContent(trgDir, null);
      ResourceUtil.moveTo(archive, trgFile,true);
     
      log.info("archive","add "+type+" mapping ["+virtual+"] with archive ["+trgFile.getAbsolutePath()+"]");
      if("regular".equalsIgnoreCase(type))
        ConfigWebAdmin.updateMapping((ConfigImpl)config,virtual, null, trgFile.getAbsolutePath(), "archive", inspect, topLevel);
      else if("cfc".equalsIgnoreCase(type))
        ConfigWebAdmin.updateComponentMapping((ConfigImpl)config,virtual, null, trgFile.getAbsolutePath(), "archive", inspect);
      else if("ct".equalsIgnoreCase(type))
        ConfigWebAdmin.updateCustomTagMapping((ConfigImpl)config,virtual, null, trgFile.getAbsolutePath(), "archive", inspect);
     
       
    }
    catch (Throwable t) {
      moveToFailedFolder(archive);
      log.error("archive",ExceptionUtil.getStacktrace(t, true));
    }
  }
View Full Code Here

  private static void deployExtension(Config config, Resource ext) {
    ConfigImpl ci = (ConfigImpl)config;
    boolean isWeb=config instanceof ConfigWeb;
    String type=isWeb?"web":"server";
    LogAndSource log = ((ConfigImpl)config).getDeployLogger();
   
    // Manifest
    Manifest manifest = null;
    ZipInputStream zis=null;
        try {
          zis = new ZipInputStream( IOUtil.toBufferedInputStream(ext.getInputStream()) ) ;    
          ZipEntry entry;
          String name;
          while ( ( entry = zis.getNextEntry()) != null ) {
            name=entry.getName();
            if(!entry.isDirectory() && name.equalsIgnoreCase("META-INF/MANIFEST.MF")) {
              manifest = toManifest(config,zis,null);
            }
              zis.closeEntry() ;
          }
        }
        catch(Throwable t){
          log.error("extension", ExceptionUtil.getStacktrace(t, true));
      moveToFailedFolder(ext);
      return;
        }
        finally {
          IOUtil.closeEL(zis);
        }
       
        int minCoreVersion=0;
        double minLoaderVersion=0;
        String strMinCoreVersion="",strMinLoaderVersion="",version=null,name=null,id=null;
       
        if(manifest!=null) {
          Attributes attr = manifest.getMainAttributes();
          // version
          version=unwrap(attr.getValue("version"));


          // id
          id=unwrap(attr.getValue("id"));
         
          // name
          name=unwrap(attr.getValue("name"));

          // core version
          strMinCoreVersion=unwrap(attr.getValue("railo-core-version"));
          minCoreVersion=Info.toIntVersion(strMinCoreVersion,minCoreVersion);
         
          // loader version
          strMinLoaderVersion=unwrap(attr.getValue("railo-loader-version"));
          minLoaderVersion=Caster.toDoubleValue(strMinLoaderVersion,minLoaderVersion);
         
        }
        if(StringUtil.isEmpty(name,true)) {
          name=ext.getName();
          int index=name.lastIndexOf('.');
          name=name.substring(0,index-1);
        }
        name=name.trim();
       
       
        // check core version
    if(minCoreVersion>Info.getVersionAsInt()) {
      log.error("extension", "cannot deploy Railo Extension ["+ext+"], Railo Version must be at least ["+strMinCoreVersion+"].");
      moveToFailedFolder(ext);
      return;
    }

    // check loader version
    if(minLoaderVersion>SystemUtil.getLoaderVersion()) {
      log.error("extension", "cannot deploy Railo Extension ["+ext+"], Railo Loader Version must be at least ["+strMinLoaderVersion+"], update the railo.jar first.");
      moveToFailedFolder(ext);
      return;
    }
    // check id
    if(!Decision.isUUId(id)) {
      log.error("extension", "cannot deploy Railo Extension ["+ext+"], this Extension has no valid id ["+id+"],id must be a valid UUID.");
      moveToFailedFolder(ext);
      return;
    }
   
   
   
   
    Resource trgFile=null;
    try{
      ConfigWebAdmin.removeRHExtension(ci,id);
     
      Resource trgDir = config.getConfigDir().getRealResource("extensions").getRealResource(type).getRealResource(name);
      trgFile = trgDir.getRealResource(ext.getName());
      trgDir.mkdirs();
      ResourceUtil.moveTo(ext, trgFile,true);
    }
      catch(Throwable t){
        log.error("extension", ExceptionUtil.getStacktrace(t, true));
      moveToFailedFolder(ext);
      return;
      }
     
    try {
          zis = new ZipInputStream( IOUtil.toBufferedInputStream(trgFile.getInputStream()) ) ;    
          ZipEntry entry;
          String path;
          String fileName;
          List<String> jars=new ArrayList<String>(), flds=new ArrayList<String>(), tlds=new ArrayList<String>(), contexts=new ArrayList<String>(), applications=new ArrayList<String>();
          while ( ( entry = zis.getNextEntry()) != null ) {
            path=entry.getName();
            fileName=fileName(entry);
            // jars
            if(!entry.isDirectory() && (startsWith(path,type,"jars") || startsWith(path,type,"jar") || startsWith(path,type,"lib") || startsWith(path,type,"libs")) && StringUtil.endsWithIgnoreCase(path, ".jar")) {
              log.info("extension","deploy jar "+fileName);
              ConfigWebAdmin.updateJar(config,zis,fileName,false);
              jars.add(fileName);
            }
           
            // flds
            if(!entry.isDirectory() && startsWith(path,type,"flds") && StringUtil.endsWithIgnoreCase(path, ".fld")) {
              log.info("extension","deploy fld "+fileName);
              ConfigWebAdmin.updateFLD(config, zis, fileName,false);
              flds.add(fileName);
            }
           
            // tlds
            if(!entry.isDirectory() && startsWith(path,type,"tlds") && StringUtil.endsWithIgnoreCase(path, ".tld")) {
              log.info("extension","deploy tld "+fileName);
              ConfigWebAdmin.updateTLD(config, zis, fileName,false);
              tlds.add(fileName);
            }
           
            // context
            String realpath;
            if(!entry.isDirectory() && startsWith(path,type,"context") && !StringUtil.startsWith(fileName(entry), '.')) {
              realpath=path.substring(8);
              //log.info("extension","deploy context "+realpath);
              log.info("extension","deploy context "+realpath);
              ConfigWebAdmin.updateContext(ci, zis, realpath,false);
              contexts.add(realpath);
            }
           
            // applications
            if(!entry.isDirectory() && startsWith(path,type,"applications") && !StringUtil.startsWith(fileName(entry), '.')) {
              realpath=path.substring(13);
              //log.info("extension","deploy context "+realpath);
              log.info("extension","deploy application "+realpath);
              ConfigWebAdmin.updateApplication(ci, zis, realpath,false);
              applications.add(realpath);
            }
           
           
              zis.closeEntry() ;
          }
         
          //installation successfull
         
          ConfigWebAdmin.updateRHExtension(ci,
              new RHExtension(id,name,version,
              jars.toArray(new String[jars.size()]),
              flds.toArray(new String[flds.size()]),
              tlds.toArray(new String[tlds.size()]),
              contexts.toArray(new String[contexts.size()]),
              applications.toArray(new String[applications.size()])));
         
        }
      catch(Throwable t){
        // installation failed
       
        log.error("extension",ExceptionUtil.getStacktrace(t, true));
      moveToFailedFolder(trgFile);
      return;
      }
        finally {
          IOUtil.closeEL(zis);
View Full Code Here

    catch (Throwable t) {
      if(!Abort.isSilentAbort(t)) {
        ConfigWeb c = pc.getConfig();
        if(c instanceof ConfigImpl) {
          ConfigImpl ci=(ConfigImpl) c;
          LogAndSource log = ci.getThreadLogger();
          if(log!=null)log.error(this.getName(), ExceptionUtil.getStacktrace(t,true));
        }
        PageException pe = Caster.toPageException(t);
        if(!serializable)catchBlock=pe.getCatchBlock(pc);
        return pe;
      }
View Full Code Here

    String strLogger = el.getAttribute("log");
    int logLevel = LogUtil.toIntType(el.getAttribute("log-level"), Log.LEVEL_ERROR);
    if (StringUtil.isEmpty(strLogger)) {
      if (configServer != null) {
        LogAndSource log = configServer.getMailLogger();
        strLogger = log.getSource();
        logLevel = log.getLogLevel();
      }
      else
        strLogger = "{railo-config}/logs/mapping.log";
    }
View Full Code Here

    // Log
    String strLogger = el.getAttribute("log");
    int logLevel = LogUtil.toIntType(el.getAttribute("log-level"), Log.LEVEL_ERROR);
    if (StringUtil.isEmpty(strLogger)) {
      if (configServer != null) {
        LogAndSource log = configServer.getRestLogger();
        strLogger = log.getSource();
        logLevel = log.getLogLevel();
      }
      else
        strLogger = "{railo-config}/logs/rest.log";
    }
    config.setRestLogger(ConfigWebUtil.getLogAndSource(configServer, config, strLogger, true, logLevel));
View Full Code Here

    if(maxThreads<1)maxThreads=20;
   
    // Logger
    String strLogger = hasAccess ? _clients.getAttribute("log") : null;
    int logLevel = LogUtil.toIntType(_clients.getAttribute("log-level"), Log.LEVEL_ERROR);
    LogAndSource log = ConfigWebUtil.getLogAndSource(configServer, config, strLogger, true, logLevel);
    config.setRemoteClientLog(log);

    // directory
    Resource file = ConfigWebUtil.getFile(config.getRootDirectory(), _clients.getAttribute("directory"), "client-task", config.getConfigDir(), FileUtil.TYPE_DIR, config);
    config.setRemoteClientDirectory(file);
View Full Code Here

    try {
      // Logger
      String strLogger = search.getAttribute("log");
      int logLevel = LogUtil.toIntType(search.getAttribute("log-level"), Log.LEVEL_ERROR);
      LogAndSource log = ConfigWebUtil.getLogAndSource(configServer, config, strLogger, true, logLevel);

      // Init
      se.init(config, ConfigWebUtil.getFile(configDir, ConfigWebUtil.translateOldPath(search.getAttribute("directory")), "search", configDir, FileUtil.TYPE_DIR, config), log);
    }
    catch (Exception e) {
View Full Code Here

    Element scheduler = getChildByName(doc.getDocumentElement(), "scheduler");

    // Logger
    String strLogger = scheduler.getAttribute("log");
    int logLevel = LogUtil.toIntType(scheduler.getAttribute("log-level"), Log.LEVEL_INFO);
    LogAndSource log = ConfigWebUtil.getLogAndSource(configServer, config, strLogger, true, logLevel);

    // set scheduler
    Resource file = ConfigWebUtil.getFile(config.getRootDirectory(), scheduler.getAttribute("directory"), "scheduler", configDir, FileUtil.TYPE_DIR, config);
    config.setScheduler(configServer.getCFMLEngine(), file, log);
  }
View Full Code Here

    long start=System.nanoTime();
    long _timeout = getTimeout(config);
    try {

          Proxy.start(proxyData);
    LogAndSource log = config.getMailLogger();
    // Server
        Server[] servers = config.getMailServers();
        if(host!=null) {
          int prt;
          String usr,pwd;
View Full Code Here

TOP

Related Classes of railo.commons.io.log.LogAndSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.