示例#1
1
  /** @param config */
  public DecorateHandler(TagConfig config) {
    super(config);
    this.template = this.getRequiredAttribute("template");
    this.handlers = new HashMap();

    Iterator itr = this.findNextByType(DefineHandler.class);
    DefineHandler d = null;
    while (itr.hasNext()) {
      d = (DefineHandler) itr.next();
      this.handlers.put(d.getName(), d);
      if (log.isLoggable(Level.FINE)) {
        log.fine(tag + " found Define[" + d.getName() + "]");
      }
    }
    List paramC = new ArrayList();
    itr = this.findNextByType(ParamHandler.class);
    while (itr.hasNext()) {
      paramC.add(itr.next());
    }
    if (paramC.size() > 0) {
      this.params = new ParamHandler[paramC.size()];
      for (int i = 0; i < this.params.length; i++) {
        this.params[i] = (ParamHandler) paramC.get(i);
      }
    } else {
      this.params = null;
    }
  }
示例#2
1
  public ConsoleManager(GlowServer server) {
    this.server = server;

    // install Ansi code handler, which makes colors work on Windows
    AnsiConsole.systemInstall();

    for (Handler h : logger.getHandlers()) {
      logger.removeHandler(h);
    }

    // used until/unless gui is created
    consoleHandler = new FancyConsoleHandler();
    // consoleHandler.setFormatter(new DateOutputFormatter(CONSOLE_DATE));
    logger.addHandler(consoleHandler);

    // todo: why is this here?
    Runtime.getRuntime().addShutdownHook(new ServerShutdownThread());

    // reader must be initialized before standard streams are changed
    try {
      reader = new ConsoleReader();
    } catch (IOException ex) {
      logger.log(Level.SEVERE, "Exception initializing console reader", ex);
    }
    reader.addCompleter(new CommandCompleter());

    // set system output streams
    System.setOut(new PrintStream(new LoggerOutputStream(Level.INFO), true));
    System.setErr(new PrintStream(new LoggerOutputStream(Level.WARNING), true));
  }
  /**
   * Check the autoCommit and Transaction Isolation levels of the DataSource.
   *
   * <p>If autoCommit is true this could be a real problem.
   *
   * <p>If the Isolation level is not READ_COMMITED then optimistic concurrency checking may not
   * work as expected.
   */
  private boolean checkDataSource(ServerConfig serverConfig) {

    if (serverConfig.getDataSource() == null) {
      if (serverConfig.getDataSourceConfig().isOffline()) {
        // this is ok - offline DDL generation etc
        return false;
      }
      throw new RuntimeException("DataSource not set?");
    }

    Connection c = null;
    try {
      c = serverConfig.getDataSource().getConnection();

      if (c.getAutoCommit()) {
        String m = "DataSource [" + serverConfig.getName() + "] has autoCommit defaulting to true!";
        logger.warning(m);
      }

      return true;

    } catch (SQLException ex) {
      throw new PersistenceException(ex);

    } finally {
      if (c != null) {
        try {
          c.close();
        } catch (SQLException ex) {
          logger.log(Level.SEVERE, null, ex);
        }
      }
    }
  }
