@Bean(name = "mainDataSource")
  public DataSource dataSource() {

    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    try {
      dataSource.setDriverClass(env.getProperty("jdbc.driverClassName"));
    } catch (PropertyVetoException e) {
      // TODO Auto-generated catch block
      logger.info("PropertyVetoException : {}", e.getMessage());
    }
    dataSource.setJdbcUrl(env.getProperty("jdbc.url"));
    dataSource.setUser(env.getProperty("jdbc.username"));
    dataSource.setPassword(env.getProperty("jdbc.password"));
    dataSource.setAcquireIncrement(20);
    dataSource.setAcquireRetryAttempts(30);
    dataSource.setAcquireRetryDelay(1000);
    dataSource.setAutoCommitOnClose(false);
    dataSource.setDebugUnreturnedConnectionStackTraces(true);
    dataSource.setIdleConnectionTestPeriod(100);
    dataSource.setInitialPoolSize(10);
    dataSource.setMaxConnectionAge(1000);
    dataSource.setMaxIdleTime(200);
    dataSource.setMaxIdleTimeExcessConnections(3600);
    dataSource.setMaxPoolSize(10);
    dataSource.setMinPoolSize(2);
    dataSource.setPreferredTestQuery("select 1");
    dataSource.setTestConnectionOnCheckin(false);
    dataSource.setUnreturnedConnectionTimeout(1000);
    return dataSource;
  }
Exemplo n.º 2
0
 /**
  * Delete the bean after all the checking has been done.
  *
  * <p>Separate so that it can be easily subclassed if other functionality is needed.
  */
 void doDelete(NamedBean bean) {
   try {
     getManager().deleteBean(bean, "DoDelete");
   } catch (PropertyVetoException e) {
     // At this stage the DoDelete shouldn't fail, as we have already done a can delete, which
     // would trigger a veto
     log.error(e.getMessage());
   }
 }
  // This function will get the advisor details from the database depending upon the username
  // entered by the advisor in the forgot password form
  public AdvisorProfileDTO getForgotPasswordDetails(String userName, String register) {

    logger.info("Entered getForgotPasswordDetails method of ForgotPasswordDAO");

    PreparedStatement pstmt;
    ResultSet results = null;
    String query = "";
    AdvisorProfileDTO profile = new AdvisorProfileDTO();
    Boolean flag = true;
    try {
      conn = ConnectionFactory.getConnection();
      conn.setAutoCommit(false);
      if (register.equals("true")) {
        query = "SELECT ADVISOR_ID,EMAIL FROM advisordetails WHERE EMAIL = ?";
      } else {
        query = "SELECT ADVISOR_ID,EMAIL FROM advisordetails WHERE EMAIL = ? AND ISACTIVE= ?";
      }
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, userName);
      if (!register.equals("true")) {
        pstmt.setBoolean(2, flag);
      }
      results = pstmt.executeQuery();
      if (results.first()) {
        profile.setAdvisorId(results.getInt("ADVISOR_ID"));
        profile.setEmail(results.getString("EMAIL"));
      }
      logger.info("Entered getForgotPasswordDetails method of ForgotPasswordDAO");
    } catch (SQLException e) {
      logger.error(
          "getForgotPasswordDetails method of ForgotPasswordDAO threw error:" + e.getMessage());
      e.printStackTrace();
    } catch (IOException e) {
      logger.error(
          "getForgotPasswordDetails method of ForgotPasswordDAO threw error:" + e.getMessage());
      e.printStackTrace();
    } catch (PropertyVetoException e) {
      logger.error(
          "getForgotPasswordDetails method of ForgotPasswordDAO threw error:" + e.getMessage());
      e.printStackTrace();
    } finally {
      try {
        conn.close();
      } catch (SQLException e) {
        logger.error(
            "getForgotPasswordDetails method of ForgotPasswordDAO threw error:" + e.getMessage());
        e.printStackTrace();
      }
    }

    return profile;
  }
  /**
   * maximizes the internal frame to the viewport bounds rather than the desktop bounds
   *
   * @param f the internal frame being maximized
   */
  public void maximizeFrame(JInternalFrame f) {

    Rectangle p = desktopPane.getScrollPaneRectangle();
    f.setNormalBounds(f.getBounds());
    setBoundsForFrame(f, p.x, p.y, p.width, p.height);
    try {
      f.setSelected(true);
    } catch (PropertyVetoException pve) {
      System.out.println(pve.getMessage());
    }

    removeIconFor(f);
  }
 @VisibleForTesting
 void failIfVetoed(
     JInternalFrame internalFrame, JInternalFrameAction action, UnexpectedException unexpected) {
   PropertyVetoException vetoError = vetoFrom(unexpected);
   if (vetoError == null) return;
   throw actionFailure(
       concat(
           action.name,
           " of ",
           format(internalFrame),
           " was vetoed: <",
           vetoError.getMessage(),
           ">"));
 }
 @VisibleForTesting
 void failIfVetoed(
     @Nonnull JInternalFrame internalFrame,
     @Nonnull JInternalFrameAction action,
     @Nonnull UnexpectedException unexpected) {
   PropertyVetoException vetoError = vetoFrom(unexpected);
   if (vetoError == null) {
     return;
   }
   String msg =
       String.format(
           "%s of %s was vetoed: <%s>",
           action.name, format(internalFrame), vetoError.getMessage());
   throw actionFailure(msg);
 }
