コード例 #1
0
ファイル: DBConnect.java プロジェクト: orcacvsmirror/qkan
  /**
   * SQL文の実行を行い、データの取得を行う。<br>
   * 取得したレコードの最初の行の最初の列データを返却する。
   *
   * @param sql 実行するSQL(select)
   * @return 取得データ
   */
  public String execQuerySingle(String sql) throws Exception {
    String result = null;
    try {
      Log.info("--- start execQuerySingle " + sql + " ---");
      if (con == null) {
        Log.warning("Connection is null -- run makeConnection");
        makeConnection();
      }
      Statement stmt = con.createStatement();
      Log.info("createStatement success");

      ResultSet rs = stmt.executeQuery(sql);

      if (rs.next()) {
        result = rs.getString(1);
      }
      Log.info("execQuerySingle " + sql + " success\nreturn data:" + result);

      rs.close();
      stmt.close();

    } catch (Exception e) {
      Log.warning("fail execQuerySingle : " + e.getLocalizedMessage() + "\nSQL : " + sql);
      throw e;
    }
    Log.info("--- end execQuerySingle " + sql + " ---");
    return result;
  }
コード例 #2
0
ファイル: DynmapPlugin.java プロジェクト: CovertHoax/dynmap
 /**
  * ** This is the public API for other plugins to use for accessing the Marker API ** This method
  * can return null if the 'markers' component has not been configured - a warning message will be
  * issued to the server.log in this event.
  *
  * @return MarkerAPI, or null if not configured
  */
 public MarkerAPI getMarkerAPI() {
   if (markerapi == null) {
     Log.warning(
         "Marker API has been requested, but is not enabled.  Uncomment or add 'markers' component to configuration.txt.");
   }
   return markerapi;
 }
コード例 #3
0
ファイル: Xml.java プロジェクト: fxprunayre/core-geonetwork
  /**
   * Transforms an xml tree putting the result to a stream with optional parameters.
   *
   * @param xml
   * @param styleSheetPath
   * @param result
   * @param params
   * @throws Exception
   */
  public static void transform(
      Element xml, String styleSheetPath, Result result, Map<String, String> params)
      throws Exception {
    File styleSheet = new File(styleSheetPath);
    Source srcXml = new JDOMSource(new Document((Element) xml.detach()));
    Source srcSheet = new StreamSource(styleSheet);

    // Dear old saxon likes to yell loudly about each and every XSLT 1.0
    // stylesheet so switch it off but trap any exceptions because this
    // code is run on transformers other than saxon
    TransformerFactory transFact = TransformerFactoryFactory.getTransformerFactory();
    transFact.setURIResolver(new JeevesURIResolver());
    try {
      transFact.setAttribute(FeatureKeys.VERSION_WARNING, false);
      transFact.setAttribute(FeatureKeys.LINE_NUMBERING, true);
      transFact.setAttribute(FeatureKeys.PRE_EVALUATE_DOC_FUNCTION, false);
      transFact.setAttribute(FeatureKeys.RECOVERY_POLICY, Configuration.RECOVER_SILENTLY);
      // Add the following to get timing info on xslt transformations
      // transFact.setAttribute(FeatureKeys.TIMING,true);
    } catch (IllegalArgumentException e) {
      Log.warning(Log.ENGINE, "WARNING: transformerfactory doesnt like saxon attributes!");
      // e.printStackTrace();
    } finally {
      Transformer t = transFact.newTransformer(srcSheet);
      if (params != null) {
        for (Map.Entry<String, String> param : params.entrySet()) {
          t.setParameter(param.getKey(), param.getValue());
        }
      }
      t.transform(srcXml, result);
    }
  }
コード例 #4
0
ファイル: DBConnect.java プロジェクト: orcacvsmirror/qkan
  /** コネクションの生成を行う */
  private void makeConnection() throws Exception {
    try {
      // 設定ファイルからDB接続情報を取得する。
      String server = "localhost";
      String port = "3050";
      String id = "SYSDBA";
      String pass = "******";
      String charSet = "?lc_ctype=SJIS_0208";

      if (doc != null) {
        server = doc.getNodeValue("DBConfig", "Server");
        port = doc.getNodeValue("DBConfig", "Port");
        id = doc.getNodeValue("DBConfig", "UserName");
        pass = doc.getNodeValue("DBConfig", "Password");
      }

      Class.forName("org.firebirdsql.jdbc.FBDriver");
      con =
          DriverManager.getConnection(
              "jdbc:firebirdsql://" + server + ":" + port + "/" + path + charSet, id, pass);
      con.setAutoCommit(false);
    } catch (Exception e) {
      Log.warning("makeConnection Error : " + e.getLocalizedMessage());
      throw e;
    }
  }