示例#4
1
  public boolean savePassword(String password) {
    if (passwordExist()) {
      _log.warning(
          "[SecondaryPasswordAuth]" + _activeClient.getAccountName() + " forced savePassword");
      _activeClient.closeNow();
      return false;
    }

    if (!validatePassword(password)) {
      _activeClient.sendPacket(new Ex2ndPasswordAck(0, Ex2ndPasswordAck.WRONG_PATTERN));
      return false;
    }

    password = cryptPassword(password);

    try (Connection con = DatabaseFactory.getInstance().getConnection();
        PreparedStatement statement = con.prepareStatement(INSERT_PASSWORD)) {
      statement.setString(1, _activeClient.getAccountName());
      statement.setString(2, VAR_PWD);
      statement.setString(3, password);
      statement.execute();
    } catch (Exception e) {
      _log.log(Level.SEVERE, "Error while writing password.", e);
      return false;
    }
    _password = password;
    return true;
  }
  @Override
  public void setSymbols(List<List<String>> symbols) {
    log.info("set symbols called");

    clearTickSymbols();

    final List<TickParms> tp = new ArrayList<TickParms>();

    try {

      TickParms p;
      for (List<String> m : symbols) {
        p = new TickParms();
        p.setSymbol(m.get(0));
        p.setMinvol(Integer.parseInt(m.get(1)));
        p.setMaxvol(Integer.parseInt(m.get(2)));
        p.setPriceBasis(Double.parseDouble(m.get(3)));
        tp.add(p);
      }

    } catch (Exception e) {
      log.severe("caught exception parsing parms: " + e.getMessage());
    }

    log.info(String.format("calling setSymbols with %d symbols\n", tp.size()));
    try {
      ctx.getBean(TickGenerator.class).setSymbols(tp.toArray(new TickParms[] {}));
    } catch (Exception e) {
      log.severe("caught exception setting parms: " + e.getMessage());
    }
  }
  /**
   * Checks if our WPS can really handle this process inputs and outputs
   *
   * @param pf
   * @param name
   * @return
   */
  Set<Name> getProcessBlacklist() {
    synchronized (PROCESS_BLACKLIST) {
      if (PROCESS_BLACKLIST == Collections.EMPTY_SET) {

        Set<Name> blacklist = new HashSet<Name>();

        for (ProcessFactory pf : Processors.getProcessFactories()) {
          int count = 0;
          for (Name name : pf.getNames()) {
            try {
              // check inputs
              for (Parameter<?> p : pf.getParameterInfo(name).values()) {
                List<ProcessParameterIO> ppios = ProcessParameterIO.findAll(p, context);
                if (ppios.isEmpty()) {
                  LOGGER.log(
                      Level.INFO,
                      "Blacklisting process "
                          + name.getURI()
                          + " as the input "
                          + p.key
                          + " of type "
                          + p.type
                          + " cannot be handled");
                  blacklist.add(name);
                }
              }

              // check outputs
              for (Parameter<?> p : pf.getResultInfo(name, null).values()) {
                List<ProcessParameterIO> ppios = ProcessParameterIO.findAll(p, context);
                if (ppios.isEmpty()) {
                  LOGGER.log(
                      Level.INFO,
                      "Blacklisting process "
                          + name.getURI()
                          + " as the output "
                          + p.key
                          + " of type "
                          + p.type
                          + " cannot be handled");
                  blacklist.add(name);
                }
              }
            } catch (Throwable t) {
              blacklist.add(name);
            }

            if (!blacklist.contains(name)) {
              count++;
            }
          }
          LOGGER.info("Found " + count + " bindable processes in " + pf.getTitle());
        }

        PROCESS_BLACKLIST = blacklist;
      }
    }

    return PROCESS_BLACKLIST;
  }
  protected void closeWebDriver(Thread thread) {
    ALL_WEB_DRIVERS_THREADS.remove(thread);
    WebDriver webdriver = THREAD_WEB_DRIVER.remove(thread.getId());

    if (webdriver != null && !holdBrowserOpen) {
      log.info("Close webdriver: " + thread.getId() + " -> " + webdriver);

      long start = System.currentTimeMillis();

      Thread t = new Thread(new CloseBrowser(webdriver));
      t.setDaemon(true);
      t.start();

      try {
        t.join(closeBrowserTimeoutMs);
      } catch (InterruptedException e) {
        log.log(FINE, "Failed to close webdriver in " + closeBrowserTimeoutMs + " milliseconds", e);
      }

      long duration = System.currentTimeMillis() - start;
      if (duration >= closeBrowserTimeoutMs) {
        log.severe("Failed to close webdriver in " + closeBrowserTimeoutMs + " milliseconds");
      } else if (duration > 200) {
        log.info("Closed webdriver in " + duration + " ms");
      } else {
        log.fine("Closed webdriver in " + duration + " ms");
      }
    }
  }
