Exemplo n.º 1
0
  /**
   * This private worker method attempts to find [java_home]/lib/tools.jar. Note: The tools.jar is a
   * part of the SDK, it is not present in the JRE.
   *
   * @return If tools.jar can be found, a File representing tools.jar. <br>
   *     If tools.jar cannot be found, null.
   */
  private static Resource findToolsJar(Config config, Log log, RefBoolean useOurOwn) {
    log.info("Instrumentation", "looking for tools.jar");
    String javaHome = System.getProperty("java.home");
    Resource javaHomeFile = ResourcesImpl.getFileResourceProvider().getResource(javaHome);

    Resource toolsJarFile = javaHomeFile.getRealResource("lib" + File.separator + "tools.jar");
    if (toolsJarFile.exists()) {
      useOurOwn.setValue(false);
      return toolsJarFile;
    }
    log.info("Instrumentation", "couldn't find tools.jar at: " + toolsJarFile.getAbsolutePath());

    // If we're on an IBM SDK, then remove /jre off of java.home and try again.
    if (javaHomeFile.getAbsolutePath().endsWith(SEP + "jre")) {
      javaHomeFile = javaHomeFile.getParentResource();
      toolsJarFile = javaHomeFile.getRealResource("lib" + SEP + "tools.jar");
      if (!toolsJarFile.exists()) {
        log.info("Instrumentation", "for IBM SDK couldn't find " + toolsJarFile.getAbsolutePath());
      } else {
        useOurOwn.setValue(false);
        return toolsJarFile;
      }
    } else if (System.getProperty("os.name").toLowerCase().indexOf("mac") >= 0) {
      // If we're on a Mac, then change the search path to use ../Classes/classes.jar.
      if (javaHomeFile.getAbsolutePath().endsWith(SEP + "Home")) {
        javaHomeFile = javaHomeFile.getParentResource();
        toolsJarFile = javaHomeFile.getRealResource("Classes" + SEP + "classes.jar");
        if (!toolsJarFile.exists()) {
          log.info("Instrumentation", "for Mac OS couldn't find " + toolsJarFile.getAbsolutePath());
        } else {
          useOurOwn.setValue(false);
          return toolsJarFile;
        }
      }
    }

    // if the engine could not find the tools.jar it is using it's own version
    try {
      toolsJarFile = createToolsJar(config);
    } catch (IOException e) {
      log.error("Instrumentation", e);
    }

    if (!toolsJarFile.exists()) {
      log.info("Instrumentation", "could not be created " + toolsJarFile.getAbsolutePath());
      return null;
    }
    log.info("Instrumentation", "found " + toolsJarFile.getAbsolutePath());
    return toolsJarFile;
  }
Exemplo n.º 2
0
  private void checkOldClientFile(ConfigWeb config) {
    ExtensionResourceFilter filter = new ExtensionResourceFilter(".script", false);

    // move old structured file in new structure
    try {
      Resource dir = config.getClientScopeDir(), trgres;
      Resource[] children = dir.listResources(filter);
      String src, trg;
      int index;
      for (int i = 0; i < children.length; i++) {
        src = children[i].getName();
        index = src.indexOf('-');

        trg =
            StorageScopeFile.getFolderName(
                src.substring(0, index), src.substring(index + 1), false);
        trgres = dir.getRealResource(trg);
        if (!trgres.exists()) {
          trgres.createFile(true);
          ResourceUtil.copy(children[i], trgres);
        }
        // children[i].moveTo(trgres);
        children[i].delete();
      }
    } catch (Throwable t) {
    }
  }
Exemplo n.º 3
0
  /** @throws PageException */
  private void doUpdate() throws PageException {
    String message = "missing attribute for tag schedule with action update";
    String detail = "required attributes are [startDate, startTime, URL, interval, operation]";

    Resource file = null;
    // if(publish) {
    if (!StringUtil.isEmpty(strFile) && !StringUtil.isEmpty(strPath)) {
      file = ResourceUtil.toResourceNotExisting(pageContext, strPath);
      file = file.getRealResource(strFile);
    } else if (!StringUtil.isEmpty(strFile)) {
      file = ResourceUtil.toResourceNotExisting(pageContext, strFile);
    } else if (!StringUtil.isEmpty(strPath)) {
      file = ResourceUtil.toResourceNotExisting(pageContext, strPath);
    }
    if (file != null)
      pageContext
          .getConfig()
          .getSecurityManager()
          .checkFileLocation(pageContext.getConfig(), file, serverPassword);

    // missing attributes
    if (startdate == null || starttime == null || url == null || interval == null)
      throw new ApplicationException(message, detail);

    // timeout
    if (requesttimeout < 0) requesttimeout = pageContext.getRequestTimeout();

    // username/password
    Credentials cr = null;
    if (username != null) cr = CredentialsImpl.toCredentials(username, password);

    try {

      ScheduleTask st =
          new ScheduleTaskImpl(
              task,
              file,
              startdate,
              starttime,
              enddate,
              endtime,
              url,
              port,
              interval,
              requesttimeout,
              cr,
              ProxyDataImpl.getInstance(proxyserver, proxyport, proxyuser, proxypassword),
              resolveurl,
              publish,
              hidden,
              readonly,
              paused,
              autoDelete);
      scheduler.addScheduleTask(st, true);
    } catch (Exception e) {
      throw Caster.toPageException(e);
    }

    //
  }
