Search in sources :

Example 1 with ServiceException

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

the class ManualJobServiceImpl method execute.

@WebMethod
@POST
@Path("/executeJob/{uploadOid}")
@Override
public String execute(@WebParam(name = "uploadOid") @PathParam("uploadOid") String uploadOid) throws Exception {
    SysExprJobLogVO result = null;
    Subject subject = null;
    ObjectMapper objectMapper = new ObjectMapper();
    String exceptionMessage = "";
    try {
        Map<String, Object> dataMap = SystemExpressionJobUtils.getDecUploadOid(uploadOid);
        if (dataMap == null || StringUtils.isBlank((String) dataMap.get("accountId")) || StringUtils.isBlank((String) dataMap.get("sysExprJobOid"))) {
            log.error("no data accountId / sysExprJobOid");
            result = new SysExprJobLogVO();
            result.setFaultMsg("no data accountId / sysExprJobOid");
            return objectMapper.writeValueAsString(result);
        }
        String accountId = (String) dataMap.get("accountId");
        String sysExprJobOid = (String) dataMap.get("sysExprJobOid");
        ShiroLoginSupport loginSupport = new ShiroLoginSupport();
        subject = loginSupport.forceCreateLoginSubject(accountId);
        result = SystemExpressionJobUtils.executeJobForManual(sysExprJobOid);
    } catch (ServiceException se) {
        se.printStackTrace();
        exceptionMessage = se.getMessage().toString();
    } catch (Exception e) {
        e.printStackTrace();
        if (e.getMessage() == null) {
            exceptionMessage = e.toString();
        } else {
            exceptionMessage = e.getMessage().toString();
        }
    } finally {
        if (result == null) {
            result = new SysExprJobLogVO();
        }
        if (subject != null) {
            subject.logout();
        }
        if (!StringUtils.isBlank(exceptionMessage) && StringUtils.isBlank(result.getFaultMsg())) {
            result.setFaultMsg(exceptionMessage);
        }
    }
    return objectMapper.writeValueAsString(result);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysExprJobLogVO(com.netsteadfast.greenstep.vo.SysExprJobLogVO) Subject(org.apache.shiro.subject.Subject) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ShiroLoginSupport(com.netsteadfast.greenstep.sys.ShiroLoginSupport) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 2 with ServiceException

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

the class BaseService method ibatisSelectOneByValue.

@Transactional(isolation = Isolation.READ_COMMITTED, timeout = 25, readOnly = true)
public DefaultResult<E> ibatisSelectOneByValue(E valueObj) throws ServiceException, Exception {
    if (null == valueObj) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }
    DefaultResult<E> result = new DefaultResult<E>();
    E searchResult = this.getBaseDataAccessObject().ibatisSelectOneByValue(valueObj);
    if (searchResult != null) {
        result.setValue(searchResult);
    } else {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
    }
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with ServiceException

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

the class SystemExpressionJobUtils method getEncUploadOid.

public static String getEncUploadOid(String accountId, String sysExprJobOid) throws ServiceException, Exception {
    if (StringUtils.isBlank(accountId) || StringUtils.isBlank(sysExprJobOid)) {
        throw new Exception("error, accountId or sysExprJobOid value is blank!");
    }
    Map<String, Object> dataMap = new HashMap<String, Object>();
    dataMap.put("accountId", accountId);
    dataMap.put("sysExprJobOid", sysExprJobOid);
    ObjectMapper objectMapper = new ObjectMapper();
    String jsonData = objectMapper.writeValueAsString(dataMap);
    String uploadOid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, jsonData.getBytes(), SimpleUtils.getUUIDStr() + ".json");
    uploadOid = SimpleUtils.toHex(EncryptorUtils.encrypt(Constants.getEncryptorKey1(), Constants.getEncryptorKey2(), uploadOid));
    return uploadOid;
}
Also used : HashMap(java.util.HashMap) IOException(java.io.IOException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with ServiceException

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

the class SystemFormUtils method findTemplate.

public static SysFormTemplateVO findTemplate(String templateId) throws ServiceException, Exception {
    SysFormTemplateVO template = new SysFormTemplateVO();
    template.setTplId(templateId);
    DefaultResult<SysFormTemplateVO> result = sysFormTemplateService.findByUK(template);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    template = result.getValue();
    //this.writePage(template);		
    return template;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysFormTemplateVO(com.netsteadfast.greenstep.vo.SysFormTemplateVO)

Example 5 with ServiceException

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

the class SystemFtpClientUtils method findSysFtp.

public static SysFtpVO findSysFtp(String ftpId) throws ServiceException, Exception {
    SysFtpVO ftp = new SysFtpVO();
    ftp.setId(ftpId);
    DefaultResult<SysFtpVO> result = sysFtpService.findByUK(ftp);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    ftp = result.getValue();
    return ftp;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysFtpVO(com.netsteadfast.greenstep.vo.SysFtpVO)

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