Example #1
0
 protected boolean onChar(KeyboardEvent event) {
   if (noContent()) return true;
   final int count = model.getItemCount();
   final char c = event.getChar();
   final String beginning;
   if (selected() != null) {
     if (hotPointX >= appearance.getObservableRightBound(selected())) return false;
     final String name = getObservableSubstr(selected());
     final int pos =
         Math.min(hotPointX - appearance.getObservableLeftBound(selected()), name.length());
     if (pos < 0) return false;
     beginning = name.substring(0, pos);
   } else beginning = "";
   Log.debug("list", "beginning:" + beginning);
   final String mustBegin = beginning + c;
   for (int i = 0; i < count; ++i) {
     Log.debug("list", "checking:" + i);
     final String name = getObservableSubstr(model.getItem(i));
     Log.debug("list", "name:" + name);
     if (!name.startsWith(mustBegin)) continue;
     hotPointY = getLineIndexByItemIndex(i);
     Log.debug("list", "hotPointY:" + hotPointY);
     ++hotPointX;
     appearance.announceItem(model.getItem(hotPointY), NONE_APPEARANCE_FLAGS);
     environment.onAreaNewHotPoint(this);
     return true;
   }
   return false;
 }
  /**
   * Scan all output dirs for artifacts and remove those files (artifacts?) that are not recognized
   * as such, in the javac_state file.
   */
  public void removeUnidentifiedArtifacts() {
    Set<File> allKnownArtifacts = new HashSet<>();
    for (Package pkg : prev.packages().values()) {
      for (File f : pkg.artifacts().values()) {
        allKnownArtifacts.add(f);
      }
    }
    // Do not forget about javac_state....
    allKnownArtifacts.add(javacState);

    for (File f : binArtifacts) {
      if (!allKnownArtifacts.contains(f)) {
        Log.debug("Removing " + f.getPath() + " since it is unknown to the javac_state.");
        f.delete();
      }
    }
    for (File f : headerArtifacts) {
      if (!allKnownArtifacts.contains(f)) {
        Log.debug("Removing " + f.getPath() + " since it is unknown to the javac_state.");
        f.delete();
      }
    }
    for (File f : gensrcArtifacts) {
      if (!allKnownArtifacts.contains(f)) {
        Log.debug("Removing " + f.getPath() + " since it is unknown to the javac_state.");
        f.delete();
      }
    }
  }
  /** Populate the state object, if needed, concerning paging */
  protected void initState(SessionState state, VelocityPortlet portlet, JetspeedRunData rundata) {
    super.initState(state, portlet, rundata);

    if (state.getAttribute(STATE_PAGESIZE) == null) {
      state.setAttribute(STATE_PAGESIZE, new Integer(DEFAULT_PAGE_SIZE));
      PortletConfig config = portlet.getPortletConfig();

      try {
        Integer size = new Integer(config.getInitParameter(PARAM_PAGESIZE));
        if (size.intValue() <= 0) {
          size = new Integer(DEFAULT_PAGE_SIZE);
          if (Log.getLogger("chef").isDebugEnabled())
            Log.debug(
                "chef",
                this
                    + ".initState: size parameter invalid: "
                    + config.getInitParameter(PARAM_PAGESIZE));
        }
        state.setAttribute(STATE_PAGESIZE, size);
      } catch (Exception any) {
        if (Log.getLogger("chef").isDebugEnabled())
          Log.debug("chef", this + ".initState: size parameter invalid: " + any.toString());
        state.setAttribute(STATE_PAGESIZE, new Integer(DEFAULT_PAGE_SIZE));
      }
    }
  } // initState
  @Override
  public void jobRemoved(BlockPlacerJobEntry arg0) {

    Log.debug(
        "Job Removed : ID : "
            + arg0.getJobId()
            + " -- Name : "
            + arg0.getName()
            + " -- Status String : "
            + arg0.getStatusString());
    if (fpRegistry.get(arg0.getJobId()) != null) { // This job is for us! :D
      InstanceData i = fpRegistry.get(arg0.getJobId());
      arg0.removeStateChangedListener((IJobEntryListener) this);
      Log.debug(
          "Job Removed for Instance '"
              + i.name
              + "' -- ID : "
              + arg0.getJobId()
              + " -- Name : "
              + arg0.getName()
              + " -- Status String : "
              + arg0.getStatusString());
    } else { // sadness, someone elses job.
      Log.debug("Not for me?");
    }
  }
  /*
   IE that can be sent:
   - 8.6.1.   CALLED NUMBER
   - 8.6.2.   CALLING NUMBER
   - 8.6.3.   CALLING ANI
   - 8.6.4.   CALLING NAME
   - 8.6.5.   CALLED CONTEXT
   - 8.6.6.   USERNAME
   - 8.6.8.   CAPABILITY
   - 8.6.9.   FORMAT
   - 8.6.10.  LANGUAGE
   - 8.6.11.  VERSION (MUST, and should be first)
   - 8.6.12.  ADSICPE
   - 8.6.13.  DNID
   - 8.6.25.  AUTOANSWER
   - 8.6.31.  DATETIME
   - 8.6.38.  CALLINGPRES
   - 8.6.39.  CALLINGTON
   - 8.6.43.  ENCRYPTION
   - 8.6.45.  CODEC PREFS
  */
  public void sendNew(
      Character cno, String username, String calledNo, String callingNo, String callingName) {

    Log.debug(
        "ProtocolControlFrameNew.sendNew: calledNo="
            + calledNo
            + ", callingNo="
            + callingNo
            + ", callingName="
            + callingName
            + ", username="
            + username);
    _sCall = cno.charValue();
    _iseq = _call.getIseq();
    _oseq = _call.getOseqInc();

    InfoElement ie = new InfoElement();
    ie.calledNo = calledNo;
    ie.callingNo = callingNo;
    ie.callingName = callingName;
    ie.username = username;
    AudioInterface a = _call.getAudioFace();
    int format = a.supportedCodecs().intValue();
    ie.format = new Integer(format);
    ie.version = new Integer(2);
    ie.codec_prefs = a.codecPrefString().getBytes();
    //       ie.putIaxVar("foobar","724024");
    Log.debug("Sending initial NEW");
    sendMe(ie);
  }
  @Override
  public void jobAdded(BlockPlacerJobEntry arg0) {
    for (BlockPlacerJobEntry e : je) {
      if (e == arg0) {
        Log.debug("MATCHED JOB ENTRY!");
      }
    }

    Log.debug(
        "Job Added : ID : "
            + arg0.getJobId()
            + " -- Name : "
            + arg0.getName()
            + " -- Status String : "
            + arg0.getStatusString());
    if (fpRegistry.get(arg0.getJobId()) != null) { // This job is for us! :D
      InstanceData i = fpRegistry.get(arg0.getJobId());
      Log.debug(
          "Job Added for Instance '"
              + i.name
              + "' -- ID : "
              + arg0.getJobId()
              + " -- Name : "
              + arg0.getName()
              + " -- Status String : "
              + arg0.getStatusString());
      arg0.addStateChangedListener((IJobEntryListener) this);
    } else { // Else - ignore, not one of ours!
      Log.debug("Not for me?");
    }
  }
  public void pasteClipboard(InstanceData i, Vector where) {
    Log.debug("AsyncManager.pasteClipboard");
    DungeonData d = i.getDungeon();

    AsyncEditSession es =
        (AsyncEditSession) this.ess.getEditSession(InstancedDungeon.getIDungeonDim(), 999999999);
    // esRegistry.put(p, es);
    String p = es.getPlayer();
    Log.debug("Player is : " + p);
    es.setAsyncForced(true);
    es.setFastMode(true);

    AsyncCuboidClipboard cc = new AsyncCuboidClipboard(p, d.getSchematic());

    int id = bp.getJobId(p);
    id = id + 1;
    Log.debug("Job ID is reported as : " + id);
    fpRegistry.put(id, i);
    je.add(bp.getJob(p, id));
    this.bp.addListener((IBlockPlacerListener) this);
    cc.setOffset(new Vector(0, 0, 0));

    try {
      Log.debug("Doing Paste.");
      cc.paste(es, where, true);
      Log.debug("Post Paste.");

    } catch (MaxChangedBlocksException e) {
      e.printStackTrace();
    }
  }
 public JilterStatus eom(JilterEOMActions eomActions, Properties properties) {
   logger.debug("jilter eom()");
   try {
     bos.close(); // close stream
   } catch (IOException io) {
     logger.error("jilter failed to close io stream during eom", io);
   }
   byte[] messageBytes = bos.toByteArray();
   bos = new ByteArrayOutputStream();
   ByteArrayInputStream bis = new ByteArrayInputStream(messageBytes);
   try {
     logger.debug("jilter store callback execute");
     Config.getStopBlockFactory()
         .detectBlock("milter server", Thread.currentThread(), this, IDLE_TIMEOUT);
     callback.store(bis, host);
     logger.debug("jilter store callback finished");
   } catch (ArchiveException e) {
     logger.error("failed to store the message via milter", e);
     if (e.getRecoveryDirective() == ArchiveException.RecoveryDirective.REJECT) {
       logger.debug("jilter reject");
       return JilterStatus.SMFIS_REJECT;
     } else if (e.getRecoveryDirective() == ArchiveException.RecoveryDirective.RETRYLATER) {
       logger.debug("jilter temp fail");
       return JilterStatus.SMFIS_TEMPFAIL;
     }
   } catch (Throwable oome) {
     logger.error("failed to store message:" + oome.getMessage(), oome);
     return JilterStatus.SMFIS_REJECT;
   } finally {
     Config.getStopBlockFactory().endDetectBlock(Thread.currentThread());
   }
   return JilterStatus.SMFIS_CONTINUE;
 }