コード例 #5
0
ファイル: Enter.java プロジェクト: loverdos/javac-openjdk7
  @Override
  public void visitTopLevel(JCCompilationUnit tree) {
    JavaFileObject prev = log.useSource(tree.sourcefile);
    boolean addEnv = false;
    boolean isPkgInfo =
        tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE);
    if (tree.pid != null) {
      tree.packge = reader.enterPackage(TreeInfo.fullName(tree.pid));
      if (tree.packageAnnotations.nonEmpty() || pkginfoOpt == PkgInfo.ALWAYS) {
        if (isPkgInfo) {
          addEnv = true;
        } else {
          log.error(tree.packageAnnotations.head.pos(), "pkg.annotations.sb.in.package-info.java");
        }
      }
    } else {
      tree.packge = syms.unnamedPackage;
    }
    tree.packge.complete(); // Find all classes in package.
    Env<AttrContext> topEnv = topLevelEnv(tree);

    // Save environment of package-info.java file.
    if (isPkgInfo) {
      Env<AttrContext> env0 = typeEnvs.get(tree.packge);
      if (env0 == null) {
        typeEnvs.put(tree.packge, topEnv);
      } else {
        JCCompilationUnit tree0 = env0.toplevel;
        if (!fileManager.isSameFile(tree.sourcefile, tree0.sourcefile)) {
          log.warning(
              tree.pid != null ? tree.pid.pos() : null, "pkg-info.already.seen", tree.packge);
          if (addEnv
              || (tree0.packageAnnotations.isEmpty()
                  && tree.docComments != null
                  && tree.docComments.get(tree) != null)) {
            typeEnvs.put(tree.packge, topEnv);
          }
        }
      }

      for (Symbol q = tree.packge; q != null && q.kind == PCK; q = q.owner) q.flags_field |= EXISTS;

      Name name = names.package_info;
      ClassSymbol c = reader.enterClass(name, tree.packge);
      c.flatname = names.fromString(tree.packge + "." + name);
      c.sourcefile = tree.sourcefile;
      c.completer = null;
      c.members_field = new Scope(c);
      tree.packge.package_info = c;
    }
    classEnter(tree.defs, topEnv);
    if (addEnv) {
      todo.append(topEnv);
    }
    log.useSource(prev);
    result = null;
  }
コード例 #6
0
 /**
  * Reports a trouble (error or warning).
  *
  * @param trouble a description of the trouble to report.
  */
 public void reportTrouble(PositionedError trouble) {
   if (trouble instanceof CWarning) {
     if (options.warning != 0 && filterWarning((CWarning) trouble)) {
       Log.warning(trouble.getMessage());
     }
   } else {
     Log.error(trouble.getMessage());
     errorFound = true;
   }
 }
コード例 #7
0
ファイル: BundleUtil.java プロジェクト: Tagin/aurora-ide
  public static String getResolvedResourceLocation(
      String resource, Bundle bundle, boolean forceNLResolve) {
    // quick exits.
    if (resource == null) return null;

    if (bundle == null || !bundleHasValidState(bundle)) return resource;

    URL localLocation = null;
    try {
      // we need to resolve this URL.
      String copyResource = resource;
      if (forceNLResolve && !copyResource.startsWith(NL_TAG)) {
        if (copyResource.startsWith("/") // $NON-NLS-1$
            || copyResource.startsWith("\\")) // $NON-NLS-1$
        copyResource = resource.substring(1);
        copyResource = NL_TAG + copyResource;
      }
      IPath resourcePath = new Path(copyResource);
      localLocation = FileLocator.find(bundle, resourcePath, null);
      if (localLocation == null) {
        // localLocation can be null if the passed resource could not
        // be found relative to the plugin. log fact, return resource,
        // as is.
        String msg =
            StringUtil.concat(
                    "Could not find resource: ", //$NON-NLS-1$
                    resource,
                    " in ",
                    getBundleHeader( //$NON-NLS-1$
                        bundle, Constants.BUNDLE_NAME))
                .toString();
        Log.warning(msg);
        return resource;
      }
      /*
      localLocation = FileLocator.toFileURL(localLocation);
      return localLocation.toExternalForm();
      */
      return toExternalForm(localLocation);
    } catch (Exception e) {
      String msg =
          StringUtil.concat(
                  "Failed to load resource: ", //$NON-NLS-1$
                  resource,
                  " from ",
                  getBundleHeader(
                      bundle, //$NON-NLS-1$
                      Constants.BUNDLE_NAME))
              .toString();
      Log.error(msg, e);
      return resource;
    }
  }
