Search in sources :

Example 1 with ControllerException

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

the class BaseSupportAction method checkFields.

@Deprecated
protected void checkFields(String[] fieldsName, String[] msg, Class<IActionFieldsCheckUtils>[] checkUtilsClass, String[] methodsName, List<String> fieldsId) throws ControllerException, InstantiationException, IllegalAccessException {
    if (fieldsName == null || msg == null || checkUtilsClass == null || (fieldsName.length != msg.length) || (fieldsName.length != checkUtilsClass.length)) {
        throw new java.lang.IllegalArgumentException("check filed args error!");
    }
    StringBuilder exceptionMsg = new StringBuilder();
    for (int i = 0; i < fieldsName.length; i++) {
        String value = this.getFields().get(fieldsName[i]);
        IActionFieldsCheckUtils checkUtils = checkUtilsClass[i].newInstance();
        if (methodsName != null && methodsName.length == checkUtilsClass.length) {
            Method[] methods = checkUtils.getClass().getMethods();
            for (Method method : methods) {
                if (method.getName().equals(methodsName[i])) {
                    try {
                        if (!(Boolean) method.invoke(null, value)) {
                            if (fieldsId != null) {
                                fieldsId.add(fieldsName[i]);
                            }
                            exceptionMsg.append(msg[i]);
                        }
                    } catch (IllegalArgumentException e) {
                        e.printStackTrace();
                    } catch (InvocationTargetException e) {
                        e.printStackTrace();
                    }
                }
            }
        } else {
            if (!checkUtils.check(value)) {
                if (fieldsId != null) {
                    fieldsId.add(fieldsName[i]);
                }
                exceptionMsg.append(msg[i]);
            }
        }
    }
    if (exceptionMsg.length() > 0) {
        throw new ControllerException(exceptionMsg.toString());
    }
}
Also used : ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) Method(java.lang.reflect.Method) IActionFieldsCheckUtils(com.netsteadfast.greenstep.base.model.IActionFieldsCheckUtils) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with ControllerException

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

the class KpiReportContentQueryAction method loadContentFromUpload.

//	public static void main(String args[]) throws Exception {
//		//CONTENT.txt
//		String jsonStr = FSUtils.readStr("/tmp/CONTENT.txt");
//		Map<String, Object> dataMap = new ObjectMapper().readValue(jsonStr, Map.class);
//		BscStructTreeObj treeObj = new ObjectMapper().readValue( SimpleUtils.deB64((String)dataMap.get("treeObjJsonStr")), BscStructTreeObj.class);
//		ChainResultObj resultObj = new ObjectMapper().readValue( SimpleUtils.deB64((String)dataMap.get("resultObjJsonStr")), ChainResultObj.class);
//		
//	}
/**
	 * 2016-11-01
	 * 主要給 workspace 圖表元件載入用的 
	 * 
	 * @throws ControllerException
	 * @throws AuthorityException
	 * @throws ServiceException
	 * @throws Exception
	 */
private void loadContentFromUpload() throws ControllerException, AuthorityException, ServiceException, Exception {
    String uploadOid = this.getFields().get("uploadOid");
    byte[] content = UploadSupportUtils.getDataBytes(uploadOid);
    String jsonStr = new String(content, Constants.BASE_ENCODING);
    if (StringUtils.isBlank(jsonStr)) {
        throw new Exception("Report json data error.");
    }
    @SuppressWarnings("unchecked") Map<String, Object> dataMap = new ObjectMapper().readValue(jsonStr, Map.class);
    BscStructTreeObj treeObj = new ObjectMapper().readValue(SimpleUtils.deB64((String) dataMap.get("treeObjJsonStr")), BscStructTreeObj.class);
    ChainResultObj resultObj = new ObjectMapper().readValue(SimpleUtils.deB64((String) dataMap.get("resultObjJsonStr")), ChainResultObj.class);
    this.body = String.valueOf(resultObj.getValue());
    this.message = resultObj.getMessage();
    if (!StringUtils.isBlank(this.body) && this.body.startsWith("<!-- BSC_PROG003D0001Q -->")) {
        this.success = IS_YES;
    }
    this.fillPerspectivesPieChartData(treeObj);
    this.fillPerspectivesBarChartData(treeObj);
    this.fillLineChartData(treeObj);
}
Also used : BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException) ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with ControllerException

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

the class StrategyMapManagementAction method loadObjectiveItem.

