use of com.netsteadfast.greenstep.base.exception.AuthorityException in project bamboobsc by billchen198318.
the class HessianServiceProxyAspect method proxyProcess.
private Object proxyProcess(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable {
MethodSignature signature = (MethodSignature) pjp.getSignature();
Annotation[] annotations = pjp.getTarget().getClass().getAnnotations();
String serviceId = AspectConstants.getServiceId(annotations);
/**
* 不需要被遠端代理的 service-bean
*/
if (!GreenStepHessianUtils.isProxyServiceId(serviceId)) {
//logger.info( "reject proxy service: " + serviceId );
return pjp.proceed();
}
String userId = StringUtils.defaultString((String) SecurityUtils.getSubject().getPrincipal());
if (GreenStepHessianUtils.getConfigHessianHeaderCheckValueModeEnable()) {
/**
* 沒使用者資訊不能處理遠端代理的 service-bean
*/
if (StringUtils.isBlank(userId)) {
logger.warn("no userId");
pjp.proceed();
}
/**
* 此使用者不能存取遠端代理的 service-bean
*/
if (GreenStepHessianUtils.isProxyBlockedAccountId(userId)) {
logger.warn("reject proxy service: " + serviceId + " , blocked userId: " + userId);
return pjp.proceed();
}
}
String serviceInterfacesName = "";
Class<?>[] serviceInterfaces = pjp.getTarget().getClass().getInterfaces();
for (Class<?> clazz : serviceInterfaces) {
if (clazz.getName().indexOf(".service.") > -1) {
serviceInterfacesName = clazz.getName();
}
}
if (StringUtils.isBlank(serviceInterfacesName)) {
logger.error("error no service interface: " + serviceId);
throw new Exception("error no service interface: " + serviceId);
}
String url = GreenStepHessianUtils.getServiceUrl(serviceId);
String theSystemPath = ApplicationSiteUtils.getHost(Constants.getSystem()) + "/" + ApplicationSiteUtils.getContextPath(Constants.getSystem());
/**
* 不要自己呼叫遠端代理的自己, 會造成 HessianServiceProxyAspect 一直重複觸發 (客戶端與server-remote同一台的情況下)
* 如客戶端是 http://127.0.0.1:8080/
* 但是客戶端有開啟 hessian.enable=Y 呼叫遠端代理, 然後遠端url設定為 hessian.serverUrl=http://127.0.0.1:8080/
*
*/
if (url.indexOf(theSystemPath) > -1) {
logger.error("cannot open same-server. now system contextPath = " + theSystemPath + " , but proxy url = " + url);
throw new Exception("cannot open same-server. now system contextPath = " + theSystemPath + " , but proxy url = " + url);
}
logger.info("proxy url = " + url);
HessianProxyFactory factory = null;
Object proxyServiceObject = null;
if (GreenStepHessianUtils.getConfigHessianHeaderCheckValueModeEnable()) {
// 一般要checkValue模式
factory = new GreenStepHessianProxyFactory();
((GreenStepHessianProxyFactory) factory).setHeaderCheckValue(GreenStepHessianUtils.getEncAuthValue(userId));
proxyServiceObject = ((GreenStepHessianProxyFactory) factory).createForHeaderMode(Class.forName(serviceInterfacesName), url);
} else {
// 不使用checkValue模式
factory = new HessianProxyFactory();
proxyServiceObject = factory.create(Class.forName(serviceInterfacesName), url);
}
Method[] proxyObjectMethods = proxyServiceObject.getClass().getMethods();
Method proxyObjectMethod = null;
if (null == proxyObjectMethods) {
logger.error("error no find proxy method: " + serviceId);
throw new Exception("error no find proxy method: " + serviceId);
}
for (Method m : proxyObjectMethods) {
if (m.getName().equals(signature.getMethod().getName()) && Arrays.equals(m.getParameterTypes(), signature.getMethod().getParameterTypes())) {
proxyObjectMethod = m;
}
}
if (null == proxyObjectMethod) {
logger.error("error no execute proxy method: " + serviceId);
throw new Exception("error no execute proxy method: " + serviceId);
}
Object resultObj = null;
try {
resultObj = proxyObjectMethod.invoke(proxyServiceObject, pjp.getArgs());
this.setReCalculateSizePageOfForPageFindGridResult(resultObj, pjp.getArgs());
} catch (InvocationTargetException e) {
if (e.getMessage() != null) {
throw new ServiceException(e.getMessage().toString());
}
if (e.getTargetException().getMessage() != null) {
throw new ServiceException(e.getTargetException().getMessage().toString());
}
throw e;
} catch (Exception e) {
logger.error(e.getMessage().toString());
throw e;
}
logger.info("proxy success: " + serviceId + " method: " + proxyObjectMethod.getName());
return resultObj;
}
use of com.netsteadfast.greenstep.base.exception.AuthorityException 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);
}
use of com.netsteadfast.greenstep.base.exception.AuthorityException 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;
}
use of com.netsteadfast.greenstep.base.exception.AuthorityException 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;
}
use of com.netsteadfast.greenstep.base.exception.AuthorityException in project bamboobsc by billchen198318.
the class CommonLoadFormAction method execute.
@JSON(serialize = false)
@SystemForm
public String execute() throws Exception {
String resultName = RESULT_SEARCH_NO_DATA;
if (StringUtils.isBlank(form_id) || StringUtils.isBlank(form_method)) {
this.message = "no settings data to init form!";
this.setErrorMessage(this.message);
return resultName;
}
try {
SysFormMethodVO formMethod = SystemFormUtils.findFormMethod(this.form_id, this.form_method);
resultName = formMethod.getResultType();
this.processExpression(formMethod);
} catch (ControllerException ce) {
this.message = ce.getMessage().toString();
this.setErrorMessage(this.message);
} catch (AuthorityException ae) {
this.message = ae.getMessage().toString();
this.setErrorMessage(this.message);
if (FormResultType.DEFAULT.equals(resultName)) {
resultName = RESULT_NO_AUTHORITH;
}
} catch (ServiceException se) {
this.message = se.getMessage().toString();
this.setErrorMessage(this.message);
} catch (Exception e) {
// 因為是 JSON 所以不用拋出 throw e 了
e.printStackTrace();
if (e.getMessage() == null) {
this.message = e.toString();
this.logger.error(e.toString());
} else {
this.message = e.getMessage().toString();
this.logger.error(e.getMessage());
}
this.setErrorMessage(this.message);
this.success = IS_EXCEPTION;
if (FormResultType.DEFAULT.equals(resultName)) {
resultName = ERROR;
}
}
return resultName;
}
Aggregations