示例#8
0
  public boolean changePassword(String oldPassword, String newPassword) {
    if (!passwordExist()) {
      _log.warning(
          "[SecondaryPasswordAuth]" + _activeClient.getAccountName() + " forced changePassword");
      _activeClient.closeNow();
      return false;
    }

    if (!checkPassword(oldPassword, true)) {
      return false;
    }

    if (!validatePassword(newPassword)) {
      _activeClient.sendPacket(new Ex2ndPasswordAck(2, Ex2ndPasswordAck.WRONG_PATTERN));
      return false;
    }

    newPassword = cryptPassword(newPassword);

    try (Connection con = DatabaseFactory.getInstance().getConnection();
        PreparedStatement statement = con.prepareStatement(UPDATE_PASSWORD)) {
      statement.setString(1, newPassword);
      statement.setString(2, _activeClient.getAccountName());
      statement.setString(3, VAR_PWD);
      statement.execute();
    } catch (Exception e) {
      _log.log(Level.SEVERE, "Error while reading password.", e);
      return false;
    }

    _password = newPassword;
    _authed = false;
    return true;
  }
  public Document createDocument(BufferedImage image, String identifier) {
    assert (image != null);
    BufferedImage bimg = image;
    // Scaling image is especially with the correlogram features very important!
    // All images are scaled to guarantee a certain upper limit for indexing.
    if (Math.max(image.getHeight(), image.getWidth()) > MAX_IMAGE_DIMENSION) {
      bimg = ImageUtils.scaleImage(image, MAX_IMAGE_DIMENSION);
    }
    Document doc = null;
    logger.finer("Starting extraction from image [CEDD - fast].");
    CEDD vd = new CEDD();
    vd.extract(bimg);
    logger.fine("Extraction finished [CEDD - fast].");

    doc = new Document();
    doc.add(new Field(DocumentBuilder.FIELD_NAME_CEDD, vd.getByteArrayRepresentation()));
    if (identifier != null)
      doc.add(
          new Field(
              DocumentBuilder.FIELD_NAME_IDENTIFIER,
              identifier,
              Field.Store.YES,
              Field.Index.NOT_ANALYZED));

    return doc;
  }
示例#10
0
  /** Method <code>resizeApplicationBuffer</code> is used to perform */
  private ByteBuffer resizeApplicationBuffer(ByteBuffer net, ByteBuffer app) {

    //  if (appBuffSize > app.remaining()) {
    //    if (net.remaining() > app.remaining()) {
    //    if (appBuffSize > app.capacity() - app.remaining()) {
    //      if (log.isLoggable(Level.FINE)) {
    //        log.fine("Resizing tlsInput to " + (appBuffSize + app.capacity()) + " bytes.");
    //      }
    //
    //      ByteBuffer bb = ByteBuffer.allocate(app.capacity() + appBuffSize);
    if (log.isLoggable(Level.FINE)) {
      log.log(
          Level.FINE,
          "Resizing tlsInput to {0} bytes, {1}",
          new Object[] {(2048 + app.capacity()), debugId});
    }

    ByteBuffer bb = ByteBuffer.allocate(app.capacity() + 2048);

    // bb.clear();
    bb.order(app.order());
    app.flip();
    bb.put(app);

    return bb;

    //  } else {
    //
    //    return app;
    //  }    // end of else
  }
    public SVNNodeKind checkRepositoryPath(
        SCMSourceOwner context, SVNURL repoURL, StandardCredentials credentials)
        throws SVNException {
      SVNRepository repository = null;

      try {
        repository =
            getRepository(
                context, repoURL, credentials, Collections.<String, Credentials>emptyMap(), null);
        repository.testConnection();

        long rev = repository.getLatestRevision();
        String repoPath = getRelativePath(repoURL, repository);
        return repository.checkPath(repoPath, rev);
      } catch (SVNException e) {
        if (LOGGER.isLoggable(Level.FINE)) {
          LogRecord lr =
              new LogRecord(
                  Level.FINE, "Could not check repository path {0} using credentials {1} ({2})");
          lr.setThrown(e);
          lr.setParameters(
              new Object[] {
                repoURL,
                credentials == null ? null : CredentialsNameProvider.name(credentials),
                credentials
              });
          LOGGER.log(lr);
        }
        throw e;
      } finally {
        if (repository != null) repository.closeSession();
      }
    }
示例#12
0
 @Test
 public void test3BoundsSolve() {
   for (int seed = 0; seed < 10; seed++) {
     m = new CPModel();
     s = new CPSolver();
     int k = 9, k1 = 7, k2 = 6;
     IntegerVariable v0 = makeIntVar("v0", 0, 10);
     IntegerVariable v1 = makeIntVar("v1", 0, 10);
     IntegerVariable v2 = makeIntVar("v2", 0, 10);
     IntegerVariable v3 = makeIntVar("v3", 0, 10);
     m.addVariables(Options.V_BOUND, v0, v1, v2, v3);
     m.addConstraint(distanceEQ(v0, v1, k));
     m.addConstraint(distanceEQ(v1, v2, k1));
     m.addConstraint(distanceEQ(v2, v3, k2));
     s.read(m);
     s.setVarIntSelector(new RandomIntVarSelector(s, seed + 32));
     s.setValIntSelector(new RandomIntValSelector(seed));
     try {
       s.propagate();
     } catch (ContradictionException e) {
       LOGGER.info(e.getMessage()); // To change body of catch statement use File | Settings | File
       // Templates.
     }
     s.solveAll();
     int nbNode = s.getNodeCount();
     LOGGER.info("solutions : " + s.getNbSolutions() + " nbNode : " + nbNode);
     assertEquals(s.getNbSolutions(), 4);
   }
 }