Example #9
0
    /**
     * @param href
     * @param base
     * @return
     * @throws TransformerException
     */
    public Source resolve(String href, String base) throws TransformerException {
      Resolver resolver = ResolverWrapper.getInstance();
      CatalogResolver catResolver = resolver.getCatalogResolver();
      if (Log.isDebugEnabled(Log.XML_RESOLVER)) {
        Log.debug(Log.XML_RESOLVER, "Trying to resolve " + href + ":" + base);
      }
      String decodedBase;
      try {
        decodedBase = URLDecoder.decode(base, Jeeves.ENCODING);
      } catch (UnsupportedEncodingException e1) {
        decodedBase = base;
      }
      String decodedHref;
      try {
        decodedHref = URLDecoder.decode(href, Jeeves.ENCODING);
      } catch (UnsupportedEncodingException e1) {
        decodedHref = href;
      }
      Source s = catResolver.resolve(decodedHref, decodedBase);
      // If resolver has a blank XSL file to replace non existing resolved file ...
      String blankXSLFile = resolver.getBlankXSLFile();
      if (blankXSLFile != null && s.getSystemId().endsWith(".xsl")) {
        // The resolved resource does not exist, set it to blank file path to not trigger
        // FileNotFound Exception
        try {
          if (Log.isDebugEnabled(Log.XML_RESOLVER)) {
            Log.debug(Log.XML_RESOLVER, "  Check if exist " + s.getSystemId());
          }
          File f;
          if (SystemUtils.IS_OS_WINDOWS) {
            String path = s.getSystemId();
            // fxp
            path = path.replaceAll("file:\\/", "");
            // heikki
            path = path.replaceAll("file:", "");

            f = new File(path);
          } else {
            f = new File(new URI(s.getSystemId()));
          }
          if (!(f.exists())) {
            if (Log.isDebugEnabled(Log.XML_RESOLVER)) {
              Log.debug(
                  Log.XML_RESOLVER,
                  "  Resolved resource "
                      + s.getSystemId()
                      + " does not exist. blankXSLFile returned instead.");
            }
            s.setSystemId(blankXSLFile);
          }
        } catch (URISyntaxException e) {
          e.printStackTrace();
        }
      }

      if (Log.isDebugEnabled(Log.XML_RESOLVER) && s != null) {
        Log.debug(Log.XML_RESOLVER, "Resolved as " + s.getSystemId());
      }
      return s;
    }
 public void handleUpdateWorldNode(long oid, WorldManagerClient.UpdateWorldNodeMessage wnodeMsg) {
   PerceiverData perceiverData = perceiverDataMap.get(oid);
   if (perceiverData == null) {
     if (Log.loggingDebug)
       Log.debug(
           "ProximityTracker.handleMessage: ignoring updateWNMsg for oid "
               + oid
               + " because PerceptionData for oid not found");
     return;
   }
   BasicWorldNode bwnode = wnodeMsg.getWorldNode();
   if (Log.loggingDebug)
     Log.debug(
         "ProximityTracker.handleMessage: UpdateWnode for "
             + oid
             + ", loc "
             + bwnode.getLoc()
             + ", dir "
             + bwnode.getDir());
   if (perceiverData.wnode != null) {
     perceiverData.previousLoc = perceiverData.lastLoc;
     perceiverData.wnode.setDirLocOrient(bwnode);
     perceiverData.wnode.setInstanceOid(bwnode.getInstanceOid());
     perceiverData.lastLoc = perceiverData.wnode.getLoc();
   } else
     Log.error(
         "ProximityTracker.handleMessage: In UpdateWorldNodeMessage for oid "
             + oid
             + ", perceiverData.wnode is null!");
   updateEntity(perceiverData);
 }
