Search in sources :

Example 1 with ServiceNullException

use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.

the class TempPicSerController method saveImg.

// /**
// * 验证图片文件的格式和大小
// *
// * @param imgFile
// * @return
// * @throws ServiceNullException
// */
// private boolean verifyImg(MultipartFile imgFile)
// throws ServiceNullException {
// // imgFile 不为空则进行验证
// if (null != imgFile && !imgFile.isEmpty()) {
// // 判断文件大小
// if (imgFile.getSize() > IMG_MAX_SIZE) {
// throw new ServiceNullException("图片大小不能超过" + IMG_MAX_SIZE + "K");
// }
// // 判断图片格式
// String imgType = imgFile.getOriginalFilename();
// int index = imgType.lastIndexOf(".");
// if (index < 0)
// throw new ServiceNullException("图片类型不支持");
// imgType = imgType.substring(index + 1);
// if ("jpg,png".contains(imgType.toLowerCase())) {
// return true;
// }
// }
// return false;
// }
private File saveImg(File imgDir, MultipartFile file, String fileBase64, String itemType) throws IOException, ServiceNullException, UserInfoServiceException {
    String filename = System.currentTimeMillis() + itemType + TempPicService.JPG;
    // 创建磁盘文件
    File imgFile = new File(imgDir, filename);
    if (file != null && !file.isEmpty())
        file.transferTo(imgFile);
    else if (StringUtils.isNotBlank(fileBase64)) {
        imageByBase64.saveImage(fileBase64, imgFile);
        if (imgFile.length() > IMG_MAX_SIZE) {
            FileUtils.deleteQuietly(new File(imgDir, filename));
            throw new ServiceNullException("图片大小不能超过" + (IMG_MAX_SIZE / 1024) + "K");
        }
    } else
        return null;
    return imgFile;
}
Also used : ServiceNullException(com.itrus.portal.exception.ServiceNullException) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile)

Example 2 with ServiceNullException

use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.

the class SmsGateService method addSmsGate.

public Long addSmsGate(SmsGate smsGate) throws ServiceNullException, Exception {
    if (smsGate == null)
        throw new ServiceNullException("要添加短信网关配置为空");
    smsGate.setCreateTime(new Date());
    smsGate.setLastModify(smsGate.getCreateTime());
    // 加密账号密码和MD5key
    if (StringUtils.isNotBlank(smsGate.getAccountPass()))
        smsGate.setAccountPass(AESencrp.encrypt(smsGate.getAccountPass(), dbEncKey));
    if (StringUtils.isNotBlank(smsGate.getMd5Key()))
        smsGate.setMd5Key(AESencrp.encrypt(smsGate.getMd5Key(), dbEncKey));
    if (StringUtils.isNotBlank(smsGate.getEmayPass()))
        smsGate.setEmayPass(AESencrp.encrypt(smsGate.getEmayPass(), dbEncKey));
    sqlSession.insert("com.itrus.portal.db.SmsGateMapper.insert", smsGate);
    return smsGate.getId();
}
Also used : ServiceNullException(com.itrus.portal.exception.ServiceNullException) Date(java.util.Date)

Example 3 with ServiceNullException

use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.

the class SmsGateService method updateSmsGate.

public void updateSmsGate(SmsGate smsGate) throws ServiceNullException, Exception {
    if (smsGate == null || smsGate.getId() == null)
        throw new ServiceNullException("要更新短信网关配置为空");
    SmsGate smsGate1 = getSmsGateById(smsGate.getId());
    if (smsGate1 == null)
        throw new ServiceNullException("要更新短信网关配置不存在");
    // 加密账号密码和MD5key
    if (StringUtils.isNotBlank(smsGate.getAccountPass()))
        smsGate.setAccountPass(AESencrp.encrypt(smsGate.getAccountPass(), dbEncKey));
    if (StringUtils.isNotBlank(smsGate.getMd5Key()))
        smsGate.setMd5Key(AESencrp.encrypt(smsGate.getMd5Key(), dbEncKey));
    if (StringUtils.isNotBlank(smsGate.getEmayPass()))
        smsGate.setEmayPass(AESencrp.encrypt(smsGate.getEmayPass(), dbEncKey));
    smsGate.setLastModify(new Date());
    sqlSession.update("com.itrus.portal.db.SmsGateMapper.updateByPrimaryKeySelective", smsGate);
}
Also used : ServiceNullException(com.itrus.portal.exception.ServiceNullException) Date(java.util.Date) SmsGate(com.itrus.portal.db.SmsGate)

Example 4 with ServiceNullException

use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.

the class EmailServerService method updateEmailServer.

// 根据已有ID,更新邮箱配置信息
public void updateEmailServer(EmailServer emailServer) throws ServiceNullException, Exception {
    if (emailServer == null || emailServer.getId() == null)
        throw new ServiceNullException("要更新的邮件配置为空");
    EmailServer es1 = getEmailServerByID(emailServer.getId());
    if (es1 == null)
        throw new ServiceNullException("要更新的邮件配置不存在");
    // 如果密码不为空,则使用原来的密码
    if (StringUtils.isNotBlank(emailServer.getAccountPasswd()))
        emailServer.setAccountPasswd(AESencrp.encrypt(emailServer.getAccountPasswd(), dbEncKey));
    emailServer.setCreateTime(es1.getCreateTime());
    emailServer.setLastModify(new Date());
    sqlSession.update("com.itrus.portal.db.EmailServerMapper.updateByPrimaryKey", emailServer);
}
Also used : EmailServer(com.itrus.portal.db.EmailServer) ServiceNullException(com.itrus.portal.exception.ServiceNullException) Date(java.util.Date)