Exemplo n.º 4
0
 private static Resource getBinDirectory(Config config) {
   Resource dir = ConfigWebUtil.getConfigServerDirectory(config);
   if (dir == null || !dir.isWriteable() || !dir.isReadable())
     dir =
         ResourceUtil.toResource(
             CFMLEngineFactory.getClassLoaderRoot(SystemUtil.getLoaderClassLoader()));
   else {
     dir = dir.getRealResource("bin");
     if (!dir.exists()) dir.mkdir();
   }
   return dir;
 }
Exemplo n.º 5
0
  private static void addAttachIfNecessary(Config config, Log log) {

    String srcName = null, trgName = null;
    String archBits = (SystemUtil.getJREArch() == SystemUtil.ARCH_64) ? "64" : "32";

    // Windows
    if (SystemUtil.isWindows()) {
      trgName = "attach.dll";
      srcName = "windows" + archBits + "/" + trgName;
    }
    // Linux
    else if (SystemUtil.isLinux()) {
      trgName = "libattach.so";
      srcName = "linux" + archBits + "/" + trgName;
    }
    // Solaris
    else if (SystemUtil.isSolaris()) {
      trgName = "libattach.so";
      srcName = "solaris" + archBits + "/" + trgName;
    }
    // Mac OSX
    else if (SystemUtil.isMacOSX()) {
      trgName = "libattach.dylib";
      srcName = "macosx" + archBits + "/" + trgName;
    }

    if (srcName != null) {

      // create dll if necessary
      Resource binDir = getBinDirectory(config);
      Resource trg = binDir.getRealResource(trgName);
      if (!trg.exists() || trg.length() == 0) {
        log.info("Instrumentation", "deploy /resource/bin/" + srcName + " to " + trg);
        InputStream src = InfoImpl.class.getResourceAsStream("/resource/bin/" + srcName);
        try {
          IOUtil.copy(src, trg, true);
        } catch (IOException e) {
          log.log(Log.LEVEL_ERROR, "Instrumentation", e);
        }
      }

      // set directory to library path
      SystemUtil.addLibraryPathIfNoExist(binDir, log);
    }
  }
Exemplo n.º 6
0
  private static Resource createToolsJar(Config config) throws IOException {
    Resource dir = getDeployDirectory(config);

    String os = "bsd"; // used for Mac OS X
    if (SystemUtil.isWindows()) {
      os = "windows";
    } else if (SystemUtil.isLinux()) { // not MacOSX
      os = "linux";
    } else if (SystemUtil.isSolaris()) {
      os = "solaris";
    }
    String name = "tools-" + os + "-" + TOOLS_VERSION + ".jar";
    Resource trg = dir.getRealResource(name);

    if (!trg.exists() || trg.length() == 0) {

      InputStream jar = InfoImpl.class.getResourceAsStream("/resource/lib/" + name);
      IOUtil.copy(jar, trg, true);
    }
    return trg;
  }
  @Override
  public void init(lucee.runtime.config.Config config, Resource searchDir)
      throws IOException, SearchException {
    this.config = config;
    this.searchDir = searchDir;
    this.searchFile = searchDir.getRealResource("search.xml");
    if (!searchFile.exists() || searchFile.length() == 0) createSearchFile(searchFile);

    DOMParser parser = new DOMParser();
    InputStream is = null;
    try {
      is = engine.getIOUtil().toBufferedInputStream(searchFile.getInputStream());
      InputSource source = new InputSource(is);
      parser.parse(source);
    } catch (SAXException e) {
      throw new SearchException(e);
    } finally {
      engine.getIOUtil().closeSilent(is);
    }
    doc = parser.getDocument();

    readCollections(config);
  }