Example #11
0
    public Writable call(Class<?> protocol, Writable param, long receivedTime) throws IOException {
      try {
        Invocation call = (Invocation) param;
        if (verbose) log("Call: " + call);

        Method method = protocol.getMethod(call.getMethodName(), call.getParameterClasses());
        method.setAccessible(true);

        int qTime = (int) (System.currentTimeMillis() - receivedTime);
        long startNanoTime = System.nanoTime();
        Object value = method.invoke(instance, call.getParameters());
        long processingMicroTime = (System.nanoTime() - startNanoTime) / 1000;
        if (LOG.isDebugEnabled()) {
          LOG.debug(
              "Served: "
                  + call.getMethodName()
                  + " queueTime (millisec)= "
                  + qTime
                  + " procesingTime (microsec)= "
                  + processingMicroTime);
        }
        rpcMetrics.rpcQueueTime.inc(qTime);
        rpcMetrics.rpcProcessingTime.inc(processingMicroTime);

        MetricsTimeVaryingRate m =
            (MetricsTimeVaryingRate) rpcMetrics.registry.get(call.getMethodName());
        if (m == null) {
          try {
            m = new MetricsTimeVaryingRate(call.getMethodName(), rpcMetrics.registry);
          } catch (IllegalArgumentException iae) {
            // the metrics has been registered; re-fetch the handle
            LOG.debug("Error register " + call.getMethodName(), iae);
            m = (MetricsTimeVaryingRate) rpcMetrics.registry.get(call.getMethodName());
          }
        }
        // record call time in microseconds
        m.inc(processingMicroTime);

        if (verbose) log("Return: " + value);

        return new ObjectWritable(method.getReturnType(), value);

      } catch (InvocationTargetException e) {
        Throwable target = e.getTargetException();
        if (target instanceof IOException) {
          throw (IOException) target;
        } else {
          IOException ioe = new IOException(target.toString());
          ioe.setStackTrace(target.getStackTrace());
          throw ioe;
        }
      } catch (Throwable e) {
        if (!(e instanceof IOException)) {
          LOG.error("Unexpected throwable object ", e);
        }
        IOException ioe = new IOException(e.toString());
        ioe.setStackTrace(e.getStackTrace());
        throw ioe;
      }
    }
  public void handleEvent(GameEvent event, V086Controller.V086ClientHandler clientHandler) {
    handledCount++;

    GameTimeoutEvent timeoutEvent = (GameTimeoutEvent) event;
    KailleraUser player = timeoutEvent.getUser();
    KailleraUser user = clientHandler.getUser();

    if (player.equals(user)) {
      log.debug(
          user
              + " received timeout event "
              + timeoutEvent.getTimeoutNumber()
              + " for "
              + timeoutEvent.getGame()
              + ": resending messages...");
      clientHandler.resend(timeoutEvent.getTimeoutNumber());
    } else {
      log.debug(
          user
              + " received timeout event "
              + timeoutEvent.getTimeoutNumber()
              + " from "
              + player
              + " for "
              + timeoutEvent.getGame());
    }
  }
