Search in sources :

Example 41 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.

the class SystemMessageNoticeLogicServiceImpl method update.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysMsgNoticeVO> update(SysMsgNoticeVO notice, String accountOid) throws ServiceException, Exception {
    if (notice == null || super.isBlank(notice.getOid())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<SysMsgNoticeVO> oldResult = this.sysMsgNoticeService.findObjectByOid(notice);
    if (oldResult.getValue() == null) {
        throw new ServiceException(oldResult.getSystemMessage().getValue());
    }
    notice.setNoticeId(oldResult.getValue().getNoticeId());
    notice.setMsgId(oldResult.getValue().getMsgId());
    notice.setToAccount("*");
    if (!super.isNoSelectId(accountOid) && !"*".equals(accountOid)) {
        AccountVO account = new AccountVO();
        account.setOid(accountOid);
        DefaultResult<AccountVO> aResult = this.accountService.findObjectByOid(account);
        if (aResult.getValue() == null) {
            throw new ServiceException(aResult.getSystemMessage().getValue());
        }
        account = aResult.getValue();
        notice.setToAccount(account.getAccount());
    }
    if (super.defaultString(notice.getMessage()).length() > MAX_MESSAGE_LENGTH) {
        notice.setMessage(notice.getMessage().substring(0, MAX_MESSAGE_LENGTH));
    }
    return this.sysMsgNoticeService.updateObject(notice);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) AccountVO(com.netsteadfast.greenstep.vo.AccountVO) SysMsgNoticeVO(com.netsteadfast.greenstep.vo.SysMsgNoticeVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 42 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.

the class SystemProgramLogicServiceImpl method update.

/**
	 * 更新 TB_SYS_PROG 資料
	 * 
	 * @param sysProg
	 * @param sysOid
	 * @param iconOid
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysProgVO> update(SysProgVO sysProg, String sysOid, String iconOid) throws ServiceException, Exception {
    if (sysProg == null || StringUtils.isBlank(sysProg.getOid())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    SysVO sys = new SysVO();
    sys.setOid(sysOid);
    DefaultResult<SysVO> sysResult = this.sysService.findObjectByOid(sys);
    if (sysResult.getValue() == null) {
        throw new ServiceException(sysResult.getSystemMessage().getValue());
    }
    sys = sysResult.getValue();
    SysIconVO sysIcon = new SysIconVO();
    sysIcon.setOid(iconOid);
    DefaultResult<SysIconVO> iconResult = this.sysIconService.findObjectByOid(sysIcon);
    if (iconResult.getValue() == null) {
        throw new ServiceException(iconResult.getSystemMessage().getValue());
    }
    sysIcon = iconResult.getValue();
    sysProg.setProgSystem(sys.getSysId());
    sysProg.setIcon(sysIcon.getIconId());
    return this.sysProgService.updateObject(sysProg);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysVO(com.netsteadfast.greenstep.vo.SysVO) SysIconVO(com.netsteadfast.greenstep.vo.SysIconVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 43 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.

the class RoleLogicServiceImpl method updateMenuRole.

/**
	 * 更新存在選單中程式的選單所屬 role
	 * 
	 * @param progOid
	 * @param roles
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> updateMenuRole(String progOid, List<String> roles) throws ServiceException, Exception {
    if (super.isBlank(progOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    SysProgVO sysProg = new SysProgVO();
    sysProg.setOid(progOid);
    DefaultResult<SysProgVO> spResult = this.sysProgService.findObjectByOid(sysProg);
    if (spResult.getValue() == null) {
        throw new ServiceException(spResult.getSystemMessage().getValue());
    }
    sysProg = spResult.getValue();
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    result.setValue(false);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_FAIL)));
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("progId", sysProg.getProgId());
    List<TbSysMenuRole> sysMenuRoleList = this.sysMenuRoleService.findListByParams(params);
    for (int i = 0; sysMenuRoleList != null && i < sysMenuRoleList.size(); i++) {
        TbSysMenuRole sysMenuRole = sysMenuRoleList.get(i);
        this.sysMenuRoleService.delete(sysMenuRole);
    }
    for (int i = 0; roles != null && i < roles.size(); i++) {
        String roleOid = roles.get(i).trim();
        if (super.isBlank(roleOid)) {
            continue;
        }
        RoleVO role = new RoleVO();
        role.setOid(roleOid);
        DefaultResult<RoleVO> rResult = this.roleService.findObjectByOid(role);
        if (rResult.getValue() == null) {
            throw new ServiceException(rResult.getSystemMessage().getValue());
        }
        role = rResult.getValue();
        SysMenuRoleVO sysMenuRole = new SysMenuRoleVO();
        sysMenuRole.setProgId(sysProg.getProgId());
        sysMenuRole.setRole(role.getRole());
        DefaultResult<SysMenuRoleVO> smrResult = this.sysMenuRoleService.saveObject(sysMenuRole);
        if (smrResult.getValue() == null) {
            throw new ServiceException(smrResult.getSystemMessage().getValue());
        }
    }
    result.setValue(true);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    return result;
}
Also used : SysMenuRoleVO(com.netsteadfast.greenstep.vo.SysMenuRoleVO) SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) TbSysMenuRole(com.netsteadfast.greenstep.po.hbm.TbSysMenuRole) HashMap(java.util.HashMap) SysProgVO(com.netsteadfast.greenstep.vo.SysProgVO) UserRoleVO(com.netsteadfast.greenstep.vo.UserRoleVO) SysMenuRoleVO(com.netsteadfast.greenstep.vo.SysMenuRoleVO) RoleVO(com.netsteadfast.greenstep.vo.RoleVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 44 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.

the class CxfServerBean method shutdownOrReloadCallOneSystem.

@SuppressWarnings("unchecked")
public static Map<String, Object> shutdownOrReloadCallOneSystem(HttpServletRequest request, String system, String type) throws ServiceException, Exception {
    if (StringUtils.isBlank(system) || StringUtils.isBlank(type)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    String urlStr = ApplicationSiteUtils.getBasePath(system, request) + "config-services?type=" + type + "&value=" + createParamValue();
    logger.info("shutdownOrReloadCallSystem , url=" + urlStr);
    HttpClient client = new HttpClient();
    HttpMethod method = new GetMethod(urlStr);
    client.executeMethod(method);
    byte[] responseBody = method.getResponseBody();
    if (null == responseBody) {
        throw new Exception("no response!");
    }
    String content = new String(responseBody, Constants.BASE_ENCODING);
    logger.info("shutdownOrReloadCallSystem , system=" + system + " , type=" + type + " , response=" + content);
    ObjectMapper mapper = new ObjectMapper();
    Map<String, Object> dataMap = null;
    try {
        dataMap = (Map<String, Object>) mapper.readValue(content, HashMap.class);
    } catch (JsonParseException e) {
        logger.error(e.getMessage().toString());
    } catch (JsonMappingException e) {
        logger.error(e.getMessage().toString());
    }
    if (null == dataMap) {
        throw new Exception("response content error!");
    }
    return dataMap;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HttpClient(org.apache.commons.httpclient.HttpClient) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) GetMethod(org.apache.commons.httpclient.methods.GetMethod) JsonParseException(com.fasterxml.jackson.core.JsonParseException) HttpMethod(org.apache.commons.httpclient.HttpMethod) JsonParseException(com.fasterxml.jackson.core.JsonParseException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 45 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.

the class SystemFormLogicServiceImpl method createMethod.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysFormMethodVO> createMethod(SysFormMethodVO formMethod, String formOid) throws ServiceException, Exception {
    if (null == formMethod || super.isBlank(formOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    SysFormVO form = this.findForm(formOid);
    super.setStringValueMaxLength(formMethod, "description", MAX_DESCRIPTION_LENGTH);
    formMethod.setFormId(form.getFormId());
    return this.sysFormMethodService.saveObject(formMethod);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysFormVO(com.netsteadfast.greenstep.vo.SysFormVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)291 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)91 Transactional (org.springframework.transaction.annotation.Transactional)89 HashMap (java.util.HashMap)65 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)49 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)48 SysVO (com.netsteadfast.greenstep.vo.SysVO)30 IOException (java.io.IOException)24 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)20 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)19 List (java.util.List)19 Map (java.util.Map)19 ArrayList (java.util.ArrayList)17 LinkedHashMap (java.util.LinkedHashMap)17 OrganizationVO (com.netsteadfast.greenstep.vo.OrganizationVO)16 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)15 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)15 SysUploadVO (com.netsteadfast.greenstep.vo.SysUploadVO)14 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)13 AccountVO (com.netsteadfast.greenstep.vo.AccountVO)12