示例#13
0
  @Test
  public void testNEQ() {
    Model m1 = new CPModel();
    IntegerVariable x = makeIntVar("x", 2, 4);
    IntegerVariable y = makeIntVar("y", 2, 4);

    m1.addConstraint(distanceNEQ(x, y, -2));

    Model m2 = new CPModel();
    m2.addConstraint(neq(abs(minus(x, y)), -2));

    Solver s1 = new CPSolver();
    s1.read(m1);

    Solver s2 = new CPSolver();
    s2.read(m2);

    //        s1.solveAll();
    //        s2.solveAll();
    s1.solve();
    do {
      LOGGER.info("x:" + s1.getVar(x).getVal() + " y:" + s1.getVar(y).getVal());
    } while (s1.nextSolution());
    LOGGER.info("=======");

    s2.solve();
    do {
      LOGGER.info("x:" + s2.getVar(x).getVal() + " y:" + s2.getVar(y).getVal());
    } while (s2.nextSolution());

    Assert.assertEquals("nb sol", s1.getNbSolutions(), s2.getNbSolutions());
  }
 static {
   try {
     logger =
         Logger.getLogger("co.com.losalpes.marketplace.ws.avisoDespacho.Dispatchadvice_client_ep");
     URL baseUrl = Dispatchadvice_client_ep.class.getResource(".");
     if (baseUrl == null) {
       wsdlLocationURL =
           Dispatchadvice_client_ep.class.getResource(
               "http://portal.marketplace.losalpes.com.co:7001/soa-infra/services/default/ProcesoAvisoDespacho/dispatchadvice_client_ep?WSDL");
       if (wsdlLocationURL == null) {
         baseUrl = new File(".").toURL();
         wsdlLocationURL =
             new URL(
                 baseUrl,
                 "http://portal.marketplace.losalpes.com.co:7001/soa-infra/services/default/ProcesoAvisoDespacho/dispatchadvice_client_ep?WSDL");
       }
     } else {
       if (!baseUrl.getPath().endsWith("/")) {
         baseUrl = new URL(baseUrl, baseUrl.getPath() + "/");
       }
       wsdlLocationURL =
           new URL(
               baseUrl,
               "http://portal.marketplace.losalpes.com.co:7001/soa-infra/services/default/ProcesoAvisoDespacho/dispatchadvice_client_ep?WSDL");
     }
   } catch (MalformedURLException e) {
     logger.log(
         Level.ALL,
         "Failed to create wsdlLocationURL using http://portal.marketplace.losalpes.com.co:7001/soa-infra/services/default/ProcesoAvisoDespacho/dispatchadvice_client_ep?WSDL",
         e);
   }
 }
示例#15
0
  @Test
  public void testServiceWithDSLLogger() throws Exception {
    final Logger logger = Logger.getLogger(BaseDslScript.class.getName());
    final DSLLoggerHandler handler = new DSLLoggerHandler();
    logger.addHandler(handler);

    final File dir = new File(TEST_PARSING_RESOURCE_BASE + "logger");
    final Service service = ServiceReader.getServiceFromDirectory(dir).getService();
    Assert.assertNotNull(service);

    Assert.assertTrue(
        "Println logger not found", handler.getMessages().contains("println logger call"));
    Assert.assertTrue(
        "Print logger not found", handler.getMessages().contains("print logger call"));
    Assert.assertTrue(
        "Class println not found", handler.getMessages().contains("Test Class println"));
    Assert.assertTrue("Class print not found", handler.getMessages().contains("Test Class print"));

    Assert.assertFalse(
        "preInstall event message appeared before expected",
        handler.getMessages().contains("This is the preInstall event"));

    final ExecutableDSLEntry preInstall = service.getLifecycle().getPreInstall();
    final ClosureExecutableEntry preInstallClosureEntry = (ClosureExecutableEntry) preInstall;
    preInstallClosureEntry.getCommand().call();

    Assert.assertTrue(
        "preInstall event message not found",
        handler.getMessages().contains("This is the preInstall event"));
  }