Example #13
0
  public void testLoggingWithNullParameters() {
    Log log = this.getLogObject();

    assertNotNull(log);

    log.debug(null);

    log.debug(null, null);

    log.debug(log.getClass().getName() + ": debug statement");

    log.debug(
        log.getClass().getName() + ": debug statement w/ null exception", new RuntimeException());

    log.error(null);

    log.error(null, null);

    log.error(log.getClass().getName() + ": error statement");

    log.error(
        log.getClass().getName() + ": error statement w/ null exception", new RuntimeException());

    log.fatal(null);

    log.fatal(null, null);

    log.fatal(log.getClass().getName() + ": fatal statement");

    log.fatal(
        log.getClass().getName() + ": fatal statement w/ null exception", new RuntimeException());

    log.info(null);

    log.info(null, null);

    log.info(log.getClass().getName() + ": info statement");

    log.info(
        log.getClass().getName() + ": info statement w/ null exception", new RuntimeException());

    log.trace(null);

    log.trace(null, null);

    log.trace(log.getClass().getName() + ": trace statement");

    log.trace(
        log.getClass().getName() + ": trace statement w/ null exception", new RuntimeException());

    log.warn(null);

    log.warn(null, null);

    log.warn(log.getClass().getName() + ": warn statement");

    log.warn(
        log.getClass().getName() + ": warn statement w/ null exception", new RuntimeException());
  }