Exemplo n.º 7
0
 private void abrirGUICadastroEspeciePagamento(EspeciePagamento especiepagamento) {
   if ((guiCadastroEspeciePagamento == null) || (!guiCadastroEspeciePagamento.isVisible())) {
     guiCadastroEspeciePagamento = new GUICadastroEspeciePagamento();
     OuvinteEspeciePagamento ouvinte = new OuvinteEspeciePagamento(guiCadastroEspeciePagamento);
     this.getParent().add(guiCadastroEspeciePagamento);
     guiCadastroEspeciePagamento.setPosicao();
     guiCadastroEspeciePagamento.setVisible(true);
     guiCadastroEspeciePagamento.setEspeciePagamento(especiepagamento);
   }
   try {
     guiCadastroEspeciePagamento.setSelected(true);
   } catch (PropertyVetoException exc) {
     StringBuffer mensagem = new StringBuffer();
     mensagem.append("Não foi possível selecionar a janela de cadastro de especie pagamento!");
     mensagem.append("\nMotivo: " + exc.getMessage());
     GUIMensagem.exibirMensagem(mensagem.toString(), "DukeClube - Cadastro desócio", true);
   }
 }
  // This function returns the timestamp of the advisor to determine whether the link on
  // the mail of the advisor is valid or not
  public Timestamp getAdvisorTimestamp(String advisorId) {

    logger.info("Entered getAdvisorTimestamp method of ForgotPasswordDAO");

    PreparedStatement pstmt;
    ResultSet results = null;
    Timestamp time = null;
    Boolean exist = false;
    try {
      conn = ConnectionFactory.getConnection();
      conn.setAutoCommit(false);
      String query = "SELECT * FROM forgotpassword_admin WHERE ADVISOR_ID = ?";
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, advisorId);
      results = pstmt.executeQuery();
      exist = results.next();
      if (exist) {
        time = results.getTimestamp("TIME");
      }
      logger.info("Entered getAdvisorTimestamp method of ForgotPasswordDAO");
    } catch (SQLException e) {
      logger.error("getAdvisorTimestamp method of ForgotPasswordDAO threw error:" + e.getMessage());
      e.printStackTrace();
    } catch (IOException e) {
      logger.error("getAdvisorTimestamp method of ForgotPasswordDAO threw error:" + e.getMessage());
      e.printStackTrace();
    } catch (PropertyVetoException e) {
      logger.error("getAdvisorTimestamp method of ForgotPasswordDAO threw error:" + e.getMessage());
      e.printStackTrace();
    } finally {
      try {
        conn.close();
      } catch (SQLException e) {
        logger.error(
            "getAdvisorTimestamp method of ForgotPasswordDAO threw error:" + e.getMessage());
        e.printStackTrace();
      }
    }
    logger.info("Exit checkLinkValid method of ForgotPasswordDAO");
    return time;
  }
