use of com.mendmix.common.JeesuiteBaseException in project jeesuite-libs by vakinge.
the class QcloudProvider method getObjectMetadata.
@Override
public CObjectMetadata getObjectMetadata(String bucketName, String fileKey) {
try {
String _bucketName = buildBucketName(bucketName);
String _fileKey = resolveFileKey(bucketName, fileKey);
ObjectMetadata metadata = cosclient.getObjectMetadata(_bucketName, _fileKey);
CObjectMetadata objectMetadata = new CObjectMetadata();
objectMetadata.setCreateTime(metadata.getLastModified());
objectMetadata.setMimeType(metadata.getContentType());
objectMetadata.setFilesize(metadata.getContentLength());
objectMetadata.setHash(metadata.getContentMD5());
objectMetadata.setExpirationTime(metadata.getExpirationTime());
objectMetadata.setCustomMetadatas(metadata.getUserMetadata());
return objectMetadata;
} catch (Exception e) {
throw new JeesuiteBaseException(500, buildMessage(bucketName, e));
}
}
use of com.mendmix.common.JeesuiteBaseException in project jeesuite-libs by vakinge.
the class QcloudProvider method delete.
@Override
public boolean delete(String bucketName, String fileKey) {
try {
bucketName = buildBucketName(bucketName);
cosclient.deleteObject(bucketName, fileKey);
} catch (Exception e) {
throw new JeesuiteBaseException(500, buildMessage(bucketName, e));
}
return true;
}
use of com.mendmix.common.JeesuiteBaseException in project jeesuite-libs by vakinge.
the class QcloudProvider method createBucket.
@Override
public void createBucket(String bucketName, boolean isPrivate) {
bucketName = buildBucketName(bucketName);
if (cosclient.doesBucketExist(bucketName)) {
throw new JeesuiteBaseException(406, "bucketName[" + bucketName + "]已存在");
}
CreateBucketRequest request = new CreateBucketRequest(bucketName);
if (isPrivate) {
request.setCannedAcl(CannedAccessControlList.Private);
} else {
request.setCannedAcl(CannedAccessControlList.PublicRead);
}
cosclient.createBucket(request);
}
use of com.mendmix.common.JeesuiteBaseException in project jeesuite-libs by vakinge.
the class RequestLoggingInterceptor method around.
@Around("pointcut()")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
ActionLog actionLog = ActionLogCollector.currentActionLog();
if (actionLog == null) {
return pjp.proceed();
}
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
Method method = ((MethodSignature) pjp.getSignature()).getMethod();
boolean requestLog = true;
boolean responseLog = !ignoreResponseBody;
if (method.isAnnotationPresent(ApiMetadata.class)) {
ApiMetadata metadata = method.getAnnotation(ApiMetadata.class);
requestLog = metadata.requestLog();
responseLog = metadata.responseLog();
if (!requestLog && !responseLog) {
return pjp.proceed();
}
}
Map<String, Object> parameters = null;
Object body = null;
if (requestLog) {
Object[] args = pjp.getArgs();
if (args.length > 0) {
List<ParameterLogConfig> parameterConfigs = getParameterConfigs(pjp.getTarget().getClass().getName(), method);
parameters = new HashMap<>(3);
ParameterLogConfig config;
for (int i = 0; i < args.length; i++) {
if ((config = parameterConfigs.get(i)).ignore)
continue;
if (config.isBody) {
body = args[i];
} else if (config.paramName != null && args[i] != null) {
parameters.put(config.paramName, args[i].toString());
}
}
}
if (log.isDebugEnabled()) {
String requestLogMessage = RequestLogBuilder.requestLogMessage(request.getRequestURI(), request.getMethod(), parameters, body);
log.debug(requestLogMessage);
}
}
actionLog.setQueryParameters(ParameterUtils.mapToQueryParams(parameters));
actionLog.setRequestData(body);
Object result = null;
try {
result = pjp.proceed();
//
if (responseLog) {
actionLog.setResponseData(result);
}
return result;
} catch (Exception e) {
if (e instanceof JeesuiteBaseException) {
actionLog.setExceptions(e.getMessage());
} else {
actionLog.setExceptions(ExceptionUtils.getMessage(e));
}
throw e;
}
}
use of com.mendmix.common.JeesuiteBaseException in project jeesuite-libs by vakinge.
the class ActuatorController method health.
@GetMapping("/health")
public Map<String, Object> health(@RequestParam(value = "details", required = false) boolean details) {
Map<String, Object> result = new HashMap<>(1);
result.put("status", "UP");
result.put("startTime", GlobalRuntimeContext.STARTUP_TIME);
if (details) {
Collection<BizSystemModule> modules = CurrentSystemHolder.getModules();
Map<String, Object> moduleStatus = new HashMap<>(modules.size());
for (BizSystemModule module : modules) {
try {
String status = HttpRequestEntity.get(module.getHealthUri()).execute().toValue("status");
moduleStatus.put(module.getServiceId(), status);
} catch (JeesuiteBaseException e) {
if (e.getCode() == 404 || e.getCode() == 401 || e.getCode() == 403) {
result.put(module.getServiceId(), "UP");
} else {
result.put(module.getServiceId(), "UNKNOW");
}
} catch (Exception e) {
result.put(module.getServiceId(), "UNKNOW");
}
}
result.put("modules", moduleStatus);
}
return result;
}
Aggregations