コード例 #8
0
ファイル: DBConnect.java プロジェクト: orcacvsmirror/qkan
  /**
   * SQL文の実行を行う
   *
   * @param sql 実行するSQL文
   */
  public void exec(String sql) throws Exception {
    try {
      Log.info("--- start exec " + sql + " ---");
      if (con == null) {
        Log.warning("Connection is null -- run makeConnection");
        makeConnection();
      }
      Statement stmt = con.createStatement();
      Log.info("createStatement success");

      stmt.execute(sql);
      Log.info("exec " + sql + " success");

      stmt.close();

    } catch (Exception e) {
      Log.warning("fail exec : " + e.getLocalizedMessage() + "\nSQL : " + sql);
      throw e;
    }
    Log.info("--- end exec " + sql + " ---");
  }
コード例 #9
0
 private void initUserDefined(String fileName) {
   try {
     load(fileName);
   } catch (IOException e) {
     // file does not exist:
     // write default properties
     try {
       store(fileName);
     } catch (IOException e1) {
       Log.warning(this, "Failed to create configuration file: %s", e1.getMessage());
     }
   }
 }
コード例 #10
0
ファイル: Xml.java プロジェクト: fxprunayre/core-geonetwork
  /**
   * Transform an xml tree to PDF using XSL-FOP     * putting the result to a stream (uses a
   * stylesheet on disk)
   */
  public static String transformFOP(String uploadDir, Element xml, String styleSheetPath)
      throws Exception {
    String file = uploadDir + UUID.randomUUID().toString() + ".pdf";

    // Step 1: Construct a FopFactory
    // (reuse if you plan to render multiple documents!)
    FopFactory fopFactory = FopFactory.newInstance();

    // Step 2: Set up output stream.
    // Note: Using BufferedOutputStream for performance reasons (helpful
    // with FileOutputStreams).
    OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(file)));

    try {
      // Step 3: Construct fop with desired output format
      Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);

      // Step 4: Setup JAXP using identity transformer
      TransformerFactory factory = TransformerFactoryFactory.getTransformerFactory();
      factory.setURIResolver(new JeevesURIResolver());
      Source xslt = new StreamSource(new File(styleSheetPath));
      try {
        factory.setAttribute(FeatureKeys.VERSION_WARNING, false);
        factory.setAttribute(FeatureKeys.LINE_NUMBERING, true);
        factory.setAttribute(FeatureKeys.RECOVERY_POLICY, Configuration.RECOVER_SILENTLY);
      } catch (IllegalArgumentException e) {
        Log.warning(Log.ENGINE, "WARNING: transformerfactory doesnt like saxon attributes!");
        // e.printStackTrace();
      } finally {
        Transformer transformer = factory.newTransformer(xslt);

        // Step 5: Setup input and output for XSLT transformation
        // Setup input stream
        Source src = new JDOMSource(new Document((Element) xml.detach()));

        // Resulting SAX events (the generated FO) must be piped through to
        // FOP
        Result res = new SAXResult(fop.getDefaultHandler());

        // Step 6: Start XSLT transformation and FOP processing
        transformer.transform(src, res);
      }

    } finally {
      // Clean-up
      out.close();
    }

    return file;
  }
コード例 #11
0
ファイル: DBConnect.java プロジェクト: orcacvsmirror/qkan
 /** 現在のトランザクションをコミットする */
 public void commit() {
   Log.info("--- start commit transactin ---");
   if (con != null) {
     try {
       if (!con.isClosed()) {
         con.commit();
         con.close();
       }
     } catch (Exception e) {
       Log.warning("fail commit transaction : " + e.getLocalizedMessage());
     }
     con = null;
   }
   Log.info("--- end commit transactin ---");
 }
コード例 #12
0
ファイル: Options.java プロジェクト: conormcd/exemplar
  /**
   * Check that all of the mandatory options have been set.
   *
   * @return True if all of the mandatory options have been given a value, false otherwise.
   */
  public static boolean allMandatoryOptionsSet() {
    // Ensure that the options stash is created
    init();

    for (String optionName : options.keySet()) {
      if (isMandatory(optionName)) {
        Option<?> opt = get(optionName);
        if (opt == null || opt.getValue() == null || opt.getValue().isEmpty()) {
          Log.warning(Message.MISSING_MANDATORY_OPTION(optionName));
          return false;
        }
      }
    }

    return true;
  }