Example #14
0
 public static boolean addLock(String key) {
   if (isLocked(key)) {
     Log.debug(PKG, "locked-" + key);
     return false;
   } else {
     locks.add(key);
     Log.debug(PKG, "lock-" + key);
     return true;
   }
 }
  private Bitmap makeProperBitmap(final Bitmap aBitmap, final int aWidth, final int aHeight) {
    final Bitmap bitmap = Bitmap.createBitmap(aWidth, aHeight, Bitmap.Config.ARGB_8888);
    myTextureCloneCanvas.setBitmap(bitmap);
    myTextureCloneCanvas.drawBitmap(aBitmap, 0, 0, myTextureClonePaint);

    // #if DEBUG
    Log.debug("created proper texture bitmap");
    Log.debug("bitmap size: {}x{}", aBitmap.getWidth(), aBitmap.getHeight());
    Log.debug("proper size: {}x{}", aWidth, aHeight);
    // #endif

    return bitmap;
  }
  public JilterStatus envrcpt(String[] argv, Properties properties) {
    for (int i = 0; i < argv.length; i++) {
      String strRecipient = argv[i];
      boolean orcptFlag = strRecipient.toLowerCase(Locale.ENGLISH).trim().contains("orcpt=");
      if (!orcptFlag) {
        logger.debug("jilter envrcpt() {to='" + strRecipient + "'}");
        String recipient =
            strRecipient.toLowerCase(Locale.ENGLISH).trim().replaceAll("<", "").replaceAll(">", "");
        rcpts.add(recipient);

        logger.debug("jilter add recipient {recipient='" + recipient + "'}");
      }
    }
    return JilterStatus.SMFIS_CONTINUE;
  }
  /**
   * there is a socket listening on the port for this packet. process if it is a new connection rdp
   * packet
   */
  public void processNewConnection(RDPServerSocket serverSocket, RDPPacket packet) {
    if (Log.loggingNet)
      Log.net(
          "processNewConnection: RDPPACKET (localport=" + serverSocket.getPort() + "): " + packet);

    //        int localPort = serverSocket.getPort();
    InetAddress remoteAddr = packet.getInetAddress();
    int remotePort = packet.getPort();
    if (!packet.isSyn()) {
      // the client is not attemping to start a new connection
      // send a reset and forget about it
      Log.debug("socket got non-syn packet, replying with reset: packet=" + packet);
      RDPPacket rstPacket = RDPPacket.makeRstPacket();
      rstPacket.setPort(remotePort);
      rstPacket.setInetAddress(remoteAddr);
      RDPServer.sendPacket(serverSocket.getDatagramChannel(), rstPacket);
      return;
    }

    // it is a syn packet, lets make a new connection for it
    RDPConnection con = new RDPConnection();
    DatagramChannel dc = serverSocket.getDatagramChannel();
    con.initConnection(dc, packet);

    // add new connection to allConnectionMap
    registerConnection(con, dc);

    // ack it with a syn
    RDPPacket synPacket = RDPPacket.makeSynPacket(con);
    con.sendPacketImmediate(synPacket, false);
  }
