Search in sources :

Example 1 with ServiceException

use of org.neusoft.neubbs.exception.ServiceException in project neubbs by nuitcoder.

the class EmailServiceImpl method sendAccountActivateMail.

@Override
public void sendAccountActivateMail(String email, String emailToken) {
    String activateUrl = neubbsConfig.getAccountApiVaslidateUrl();
    if (activateUrl == null) {
        throw new ServiceException(ApiMessage.UNKNOWN_ERROR).log(LogWarnEnum.ES1);
    }
    String emailContent = StringUtil.generateActivateMailHtmlContent(activateUrl + emailToken);
    this.send(SetConst.EMAIL_SENDER_NAME, email, SetConst.EMAIL_SUBJECT_ACTIVATE, emailContent);
}
Also used : ServiceException(org.neusoft.neubbs.exception.ServiceException)

Example 2 with ServiceException

use of org.neusoft.neubbs.exception.ServiceException in project neubbs by nuitcoder.

the class UserServiceImpl method alterUserActivateStateByEmailToken.

@Override
public UserDO alterUserActivateStateByEmailToken(String emailToken) {
    // parse token
    String plainText = SecretUtil.decodeBase64(emailToken);
    String[] array = plainText.split("-");
    if (array.length != SetConst.LENGTH_TWO) {
        throw new ServiceException(ApiMessage.INVALID_TOKEN).log(LogWarnEnum.US12);
    }
    String email = array[0];
    if (!PatternUtil.matchEmail(email)) {
        throw new ServiceException(ApiMessage.INVALID_TOKEN).log(LogWarnEnum.US12);
    }
    String expireTime = array[1];
    if (StringUtil.isExpire(expireTime)) {
        throw new ServiceException(ApiMessage.LINK_INVALID).log(LogWarnEnum.US4);
    }
    this.confirmUserActivatedByEmail(email);
    if (userDAO.updateUserStateToActivateByEmail(email) == 0) {
        throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.US2);
    }
    return userDAO.getUserByEmail(email);
}
Also used : ServiceException(org.neusoft.neubbs.exception.ServiceException)

Example 3 with ServiceException

use of org.neusoft.neubbs.exception.ServiceException in project neubbs by nuitcoder.

the class TopicServiceImpl method alterTopicContent.

@Override
public void alterTopicContent(int topicId, String newCategoryNick, String newTitle, String newTopicContent) {
    this.getTopicNotNull(topicId);
    this.getTopicContentNotNull(topicId);
    TopicCategoryDO category = this.getTopicCategoryNotNullByNick(newCategoryNick);
    // update forum_topic 'fucg_id', 'ft_title'
    if (topicDAO.updateCategoryById(topicId, category.getId()) == 0 || topicDAO.updateTitleById(topicId, newTitle) == 0) {
        throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.TS7);
    }
    // update forum_topic_content 'ftc_content'
    if (topicContentDAO.updateContentByTopicId(topicId, newTopicContent) == 0) {
        throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.TS8);
    }
}
Also used : ServiceException(org.neusoft.neubbs.exception.ServiceException) TopicCategoryDO(org.neusoft.neubbs.entity.TopicCategoryDO)

Example 4 with ServiceException

use of org.neusoft.neubbs.exception.ServiceException in project neubbs by nuitcoder.

the class HttpServiceImpl method outputCaptchaImage.

@Override
public void outputCaptchaImage(BufferedImage captchaImage) {
    try {
        ServletOutputStream outputStream = PublicParamsUtil.getResponse().getOutputStream();
        ImageIO.write(captchaImage, "jpg", outputStream);
        outputStream.flush();
        outputStream.close();
    } catch (IOException e) {
        throw new ServiceException(ApiMessage.GENERATE_CAPTCHA_FAIL).log(LogWarnEnum.US17);
    }
}
Also used : ServiceException(org.neusoft.neubbs.exception.ServiceException) ServletOutputStream(javax.servlet.ServletOutputStream) IOException(java.io.IOException)

Example 5 with ServiceException

use of org.neusoft.neubbs.exception.ServiceException in project neubbs by nuitcoder.

the class UserServiceImpl method loginVerification.

@Override
public UserDO loginVerification(String username, String password) {
    // check username, get user information
    UserDO user;
    try {
        user = this.getUserInfoByName(username);
    } catch (ServiceException ae) {
        // prevent user know real error message
        throw new ServiceException(ApiMessage.USERNAME_OR_PASSWORD_INCORRECT).log(ae.getLog());
    }
    String cipherText = this.encryptUserPassword(password);
    if (!cipherText.equals(user.getPassword())) {
        throw new ServiceException(ApiMessage.USERNAME_OR_PASSWORD_INCORRECT).log(LogWarnEnum.US7);
    }
    return user;
}
Also used : ServiceException(org.neusoft.neubbs.exception.ServiceException) UserDO(org.neusoft.neubbs.entity.UserDO)

Aggregations

ServiceException (org.neusoft.neubbs.exception.ServiceException)16 TopicCategoryDO (org.neusoft.neubbs.entity.TopicCategoryDO)3 UserDO (org.neusoft.neubbs.entity.UserDO)3 TopicContentDO (org.neusoft.neubbs.entity.TopicContentDO)2 TopicDO (org.neusoft.neubbs.entity.TopicDO)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 TopicActionDO (org.neusoft.neubbs.entity.TopicActionDO)1 TopicReplyDO (org.neusoft.neubbs.entity.TopicReplyDO)1 UserActionDO (org.neusoft.neubbs.entity.UserActionDO)1