Example 5 with ServiceNullException

use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.

the class ActMsgCollectService method setAmTimes.

private void setAmTimes(ActivityMsgTemp activityMsg, String runStatus, Long lifeTime) throws ServiceNullException {
    // 若不为插入状态且持续时间为null或小于0或大于最大时间,则直接抛出异常,放弃处理
    if (!"0".equals(runStatus) && (lifeTime == null || lifeTime < 0 || lifeTime > MAX_LIFE_TIME)) {
        // logger.error("ServiceNullException: keySn= "+activityMsg.getKeySn()+", runStatus = " + runStatus + ", lifeTime = " + lifeTime);
        throw new ServiceNullException();
    }
    // 若为插入状态,但持续时间异常,则设置持续时间为0.增加终端统计的准确性
    if ("0".equals(runStatus) && (lifeTime == null || lifeTime < 0 || lifeTime > MAX_LIFE_TIME))
        lifeTime = 0l;
    // 客户端已持续时间
    long dt = lifeTime;
    ActivityMsgTempExample acte = new ActivityMsgTempExample();
    ActivityMsgTempExample.Criteria actec = acte.createCriteria();
    actec.andKeySnEqualTo(activityMsg.getKeySn());
    actec.andCertCnEqualTo(activityMsg.getCertCn());
    actec.andThreadIdEqualTo(activityMsg.getThreadId());
    ActivityMsgTemp am = sqlSession.selectOne("com.itrus.portal.db.ActivityMsgTempMapper.selectByExample", acte);
    Calendar calendar = Calendar.getInstance();
    // 数据库没有记录数据
    if (null == am) {
        long nowLong = calendar.getTimeInMillis();
        // 没有插入的数据,记录插入的数据
        if ("1".equals(runStatus)) {
            // 获取当前时间毫秒数
            calendar.setTimeInMillis(nowLong - dt);
            // 设置当前时间
            activityMsg.setCreateTime(calendar.getTime());
            // 先获取开始时间
            activityMsg.setOnLineTime(calendar.getTime());
            dt += ComNames.DELAY_TIME;
            calendar.setTimeInMillis(nowLong + dt);
            activityMsg.setOffLineTime(calendar.getTime());
            activityMsg.setLifeTime(activityMsg.getOffLineTime().getTime() - activityMsg.getOnLineTime().getTime());
        } else if ("2".equals(runStatus)) {
            // 没有插入的数据,只有拔出的数据
            // 设置当前时间为结束时间
            activityMsg.setOffLineTime(calendar.getTime());
            calendar.setTimeInMillis(nowLong - dt);
            // 设置当前时间
            activityMsg.setCreateTime(calendar.getTime());
            // 先获取开始时间
            activityMsg.setOnLineTime(calendar.getTime());
            activityMsg.setLifeTime(activityMsg.getOffLineTime().getTime() - activityMsg.getOnLineTime().getTime());
        }
    } else {
        // 客户端已持续时间 0:key插入状态 1:key持续插入状态 2:key拔出状态
        activityMsg.setCreateTime(null == am.getCreateTime() ? calendar.getTime() : am.getCreateTime());
        activityMsg.setOnLineTime(null == am.getOnLineTime() ? calendar.getTime() : am.getOnLineTime());
        if ("2".equals(runStatus)) {
            activityMsg.setCertCn("".equals(activityMsg.getCertCn()) ? am.getCertCn() : activityMsg.getCertCn());
            calendar.setTimeInMillis(am.getOnLineTime().getTime() + dt);
            activityMsg.setOffLineTime(calendar.getTime());
            activityMsg.setLifeTime(activityMsg.getOffLineTime().getTime() - activityMsg.getOnLineTime().getTime());
        } else if ("1".equals(runStatus)) {
            calendar.setTimeInMillis(calendar.getTimeInMillis() + dt);
            activityMsg.setOffLineTime(calendar.getTime());
            activityMsg.setLifeTime(activityMsg.getOffLineTime().getTime() - activityMsg.getOnLineTime().getTime());
        }
    }
}
Also used : ActivityMsgTemp(com.itrus.portal.db.ActivityMsgTemp) Calendar(java.util.Calendar) ActivityMsgTempExample(com.itrus.portal.db.ActivityMsgTempExample) ServiceNullException(com.itrus.portal.exception.ServiceNullException)

Aggregations

ServiceNullException (com.itrus.portal.exception.ServiceNullException)15 Date (java.util.Date)7 ActivityMsgTemp (com.itrus.portal.db.ActivityMsgTemp)3 File (java.io.File)3 IOException (java.io.IOException)3 SmsGate (com.itrus.portal.db.SmsGate)2 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)2 FileOutputStream (java.io.FileOutputStream)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 MultipartFile (org.springframework.web.multipart.MultipartFile)2 SigningServerException (com.itrus.cryptorole.SigningServerException)1 ActivityMsgTempExample (com.itrus.portal.db.ActivityMsgTempExample)1 EditBill (com.itrus.portal.db.EditBill)1 EmailServer (com.itrus.portal.db.EmailServer)1 EvidenceCert (com.itrus.portal.db.EvidenceCert)1 ProjectKeyInfo (com.itrus.portal.db.ProjectKeyInfo)1 RealNameAuthentication (com.itrus.portal.db.RealNameAuthentication)1 ReceiptConfig (com.itrus.portal.db.ReceiptConfig)1 SysRegion (com.itrus.portal.db.SysRegion)1 SysRegionExample (com.itrus.portal.db.SysRegionExample)1