Exemplo n.º 9
0
  public void setSelectedTaskJarToSig() {
    String strMethod = "setSelectedTaskJarToSig()";

    IFAbs ifeTarget = null;

    for (int i = 0; i < super.getComponentCount(); i++) {
      Object objCur = super.getComponent(i);

      if (!(objCur instanceof IFAbs)) continue;

      IFAbs ifeCur = (IFAbs) objCur;

      if (ifeCur instanceof IFKstOpenJarVerif) {
        ifeTarget = ifeCur;
        continue;
      }

      if (ifeCur.isVisible()) ifeCur.setVisible(false);
    }

    if (ifeTarget == null) // !! BUG
    return;

    if (ifeTarget.isIcon()) {
      try {
        ifeTarget.setIcon(false);
      } catch (PropertyVetoException ex) {
        ex.printStackTrace();
        MySystem.s_printOutExit(this, strMethod, ex.getMessage() + "\n exiting");
      }
    }

    if (!ifeTarget.isVisible()) ifeTarget.setVisible(true);

    ifeTarget.toFront();
  }
Exemplo n.º 10
0
    @Override
    public Void doInBackground() throws Exception {
      StringBuilder message = new StringBuilder();
      try {
        getManager().deleteBean(t, "CanDelete"); // IN18N
      } catch (PropertyVetoException e) {
        if (e.getPropertyChangeEvent().getPropertyName().equals("DoNotDelete")) { // IN18N
          log.warn(e.getMessage());
          message.append(
              Bundle.getMessage(
                  "VetoDeleteBean",
                  t.getBeanType(),
                  t.getFullyFormattedDisplayName(),
                  e.getMessage()));
          JOptionPane.showMessageDialog(
              null,
              message.toString(),
              Bundle.getMessage("WarningTitle"),
              JOptionPane.ERROR_MESSAGE);
          return null;
        }
        message.append(e.getMessage());
      }
      int count = t.getNumPropertyChangeListeners();
      if (log.isDebugEnabled()) {
        log.debug("Delete with " + count);
      }
      if (getDisplayDeleteMsg() == 0x02 && message.toString().equals("")) {
        doDelete(t);
      } else {
        final JDialog dialog = new JDialog();
        dialog.setTitle(Bundle.getMessage("WarningTitle"));
        dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        JPanel container = new JPanel();
        container.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
        container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
        if (count > 0) { // warn of listeners attached before delete

          JLabel question =
              new JLabel(Bundle.getMessage("DeletePrompt", t.getFullyFormattedDisplayName()));
          question.setAlignmentX(Component.CENTER_ALIGNMENT);
          container.add(question);

          ArrayList<String> listenerRefs = t.getListenerRefs();
          if (listenerRefs.size() > 0) {
            ArrayList<String> listeners = new ArrayList<>();
            for (int i = 0; i < listenerRefs.size(); i++) {
              if (!listeners.contains(listenerRefs.get(i))) {
                listeners.add(listenerRefs.get(i));
              }
            }

            message.append("<br>");
            message.append(Bundle.getMessage("ReminderInUse", count));
            message.append("<ul>");
            for (int i = 0; i < listeners.size(); i++) {
              message.append("<li>");
              message.append(listeners.get(i));
              message.append("</li>");
            }
            message.append("</ul>");

            JEditorPane pane = new JEditorPane();
            pane.setContentType("text/html");
            pane.setText("<html>" + message.toString() + "</html>");
            pane.setEditable(false);
            JScrollPane jScrollPane = new JScrollPane(pane);
            container.add(jScrollPane);
          }
        } else {
          String msg =
              MessageFormat.format(
                  Bundle.getMessage("DeletePrompt"), new Object[] {t.getSystemName()});
          JLabel question = new JLabel(msg);
          question.setAlignmentX(Component.CENTER_ALIGNMENT);
          container.add(question);
        }

        final JCheckBox remember = new JCheckBox(Bundle.getMessage("MessageRememberSetting"));
        remember.setFont(remember.getFont().deriveFont(10f));
        remember.setAlignmentX(Component.CENTER_ALIGNMENT);

        JButton yesButton = new JButton(Bundle.getMessage("ButtonYes"));
        JButton noButton = new JButton(Bundle.getMessage("ButtonNo"));
        JPanel button = new JPanel();
        button.setAlignmentX(Component.CENTER_ALIGNMENT);
        button.add(yesButton);
        button.add(noButton);
        container.add(button);

        noButton.addActionListener(
            (ActionEvent e) -> {
              // there is no point in remembering this the user will never be
              // able to delete a bean!
              dialog.dispose();
            });

        yesButton.addActionListener(
            (ActionEvent e) -> {
              if (remember.isSelected()) {
                setDisplayDeleteMsg(0x02);
              }
              doDelete(t);
              dialog.dispose();
            });
        container.add(remember);
        container.setAlignmentX(Component.CENTER_ALIGNMENT);
        container.setAlignmentY(Component.CENTER_ALIGNMENT);
        dialog.getContentPane().add(container);
        dialog.pack();
        dialog.setLocation(
            (Toolkit.getDefaultToolkit().getScreenSize().width) / 2 - dialog.getWidth() / 2,
            (Toolkit.getDefaultToolkit().getScreenSize().height) / 2 - dialog.getHeight() / 2);
        dialog.setModal(true);
        dialog.setVisible(true);
      }
      return null;
    }