Example #18
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.apache.mina.core.service.IoHandlerAdapter#sessionClosed(org.apache
  * .mina.core.session.IoSession)
  */
 public void sessionClosed(IoSession session) throws Exception {
   log.debug("closed stub: " + session.getRemoteAddress());
   TConn d = (TConn) session.getAttribute("conn");
   if (d != null) {
     d.close();
   }
 }
 public void addTrackedPerceiver(
     Long perceiverOid, InterpolatedWorldNode wnode, Integer reactionRadius) {
   lock.lock();
   try {
     if (perceiverDataMap.containsKey(perceiverOid)) {
       // Don't add the object more than once.
       Log.error(
           "ProximityTracker.addTrackedPerceiver: perceiverOid "
               + perceiverOid
               + " is already in the set of local objects, for ProximityTracker instance "
               + this);
       return;
     }
     PerceiverData perceiverData = new PerceiverData(perceiverOid, reactionRadius, wnode);
     perceiverDataMap.put(perceiverOid, perceiverData);
   } finally {
     lock.unlock();
   }
   if (Log.loggingDebug)
     Log.debug(
         "ProximityTracker.addTrackedPerceiver: perceiverOid="
             + perceiverOid
             + " reactionRadius="
             + reactionRadius
             + " instanceOid="
             + instanceOid);
 }
  @Test
  @SuppressWarnings("deprecation")
  public void testOurLogLogging() {
    final Log logger = new Log();

    logger.trace("Foobar TRACE");
    AppenderForTests.hasNoLastEvent("at Trace level");
    assertFalse(logger.isTraceEnabled());

    logger.debug("Foobar DEBUG");
    AppenderForTests.hasNoLastEvent("at Debug level");
    assertFalse(logger.isDebugEnabled());

    logger.info("Foobar INFO");
    AppenderForTests.hasNoLastEvent("at Info level");
    assertFalse(logger.isInfoEnabled());

    logger.warn("Foobar WARN");
    AppenderForTests.hasLastEvent("at Warn level");
    assertTrue(logger.isWarnEnabled());

    logger.error("Foobar ERROR");
    AppenderForTests.hasLastEvent("at Error level");
    assertTrue(logger.isErrorEnabled());
  }
 protected void performNotification(
     long perceiverOid, long perceivedOid, boolean inRadius, boolean wasInRadius) {
   if (Log.loggingDebug)
     Log.debug(
         "ProximityTracker.performNotification: perceiverOid "
             + perceiverOid
             + ", perceivedOid "
             + perceivedOid
             + ", inRadius "
             + inRadius
             + ", wasInRadius "
             + wasInRadius);
   if (notifyCallback != null) {
     notifyCallback.notifyReactionRadius(perceivedOid, perceiverOid, inRadius, wasInRadius);
     notifyCallback.notifyReactionRadius(perceiverOid, perceivedOid, inRadius, wasInRadius);
   } else {
     ObjectTracker.NotifyReactionRadiusMessage nmsg =
         new ObjectTracker.NotifyReactionRadiusMessage(
             perceivedOid, perceiverOid, inRadius, wasInRadius);
     Engine.getAgent().sendBroadcast(nmsg);
     nmsg =
         new ObjectTracker.NotifyReactionRadiusMessage(
             perceiverOid, perceivedOid, inRadius, wasInRadius);
     Engine.getAgent().sendBroadcast(nmsg);
   }
 }
Example #22
0
  @Override
  protected void checkMemoryFootPrint() {
    if (_model._output._ntrees == 0) return;
    int trees_so_far = _model._output._ntrees; // existing trees
    long model_mem_size =
        new ComputeModelSize(trees_so_far, _model._output._treeKeys).doAllNodes()._model_mem_size;
    _model._output._treeStats._byte_size = model_mem_size;
    double avg_tree_mem_size = (double) model_mem_size / trees_so_far;
    Log.debug(
        "Average tree size (for all classes): " + PrettyPrint.bytes((long) avg_tree_mem_size));

    // all the compressed trees are stored on the driver node
    long max_mem = H2O.SELF.get_max_mem();
    if (_parms._ntrees * avg_tree_mem_size > max_mem) {
      String msg =
          "The tree model will not fit in the driver node's memory ("
              + PrettyPrint.bytes((long) avg_tree_mem_size)
              + " per tree x "
              + _parms._ntrees
              + " > "
              + PrettyPrint.bytes(max_mem)
              + ") - try decreasing ntrees and/or max_depth or increasing min_rows!";
      error("_ntrees", msg);
      cancel(msg);
    }
  }