コード例 #13
0
ファイル: DynmapPlugin.java プロジェクト: CovertHoax/dynmap
  @Override
  public void onEnable() {
    /* Start with clean events */
    events = new Events();

    permissions = NijikokunPermissions.create(getServer(), "dynmap");
    if (permissions == null) permissions = BukkitPermissions.create("dynmap");
    if (permissions == null)
      permissions =
          new OpPermissions(
              new String[] {
                "fullrender", "cancelrender", "radiusrender", "resetstats", "reload", "purgequeue"
              });

    dataDirectory = this.getDataFolder();
    if (dataDirectory.exists() == false) dataDirectory.mkdirs();

    /* Initialize confguration.txt if needed */
    File f = new File(this.getDataFolder(), "configuration.txt");
    if (!createDefaultFileFromResource("/configuration.txt", f)) {
      this.setEnabled(false);
      return;
    }
    /* Load configuration.txt */
    org.bukkit.util.config.Configuration bukkitConfiguration =
        new org.bukkit.util.config.Configuration(f);
    bukkitConfiguration.load();
    configuration = new ConfigurationNode(bukkitConfiguration);

    /* Load block models */
    HDBlockModels.loadModels(dataDirectory, configuration);
    /* Load texture mappings */
    TexturePack.loadTextureMapping(dataDirectory, configuration);

    /* Now, process worlds.txt - merge it in as an override of existing values (since it is only user supplied values) */
    f = new File(this.getDataFolder(), "worlds.txt");
    if (!createDefaultFileFromResource("/worlds.txt", f)) {
      this.setEnabled(false);
      return;
    }
    org.bukkit.util.config.Configuration cfg = new org.bukkit.util.config.Configuration(f);
    cfg.load();
    ConfigurationNode cn = new ConfigurationNode(cfg);
    mergeConfigurationBranch(cn, "worlds", true, true);

    /* Now, process templates */
    loadTemplates();

    Log.verbose = configuration.getBoolean("verbose", true);
    deftemplatesuffix = configuration.getString("deftemplatesuffix", "");
    /* Default swamp shading off for 1.8, on after */
    swampshading =
        configuration.getBoolean("swampshaded", !getServer().getVersion().contains("(MC: 1.8"));
    /* Default water biome shading off for 1.8, on after */
    waterbiomeshading =
        configuration.getBoolean(
            "waterbiomeshaded", !getServer().getVersion().contains("(MC: 1.8"));
    /* Default fence-to-block-join off for 1.8, on after */
    fencejoin =
        configuration.getBoolean(
            "fence-to-block-join", !getServer().getVersion().contains("(MC: 1.8"));
    /* Default compassmode to pre19, to newrose after */
    String cmode =
        configuration.getString(
            "compass-mode", getServer().getVersion().contains("(MC: 1.8") ? "pre19" : "newrose");
    if (cmode.equals("newnorth")) compassmode = CompassMode.NEWNORTH;
    else if (cmode.equals("newrose")) compassmode = CompassMode.NEWROSE;
    else compassmode = CompassMode.PRE19;

    loadDebuggers();

    tilesDirectory = getFile(configuration.getString("tilespath", "web/tiles"));
    if (!tilesDirectory.isDirectory() && !tilesDirectory.mkdirs()) {
      Log.warning("Could not create directory for tiles ('" + tilesDirectory + "').");
    }

    playerList = new PlayerList(getServer(), getFile("hiddenplayers.txt"), configuration);
    playerList.load();
    PlayerListener pl =
        new PlayerListener() {
          public void onPlayerJoin(PlayerJoinEvent evt) {
            playerList.updateOnlinePlayers(null);
          }

          public void onPlayerQuit(PlayerQuitEvent evt) {
            playerList.updateOnlinePlayers(evt.getPlayer());
          }
        };
    registerEvent(Type.PLAYER_JOIN, pl);
    registerEvent(Type.PLAYER_QUIT, pl);

    mapManager = new MapManager(this, configuration);
    mapManager.startRendering();

    playerfacemgr = new PlayerFaces(this);

    loadWebserver();

    enabledTriggers.clear();
    List<String> triggers = configuration.getStrings("render-triggers", new ArrayList<String>());
    if (triggers != null) {
      for (Object trigger : triggers) {
        enabledTriggers.add((String) trigger);
      }
    }

    // Load components.
    for (Component component :
        configuration.<Component>createInstances(
            "components", new Class<?>[] {DynmapPlugin.class}, new Object[] {this})) {
      componentManager.add(component);
    }
    Log.verboseinfo("Loaded " + componentManager.components.size() + " components.");

    registerEvents();

    if (!configuration.getBoolean("disable-webserver", false)) {
      startWebserver();
    }

    /* Print version info */
    PluginDescriptionFile pdfFile = this.getDescription();
    Log.info("version " + pdfFile.getVersion() + " is enabled");

    events.<Object>trigger("initialized", null);
  }
コード例 #14
0
 /**
  * Instantiates a new malformatted datagram.
  *
  * @param message the message
  */
 public MalformattedDatagram(String message) {
   super(message);
   Log.warning(message);
 }