示例#16
0
  /** @see FacesContext#addMessage(String, javax.faces.application.FacesMessage) */
  public void addMessage(String clientId, FacesMessage message) {
    assertNotReleased();
    // Validate our preconditions
    Util.notNull("message", message);

    if (maxSeverity == null) {
      maxSeverity = message.getSeverity();
    } else {
      Severity sev = message.getSeverity();
      if (sev.getOrdinal() > maxSeverity.getOrdinal()) {
        maxSeverity = sev;
      }
    }

    if (componentMessageLists == null) {
      componentMessageLists = new LinkedHashMap<String, List<FacesMessage>>();
    }

    // Add this message to our internal queue
    List<FacesMessage> list = componentMessageLists.get(clientId);
    if (list == null) {
      list = new ArrayList<FacesMessage>();
      componentMessageLists.put(clientId, list);
    }
    list.add(message);
    if (LOGGER.isLoggable(Level.FINE)) {
      LOGGER.fine(
          "Adding Message[sourceId="
              + (clientId != null ? clientId : "<<NONE>>")
              + ",summary="
              + message.getSummary()
              + ")");
    }
  }
示例#17
0
  /** @see javax.faces.context.FacesContext#getRenderKit() */
  public RenderKit getRenderKit() {
    assertNotReleased();
    UIViewRoot vr = getViewRoot();
    if (vr == null) {
      return (null);
    }
    String renderKitId = vr.getRenderKitId();

    if (renderKitId == null) {
      return null;
    }

    if (renderKitId.equals(lastRkId)) {
      return lastRk;
    } else {
      lastRk = rkFactory.getRenderKit(this, renderKitId);
      if (lastRk == null) {
        if (LOGGER.isLoggable(Level.SEVERE)) {
          LOGGER.log(
              Level.SEVERE,
              "Unable to locate renderkit " + "instance for render-kit-id {0}.  Using {1} instead.",
              new String[] {renderKitId, RenderKitFactory.HTML_BASIC_RENDER_KIT});
        }
      }
      lastRkId = renderKitId;
      return lastRk;
    }
  }
