Package cave.nice.testMessage.data

Examples of cave.nice.testMessage.data.Test


      throws WebApplicationException {
    DataManager dataManager = getDataManager();
    try {
      VerifiedAccount account = dataManager
          .getVerifiedAccount(emailAddress);
      Test test = dataManager.getTestOfAccount(account, challenge);
      dataManager.markTestAsAnswered(test, new Date());
      LOGGER.info("REST answer to the test with challenge '"
          + test.getChallenge() + "' of the email account '"
          + account.getEmailAddress() + "'");
    } catch (UknownTestChallengeException e) {
      throw new WebApplicationException(Response
          .status(Status.NOT_FOUND)
          .entity("No test with challenge '" + challenge
View Full Code Here


    DataManager dataManager = getDataManager();

    try {
      VerifiedAccount account = dataManager
          .getVerifiedAccount(emailAddress);
      Test newTest = dataManager.createTest(account, new Date(),
          challenge);

      if (sendTest) {
        Session session = Session.getDefaultInstance(new Properties(),
            null);
        Message msg = null;
        try {
          InternetAddress appInternetAddress = new InternetAddress(
              TestMessageConstants.TESTS_EMAIL_ADDRESS,
              TestMessageConstants.TEST_MESSAGE_SENDER_NAME);

          Map<String, Object> params = Maps.newHashMap();
          params.put("challenge", newTest.getChallenge());
          params.put(
              "url",
              "http://"
                  + SystemProperty.applicationId.get()
                  + ".appspot.com/answerTest.jsp?emailAddress="
                  + account.getEmailAddress() + "&challenge="
                  + newTest.getChallenge());

          String content = TemplateManager.getInstance(context)
              .applyTemplate(TemplateType.TEST_MESSAGE, params);

          msg = new MimeMessage(session);
          msg.setFrom(appInternetAddress);
          msg.addRecipient(Message.RecipientType.TO,
              account.getInternetAddress());
          msg.setReplyTo(new InternetAddress[] { appInternetAddress });
          msg.addHeader(
              TestMessageConstants.SMTP_HEADER_ACCOUNT_IDENTIFIER,
              KeyFactory.keyToString(account.getIdentifier()));
          msg.addHeader(
              TestMessageConstants.SMTP_HEADER_TEST_IDENTIFIER,
              KeyFactory.keyToString(newTest.getIdentifier()));
          msg.setSubject("Test Message on "
              + DateFormat.getInstance()
                  .format(newTest.getDate()));
          msg.setContent(content, "text/plain");
          Transport.send(msg);
        } catch (Exception e) {
          /*
           * Remove the test that was not successfully sent
View Full Code Here

    DataManager dataManager = getDataManager();
    try {
      VerifiedAccount account = dataManager
          .getVerifiedAccount(emailAddress);

      Test test = dataManager.getTestOfAccount(account, challenge);
      dataManager.removeTest(test);
      return Response.ok().build();
    } catch (UknownTestChallengeException e) {
      throw new WebApplicationException(Response
          .status(Status.NOT_MODIFIED)
View Full Code Here

  private void processSMTPTestAnswer(DataManager dataStoreManager,
      VerifiedAccount account, UUID testChallenge)
      throws UknownTestChallengeException,
      UnknownVerifiedAccountException, WrongAccountForTestException,
      CannotUpdateEntityException, TestAlreadyAnsweredException {
    Test openTest = dataStoreManager.getTestOfAccount(account,
        testChallenge);

    LOGGER.info("SMTP answer to the test '"
        + KeyFactory.keyToString(openTest.getIdentifier())
        + "' of the email account '"
        + openTest.getAccount().getEmailAddress() + "'");

    dataStoreManager.markTestAsAnswered(openTest, new Date());
  }
View Full Code Here

TOP

Related Classes of cave.nice.testMessage.data.Test

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.