Exemplo n.º 11
0
  /** Contains a CyNetworkView. */
  protected void createContainer(final CyNetworkView view) {
    if (networkViewMap.containsKey(view.getNetwork().getIdentifier())) return;

    // create a new InternalFrame and put the CyNetworkViews Component into
    // it
    final JInternalFrame iframe = new JInternalFrame(view.getTitle(), true, true, true, true);
    iframe.addInternalFrameListener(
        new InternalFrameAdapter() {
          public void internalFrameClosing(InternalFrameEvent e) {
            Cytoscape.destroyNetworkView(view);
          }
        });
    desktopPane.add(iframe);

    // code added to support layered canvas for each CyNetworkView
    if (view instanceof DGraphView) {
      final InternalFrameComponent internalFrameComp =
          new InternalFrameComponent(iframe.getLayeredPane(), (DGraphView) view);

      iframe.getContentPane().add(internalFrameComp);
      internalFrameComponentMap.put(view.getNetwork().getIdentifier(), internalFrameComp);
    } else {
      logger.info("NetworkViewManager.createContainer() - DGraphView not found!");
      iframe.getContentPane().add(view.getComponent());
    }

    iframe.pack();

    int x = 0;
    int y = 0;
    JInternalFrame refFrame = null;
    JInternalFrame[] allFrames = desktopPane.getAllFrames();

    if (allFrames.length > 1) {
      refFrame = allFrames[0];
    }

    if (refFrame != null) {
      x = refFrame.getLocation().x + 20;
      y = refFrame.getLocation().y + 20;
    }

    if (x > (desktopPane.getWidth() - MINIMUM_WIN_WIDTH)) {
      x = desktopPane.getWidth() - MINIMUM_WIN_WIDTH;
    }

    if (y > (desktopPane.getHeight() - MINIMUM_WIN_HEIGHT)) {
      y = desktopPane.getHeight() - MINIMUM_WIN_HEIGHT;
    }

    if (x < 0) {
      x = 0;
    }

    if (y < 0) {
      y = 0;
    }

    iframe.setBounds(x, y, 400, 400);

    // maximize the frame if the specified property is set
    try {
      String max = CytoscapeInit.getProperties().getProperty("maximizeViewOnCreate");

      if ((max != null) && Boolean.parseBoolean(max)) iframe.setMaximum(true);
    } catch (PropertyVetoException pve) {
      logger.warn("Unable to maximize internal frame: " + pve.getMessage());
    }

    iframe.setVisible(true);
    iframe.addInternalFrameListener(this);
    iframe.setResizable(true);

    networkViewMap.put(view.getNetwork().getIdentifier(), iframe);
    componentMap.put(iframe, view.getNetwork().getIdentifier());

    firePropertyChange(
        CytoscapeDesktop.NETWORK_VIEW_FOCUSED, null, view.getNetwork().getIdentifier());
  }