示例#18
0
  /** @param args the command line arguments */
  public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    // <editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
     */
    try {
      UIManager.setLookAndFeel("com.jtattoo.plaf.noire.NoireLookAndFeel");
    } catch (ClassNotFoundException ex) {
      java.util.logging.Logger.getLogger(server_form.class.getName())
          .log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
      java.util.logging.Logger.getLogger(server_form.class.getName())
          .log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
      java.util.logging.Logger.getLogger(server_form.class.getName())
          .log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
      java.util.logging.Logger.getLogger(server_form.class.getName())
          .log(java.util.logging.Level.SEVERE, null, ex);
    }
    // </editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(
        new Runnable() {
          public void run() {
            new server_form().setVisible(true);
          }
        });
  }
  protected Collection<KnowledgePackage> compileResources(
      Map<Resource, ResourceType> resources, boolean enablePropertySpecificFacts) {
    KnowledgeBuilderConfiguration conf = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();

    if (enablePropertySpecificFacts) {
      conf.setOption(PropertySpecificOption.ALLOWED);
    } else {
      conf.setOption(PropertySpecificOption.DISABLED);
    }

    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(conf);
    for (Map.Entry<Resource, ResourceType> entry : resources.entrySet()) {
      kbuilder.add(entry.getKey(), entry.getValue());
      if (kbuilder.hasErrors()) {
        Logger.getLogger(Case1.class.getName())
            .log(Level.SEVERE, "Compilation Errors in {0}", entry.getKey());
        Iterator<KnowledgeBuilderError> iterator = kbuilder.getErrors().iterator();
        while (iterator.hasNext()) {
          KnowledgeBuilderError knowledgeBuilderError = iterator.next();
          Logger.getLogger(Case1.class.getName())
              .log(Level.SEVERE, knowledgeBuilderError.getMessage());
          System.out.println(knowledgeBuilderError.getMessage());
        }
        throw new IllegalStateException("Compilation Errors");
      }
    }
    return kbuilder.getKnowledgePackages();
  }
  static void sendJSONResponse(HttpServletResponse response, Map<String, String> responseMap) {
    if (!Boolean.parseBoolean(responseMap.get("success"))) {
      int serverCode = 500;
      if (responseMap.containsKey("serverCode")) {
        serverCode = Integer.parseInt(responseMap.get("serverCode"));
      }
      response.setStatus(serverCode);
    }

    String responseContent = new Gson().toJson(responseMap);
    response.setContentType("application/json");
    response.setCharacterEncoding("utf-8");
    response.setHeader("Content-Length", Integer.toString(responseContent.length()));

    Writer writer = null;
    try {
      writer = response.getWriter();
      writer.write(responseContent);
    } catch (IOException ex) {
      Logger.getLogger(RequestResponseHelper.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
      if (writer != null) {
        try {
          writer.close();
        } catch (IOException ex) {
          Logger.getLogger(RequestResponseHelper.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
    }
  }
示例#21
0
 @Test
 public void test3LTSolve() {
   for (int seed = 0; seed < 10; seed++) {
     m = new CPModel();
     s = new CPSolver();
     int k = 2;
     IntegerVariable v0 = makeIntVar("v0", 0, 10);
     IntegerVariable v1 = makeIntVar("v1", 0, 10);
     m.addConstraint(distanceLT(v0, v1, k));
     s.read(m);
     s.setVarIntSelector(new RandomIntVarSelector(s, seed + 32));
     s.setValIntSelector(new RandomIntValSelector(seed));
     try {
       s.propagate();
     } catch (ContradictionException e) {
       LOGGER.info(e.getMessage()); // To change body of catch statement use File | Settings | File
       // Templates.
     }
     s.solveAll();
     int nbNode = s.getNodeCount();
     LOGGER.info("solutions : " + s.getNbSolutions() + " nbNode : " + nbNode);
     assertEquals(s.getNbSolutions(), 31);
     assertEquals(nbNodeFromRegulatModel(seed), nbNode);
   }
 }
 void connect() {
   setConnectionState(ConnectionState.CONNECTING);
   try {
     tryConnect();
     setConnectionState(ConnectionState.CONNECTED);
   } catch (SecurityException e) {
     setConnectionState(ConnectionState.DISCONNECTED);
     throw e;
   } catch (SaslException e) {
     // Workaround for JBoss/WildFly authentication failed exception
     throw new SecurityException(e);
   } catch (Exception e) {
     setConnectionState(ConnectionState.DISCONNECTED);
     // Workaround for GlassFish's LoginException class not found
     if (e.toString().contains("com.sun.enterprise.security.LoginException")) { // NOI18N
       throw new SecurityException(
           "Authentication failed! Invalid username or password"); // NOI18N
     }
     if (LOGGER.isLoggable(Level.INFO)) {
       // Try to provide info on the target
       //    Use PID when attach was used to connect,
       //    Use JMXServiceURL otherwise...
       final String param =
           (lvm != null)
               ? String.valueOf(lvm.vmid())
               : ((jmxUrl != null) ? jmxUrl.toString() : ""); // NOI18N
       LOGGER.log(Level.INFO, "connect(" + param + ")", e); // NOI18N
     }
   }
 }
示例#23
0
  @Test
  public void test1NeqSolve() {
    for (int seed = 0; seed < 10; seed++) {
      m = new CPModel();
      s = new CPSolver();
      int k = 9, k1 = 7, k2 = 6;
      IntegerVariable v0 = makeIntVar("v0", 0, 10);
      IntegerVariable v1 = makeIntVar("v1", 0, 10);
      IntegerVariable v2 = makeIntVar("v2", 0, 10);
      IntegerVariable v3 = makeIntVar("v3", 0, 10);

      m.addConstraint(distanceNEQ(v0, v1, k));
      m.addConstraint(distanceNEQ(v1, v2, k1));
      m.addConstraint(distanceNEQ(v2, v3, k2));
      s.read(m);
      s.setVarIntSelector(new RandomIntVarSelector(s, seed + 32));
      s.setValIntSelector(new RandomIntValSelector(seed));
      try {
        s.propagate();
      } catch (ContradictionException e) {
        LOGGER.info(e.getMessage());
      }
      s.solveAll();
      int nbNode = s.getNodeCount();
      LOGGER.info("solutions : " + s.getNbSolutions() + " nbNode : " + nbNode);
      assertEquals(s.getNbSolutions(), 12147);
    }
  }
示例#24
0
  /*
   * (non-Javadoc)
   *
   * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
   *      javax.faces.component.UIComponent)
   */
  public void apply(FaceletContext ctxObj, UIComponent parent) throws IOException {
    FaceletContextImplBase ctx = (FaceletContextImplBase) ctxObj;
    VariableMapper orig = ctx.getVariableMapper();
    if (this.params != null) {
      VariableMapper vm = new VariableMapperWrapper(orig);
      ctx.setVariableMapper(vm);
      for (int i = 0; i < this.params.length; i++) {
        this.params[i].apply(ctx, parent);
      }
    }

    ctx.pushClient(this);
    String path = null;
    try {
      path = this.template.getValue(ctx);
      ctx.includeFacelet(parent, path);
    } catch (IOException e) {
      if (log.isLoggable(Level.FINE)) {
        log.log(Level.FINE, e.toString(), e);
      }
      throw new TagAttributeException(this.tag, this.template, "Invalid path : " + path);
    } finally {
      ctx.setVariableMapper(orig);
      ctx.popClient(this);
    }
  }
  /** @param args the command line arguments */
  public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    // <editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
     */
    try {
      for (javax.swing.UIManager.LookAndFeelInfo info :
          javax.swing.UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          javax.swing.UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (ClassNotFoundException ex) {
      java.util.logging.Logger.getLogger(FrameLoading.class.getName())
          .log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
      java.util.logging.Logger.getLogger(FrameLoading.class.getName())
          .log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
      java.util.logging.Logger.getLogger(FrameLoading.class.getName())
          .log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
      java.util.logging.Logger.getLogger(FrameLoading.class.getName())
          .log(java.util.logging.Level.SEVERE, null, ex);
    }
    // </editor-fold>

    /* Create and display the form */

  }
  private String getData(String url, String data) throws WasabiNetClientException {

    StringBuffer sb = new StringBuffer();

    try {
      URL dest = new URL(url);
      URLConnection conn = dest.openConnection();

      conn.setDoOutput(true);

      OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(), "UTF8");
      System.out.println(writer.getEncoding());
      writer.write(data);
      writer.flush();

      BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));

      char[] buf = new char[MAX_READ];
      int readed = 0;
      while ((readed = reader.read(buf)) > 0) {
        sb.append(buf, 0, readed);
      }

    } catch (MalformedURLException ex) {
      Logger.getLogger(WasabiNetClient.class.getName()).log(Level.SEVERE, null, ex);
      throw new WasabiNetClientException(
          "Error al conectar con la url <" + url + ">:" + ex.getMessage());
    } catch (IOException ex) {
      Logger.getLogger(WasabiNetClient.class.getName()).log(Level.SEVERE, null, ex);
      throw new WasabiNetClientException("Error de lectura/escritura:" + ex.getMessage());
    }

    return sb.toString();
  }
示例#27
0
  public void split() throws IOException {
    List<ObjectPath> pathTable = asset.getPaths();
    TypeTree typeTree = asset.getTypeTree();

    // assets with just one object can't be split any further
    if (pathTable.size() == 1) {
      L.warning("Asset doesn't contain sub-assets!");
      return;
    }

    for (ObjectPath path : pathTable) {
      // skip filtered classes
      if (cf != null && !cf.accept(path)) {
        continue;
      }

      String className = ClassID.getNameForID(path.getClassID(), true);

      AssetFile subAsset = new AssetFile();
      subAsset.getHeader().setFormat(asset.getHeader().getFormat());

      ObjectPath subFieldPath = new ObjectPath();
      subFieldPath.setClassID1(path.getClassID1());
      subFieldPath.setClassID2(path.getClassID2());
      subFieldPath.setLength(path.getLength());
      subFieldPath.setOffset(0);
      subFieldPath.setPathID(1);
      subAsset.getPaths().add(subFieldPath);

      TypeTree subTypeTree = subAsset.getTypeTree();
      subTypeTree.setEngineVersion(typeTree.getEngineVersion());
      subTypeTree.setVersion(-2);
      subTypeTree.setFormat(typeTree.getFormat());
      subTypeTree.getFields().put(path.getClassID(), typeTree.getFields().get(path.getClassID()));

      subAsset.setDataBuffer(asset.getPathBuffer(path));

      Path subAssetDir = outputDir.resolve(className);
      if (Files.notExists(subAssetDir)) {
        Files.createDirectories(subAssetDir);
      }

      // probe asset name
      String subAssetName = getObjectName(asset, path);
      if (subAssetName != null) {
        // remove any chars that could cause troubles on various file systems
        subAssetName = FilenameSanitizer.sanitizeName(subAssetName);
      } else {
        // use numeric names
        subAssetName = String.format("%06d", path.getPathID());
      }
      subAssetName += ".asset";

      Path subAssetFile = subAssetDir.resolve(subAssetName);
      if (Files.notExists(subAssetFile)) {
        L.log(Level.INFO, "Writing {0}", subAssetFile);
        subAsset.save(subAssetFile);
      }
    }
  }
示例#28
0
  /**
   * Method description
   *
   * @param app
   * @param net
   * @throws SSLException
   */
  public void wrap(ByteBuffer app, ByteBuffer net) throws SSLException {
    tlsEngineResult = tlsEngine.wrap(app, net);

    if (log.isLoggable(Level.FINEST)) {
      log.log(
          Level.FINEST,
          "{0}, tlsEngineRsult.getStatus() = {1}, tlsEngineRsult.getHandshakeStatus() = {2}",
          new Object[] {
            debugId, tlsEngineResult.getStatus(), tlsEngineResult.getHandshakeStatus()
          });
    }

    if (tlsEngineResult.getHandshakeStatus() == SSLEngineResult.HandshakeStatus.FINISHED) {
      if (eventHandler != null) {
        eventHandler.handshakeCompleted(this);
      }
    }

    if (tlsEngineResult.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
      doTasks();

      if (log.isLoggable(Level.FINEST)) {
        log.log(
            Level.FINEST,
            "doTasks(): {0}, {1}",
            new Object[] {tlsEngine.getHandshakeStatus(), debugId});
      }
    }
  }
  private void btnViewItemsActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnViewItemsActionPerformed

    cmbItems.removeAllItems();

    // Deserializing itemlist
    try {
      itemList = this.itemService.Deserialize(ItemFile);
    } catch (IOException ex) {
      Logger.getLogger(SiteManagerUI.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ClassNotFoundException ex) {
      Logger.getLogger(SiteManagerUI.class.getName()).log(Level.SEVERE, null, ex);
    }

    // adding the item to the combo box
    for (Item item : itemList) {
      cmbItems.addItem(
          item.getItemID()
              + " "
              + item.getItemName()
              + " ("
              + item.getItemType()
              + ") "
              + "Price = "
              + item.getItemPrice());
    }
  } // GEN-LAST:event_btnViewItemsActionPerformed
 static {
   try {
     logger =
         Logger.getLogger(
             "au.com.leighton.portal.peoplefinder.model.peopledetail.Phogetpersondetail_client_ep");
     URL baseUrl = Phogetpersondetail_client_ep.class.getResource(".");
     if (baseUrl == null) {
       wsdlLocationURL =
           Phogetpersondetail_client_ep.class.getResource(
               "http://lclxsoa11gdev.lc.local:7001/soa-infra/services/default/PhoGetPersonDetail/phogetpersondetail_client_ep?WSDL");
       if (wsdlLocationURL == null) {
         baseUrl = new File(".").toURL();
         wsdlLocationURL =
             new URL(
                 baseUrl,
                 "http://lclxsoa11gdev.lc.local:7001/soa-infra/services/default/PhoGetPersonDetail/phogetpersondetail_client_ep?WSDL");
       }
     } else {
       if (!baseUrl.getPath().endsWith("/")) {
         baseUrl = new URL(baseUrl, baseUrl.getPath() + "/");
       }
       wsdlLocationURL =
           new URL(
               baseUrl,
               "http://lclxsoa11gdev.lc.local:7001/soa-infra/services/default/PhoGetPersonDetail/phogetpersondetail_client_ep?WSDL");
     }
   } catch (MalformedURLException e) {
     logger.log(
         Level.ALL,
         "Failed to create wsdlLocationURL using http://lclxsoa11gdev.lc.local:7001/soa-infra/services/default/PhoGetPersonDetail/phogetpersondetail_client_ep?WSDL",
         e);
   }
 }