Example #23
0
  /**
   * Submit an HTTP post to the given url, sending the data specified
   *
   * @param url url to post to
   * @param length number of bytes in the dataToSend to, er, send
   * @param dataToSend stream of bytes to be sent
   */
  public static boolean postData(URL url, long length, InputStream dataToSend) {
    try {
      HttpURLConnection con = (HttpURLConnection) url.openConnection();
      con.setDoInput(true);
      con.setDoOutput(true);
      con.setUseCaches(false);
      con.setRequestMethod("POST");
      con.setRequestProperty("Content-length", "" + length);

      OutputStream out = con.getOutputStream();
      byte buf[] = new byte[1 * 1024];
      int read;
      long sent = 0;
      GZIPOutputStream zipOut = new GZIPOutputStream(out);
      while ((read = dataToSend.read(buf)) != -1) {
        zipOut.write(buf, 0, read);
        sent += read;
        if (sent >= length) break;
      }

      zipOut.flush();
      zipOut.finish();
      zipOut.close();
      out.close();

      int rv = con.getResponseCode();
      _log.debug("Posted " + sent + " bytes: " + rv);
      return length == sent;
    } catch (IOException ioe) {
      _log.error("Error posting the data", ioe);
      return false;
    }
  }
  /**
   * 領域マスタの1レコードをMap形式で返す。 引数には主キー値を渡す。
   *
   * @param connection
   * @param labelKubun
   * @param value
   * @return
   * @throws NoDataFoundException
   * @throws DataAccessException
   */
  public static Map selectRecord(Connection connection, String ryouikiNo)
      throws NoDataFoundException, DataAccessException {
    // -----------------------
    // SQL文の作成
    // -----------------------
    String select =
        "SELECT"
            + " A.RYOIKI_NO"
            + ",A.RYOIKI_RYAKU"
            + ",A.KOMOKU_NO"
            // 2006/06/26 苗 修正ここから
            + ",A.SETTEI_KIKAN" // 設定期間
            + ",A.SETTEI_KIKAN_KAISHI" // 設定期間(開始年度)
            + ",A.SETTEI_KIKAN_SHURYO" // 設定期間(終了年度)
            // 2006/06/26 苗 修正ここまで
            + ",A.BIKO"
            + " FROM MASTER_RYOIKI A"
            + " WHERE RYOIKI_NO = ? ";

    if (log.isDebugEnabled()) {
      log.debug("query:" + select);
    }

    // -----------------------
    // レコード取得
    // -----------------------
    List result = SelectUtil.select(connection, select, new String[] {ryouikiNo});
    if (result.isEmpty()) {
      throw new NoDataFoundException("当該レコードは存在しません。領域No=" + ryouikiNo);
    }
    return (Map) result.get(0);
  }
  /**
   * コード一覧作成用メソッド。<br>
   * 領域番号と領域名称の一覧を取得する。 領域番号順にソートする。
   *
   * @param connection コネクション
   * @return
   * @throws ApplicationException
   */
  public static List selectRyoikiInfoList(Connection connection, String kubun)
      throws ApplicationException {

    // -----------------------
    // SQL文の作成
    // -----------------------
    String select =
        "SELECT"
            + " RYOIKI_NO," // 領域番号
            + " RYOIKI_RYAKU" // 領域名称
            + " FROM MASTER_RYOIKI";

    if ("1".equals(kubun)) {
      select = select + " WHERE KEIKAKU_FLG = '1'";
    } else {
      select = select + " WHERE KOUBO_FLG = '1'";
    }
    select = select + " GROUP BY RYOIKI_NO, RYOIKI_RYAKU" + " ORDER BY RYOIKI_NO";

    if (log.isDebugEnabled()) {
      log.debug("query:" + select);
    }

    // -----------------------
    // リスト取得
    // -----------------------
    try {
      return SelectUtil.select(connection, select);
    } catch (DataAccessException e) {
      throw new ApplicationException("領域情報検索中にDBエラーが発生しました。", new ErrorInfo("errors.4004"), e);
    } catch (NoDataFoundException e) {
      throw new SystemException("領域マスタに1件もデータがありません。", e);
    }
  }
  /**
   * コード一覧(新規領域)作成用メソッド。<br>
   * 領域番号と領域名称の一覧を取得する。 領域番号順にソートする。
   *
   * @param connection コネクション
   * @return  List
   * @throws ApplicationException
   */
  public static List selectRyoikiSinnkiInfoList(Connection connection) throws ApplicationException {

    // -----------------------
    // SQL文の作成
    // -----------------------
    StringBuffer select = new StringBuffer();

    select.append("SELECT DISTINCT");
    select.append(" RYOIKI_NO,"); // 領域番号
    select.append(" RYOIKI_RYAKU,"); // 領域名称
    select.append(" SETTEI_KIKAN"); // 設定期間
    select.append(" FROM MASTER_RYOIKI");
    select.append(" WHERE ZENNENDO_OUBO_FLG = '1'");
    select.append(" ORDER BY RYOIKI_NO");

    if (log.isDebugEnabled()) {
      log.debug("query:" + select);
    }

    // -----------------------
    // リスト取得
    // -----------------------
    try {
      return SelectUtil.select(connection, select.toString());
    } catch (DataAccessException e) {
      throw new ApplicationException("領域情報検索中にDBエラーが発生しました。", new ErrorInfo("errors.4004"), e);
    } catch (NoDataFoundException e) {
      throw new SystemException("領域マスタに1件もデータがありません。", e);
    }
  }
  /**
   * 領域の一覧(コンポボックス用)を取得する。
   *
   * @param connection コネクション
   * @return 事業情報
   * @throws ApplicationException
   */
  public static List selectRyouikiKubunInfoList(Connection connection)
      throws ApplicationException, NoDataFoundException {

    // -----------------------
    // SQL文の作成
    // -----------------------
    String select =
        "SELECT"
            + " A.RYOIKI_NO"
            + ",A.RYOIKI_RYAKU"
            + " FROM MASTER_RYOIKI A"
            + " ORDER BY RYOIKI_NO";
    StringBuffer query = new StringBuffer(select);

    if (log.isDebugEnabled()) {
      log.debug("query:" + query);
    }

    // -----------------------
    // リスト取得
    // -----------------------
    try {
      return SelectUtil.select(connection, query.toString());
    } catch (DataAccessException e) {
      throw new ApplicationException("領域情報検索中にDBエラーが発生しました。", new ErrorInfo("errors.4004"), e);
    } catch (NoDataFoundException e) {
      throw new NoDataFoundException("領域マスタに1件もデータがありません。", e);
    }
  }
