use of com.netsteadfast.greenstep.base.exception.AuthorityException in project bamboobsc by billchen198318.
the class ServiceAuthorityCheckAspect method logicServiceProcess.
@Around(AspectConstants.LOGIC_SERVICE_PACKAGE)
public Object logicServiceProcess(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable {
MethodSignature signature = (MethodSignature) pjp.getSignature();
Annotation[] annotations = pjp.getTarget().getClass().getAnnotations();
String serviceId = AspectConstants.getServiceId(annotations);
Subject subject = SecurityUtils.getSubject();
Method method = signature.getMethod();
if (subject.hasRole(Constants.SUPER_ROLE_ALL) || subject.hasRole(Constants.SUPER_ROLE_ADMIN)) {
SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true);
return pjp.proceed();
}
if (StringUtils.isBlank(serviceId)) {
// 沒有 service id 無法判斷檢查
SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true);
return pjp.proceed();
}
if (!this.isServiceAuthorityCheck(annotations)) {
// 沒有 ServiceAuthority 或 check=false 就不用檢查了
SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true);
return pjp.proceed();
}
Annotation[] methodAnnotations = method.getAnnotations();
if (this.isServiceMethodAuthority(serviceId, methodAnnotations, subject)) {
SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true);
return pjp.proceed();
}
logger.warn("[decline] user[" + subject.getPrincipal() + "] " + pjp.getTarget().getClass().getName() + " - " + signature.getMethod().getName());
SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), false);
throw new AuthorityException(SysMessageUtil.get(GreenStepSysMsgConstants.NO_PERMISSION));
}
use of com.netsteadfast.greenstep.base.exception.AuthorityException in project bamboobsc by billchen198318.
the class AnalyticsProcessAction method exportExcel.
private void exportExcel(File catalogFile) throws ControllerException, AuthorityException, ServiceException, Exception {
this.oid = "";
this.checkFields("query");
boolean showDimensionTitle = true;
boolean showParentMembers = true;
if (!"true".equals(this.getFields().get("showDimensionTitle"))) {
showDimensionTitle = false;
}
if (!"true".equals(this.getFields().get("showParentMembers"))) {
showParentMembers = false;
}
OlapCatalogVO catalog = this.loadOlapCatalog(this.getFields().get("catalogOid"));
OlapConfVO config = this.loadOlapConfig(this.getFields().get("configOid"));
catalogFile = OlapUtils.writeCatalogContentToFile(catalog.getId() + "_" + super.getAccountOid(), new String(catalog.getContent(), Constants.BASE_ENCODING));
String mondrianUrl = OlapUtils.getMondrianUrl(config.getJdbcUrl(), config.getJdbcDrivers(), catalogFile.getPath());
File file = null;
try {
file = Pivot4JUtils.exportExcelFile(mondrianUrl, this.getFields().get("expression"), showDimensionTitle, showParentMembers);
this.oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, true, file, "analytics-export.xlsx");
} catch (Exception e) {
throw e;
} finally {
file = null;
}
this.message = this.getText("MESSAGE.QCHARTS_PROG002D0002Q_msg1") + super.getHtmlBr();
this.success = IS_YES;
}
use of com.netsteadfast.greenstep.base.exception.AuthorityException in project bamboobsc by billchen198318.
the class AnalyticsProcessAction method rendererHtmlExport.
private void rendererHtmlExport(File catalogFile) throws ControllerException, AuthorityException, ServiceException, Exception {
this.rendererHtml(catalogFile);
String datas = Pivot4JUtils.wrapRendererHtml(this.content);
File file = null;
try {
file = new File(Constants.getWorkTmpDir() + "/" + super.getUuid() + ".htm");
FileUtils.writeStringToFile(file, datas, Constants.BASE_ENCODING);
this.oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, true, file, "analytics-export.htm");
} catch (Exception e) {
throw e;
} finally {
file = null;
}
}
use of com.netsteadfast.greenstep.base.exception.AuthorityException in project bamboobsc by billchen198318.
the class AnalyticsProcessAction method doHtmlExport.
/**
* qcharts.analyticsHtmlExportAction.action
*
* @return
* @throws Exception
*/
@JSON(serialize = false)
@ControllerMethodAuthority(programId = "QCHARTS_PROG002D0002Q")
public String doHtmlExport() throws Exception {
File catalogFile = null;
try {
if (!this.allowJob()) {
this.message = this.getNoAllowMessage();
return SUCCESS;
}
this.rendererHtmlExport(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;
}
Aggregations