private void loadObjectiveItem() throws ControllerException, ServiceException, Exception {
    // 這裡的 fields.oid 放的是 BB_OBJECTIVE.OBJ_ID
    String objId = super.defaultString(super.getFields().get("oid")).trim();
    if (StringUtils.isBlank(objId)) {
        throw new ControllerException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    this.objective = new ObjectiveVO();
    this.objective.setObjId(objId);
    DefaultResult<ObjectiveVO> result = this.objectiveService.findByUK(this.objective);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    this.objective = result.getValue();
    PerspectiveVO perspective = new PerspectiveVO();
    perspective.setPerId(this.objective.getPerId());
    DefaultResult<PerspectiveVO> pResult = this.perspectiveService.findByUK(perspective);
    if (pResult.getValue() == null) {
        throw new ServiceException(pResult.getSystemMessage().getValue());
    }
    perspective = pResult.getValue();
    DefaultResult<VisionVO> vResult = this.visionService.findForSimpleByVisId(perspective.getVisId());
    if (vResult.getValue() == null) {
        throw new ServiceException(vResult.getSystemMessage().getValue());
    }
    VisionVO vision = vResult.getValue();
    this.visionOid = vision.getOid();
}
Also used : ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO)

Example 4 with ControllerException

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

the class AnalyticsProcessAction method doExcel.

/**
	 * qcharts.analyticsExcelAction.action
	 * 
	 * @return
	 * @throws Exception
	 */
@JSON(serialize = false)
@ControllerMethodAuthority(programId = "QCHARTS_PROG002D0002Q")
public String doExcel() throws Exception {
    File catalogFile = null;
    try {
        if (!this.allowJob()) {
            this.message = this.getNoAllowMessage();
            return SUCCESS;
        }
        this.exportExcel(catalogFile);
    } catch (AuthorityException | ControllerException | ServiceException e) {
        this.message = e.getMessage().toString();
    } catch (Exception e) {
        this.message = this.logException(e);
        this.success = IS_EXCEPTION;
    }
    catalogFile = null;
    return SUCCESS;
}
Also used : ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) File(java.io.File) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException) ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException) ControllerMethodAuthority(com.netsteadfast.greenstep.base.model.ControllerMethodAuthority) JSON(org.apache.struts2.json.annotations.JSON)

Example 5 with ControllerException

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

the class AnalyticsProcessAction method doHtml.

/**
	 * qcharts.analyticsHtmlAction.action
	 * 
	 * @return
	 * @throws Exception
	 */
@JSON(serialize = false)
@ControllerMethodAuthority(programId = "QCHARTS_PROG002D0002Q")
public String doHtml() throws Exception {
    File catalogFile = null;
    try {
        if (!this.allowJob()) {
            this.message = this.getNoAllowMessage();
            return SUCCESS;
        }
        this.rendererHtml(catalogFile);
    } catch (AuthorityException | ControllerException | ServiceException e) {
        this.message = e.getMessage().toString();
    } catch (Exception e) {
        this.message = this.logException(e);
        this.success = IS_EXCEPTION;
    }
    catalogFile = null;
    return SUCCESS;
}
Also used : ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) File(java.io.File) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException) ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException) ControllerMethodAuthority(com.netsteadfast.greenstep.base.model.ControllerMethodAuthority) JSON(org.apache.struts2.json.annotations.JSON)

Aggregations

ControllerException (com.netsteadfast.greenstep.base.exception.ControllerException)17 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)10 AuthorityException (com.netsteadfast.greenstep.base.exception.AuthorityException)8 File (java.io.File)6 JSON (org.apache.struts2.json.annotations.JSON)4 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)3 ControllerMethodAuthority (com.netsteadfast.greenstep.base.model.ControllerMethodAuthority)3 SysUploadVO (com.netsteadfast.greenstep.vo.SysUploadVO)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 SimpleChain (com.netsteadfast.greenstep.base.chain.SimpleChain)2 StrategyMapItemsVO (com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO)2 HashMap (java.util.HashMap)2 Context (org.apache.commons.chain.Context)2 IActionFieldsCheckUtils (com.netsteadfast.greenstep.base.model.IActionFieldsCheckUtils)1 SystemForm (com.netsteadfast.greenstep.base.model.SystemForm)1 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)1 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)1 OlapCatalogVO (com.netsteadfast.greenstep.vo.OlapCatalogVO)1 OlapConfVO (com.netsteadfast.greenstep.vo.OlapConfVO)1 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)1