Example #28
0
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
      final boolean logDebug = LOG.isDebugEnabled();
      long startTime = 0;
      if (logDebug) {
        startTime = System.currentTimeMillis();
      }

      ObjectWritable value = null;
      try {
        value =
            (ObjectWritable)
                client.call(
                    new Invocation(method, args), getAddress(), protocol, ticket, rpcTimeout);
      } catch (RemoteException re) {
        throw re;
      } catch (ConnectException ce) {
        needCheckDnsUpdate = true;
        throw ce;
      } catch (NoRouteToHostException nrhe) {
        needCheckDnsUpdate = true;
        throw nrhe;
      } catch (PortUnreachableException pue) {
        needCheckDnsUpdate = true;
        throw pue;
      } catch (UnknownHostException uhe) {
        needCheckDnsUpdate = true;
        throw uhe;
      }
      if (logDebug) {
        long callTime = System.currentTimeMillis() - startTime;
        LOG.debug("Call: " + method.getName() + " " + callTime);
      }
      return value.get();
    }
Example #29
0
    // Register  protocol and its impl for rpc calls
    void registerProtocolAndImpl(RpcKind rpcKind, Class<?> protocolClass, Object protocolImpl) {
      String protocolName = RPC.getProtocolName(protocolClass);
      long version;

      try {
        version = RPC.getProtocolVersion(protocolClass);
      } catch (Exception ex) {
        LOG.warn("Protocol " + protocolClass + " NOT registered as cannot get protocol version ");
        return;
      }

      getProtocolImplMap(rpcKind)
          .put(
              new ProtoNameVer(protocolName, version),
              new ProtoClassProtoImpl(protocolClass, protocolImpl));
      LOG.debug(
          "RpcKind = "
              + rpcKind
              + " Protocol Name = "
              + protocolName
              + " version="
              + version
              + " ProtocolImpl="
              + protocolImpl.getClass().getName()
              + " protocolClass="
              + protocolClass.getName());
    }
Example #30
0
 protected void setUp() {
   Resource res = new FileSystemResource("build/classes/beans.xml");
   XmlBeanFactory factory = new XmlBeanFactory(res);
   DataSource vfbDS = (DataSource) factory.getBean("vfbDataSource");
   this.setDataSource(vfbDS);
   LOG.debug("data source : " + vfbDS);
 }