use of com.mendmix.common.JeesuiteBaseException in project jeesuite-libs by vakinge.
the class QiniuProvider method processQiniuException.
private void processQiniuException(String bucketName, QiniuException e) {
Response r = e.response;
if (e.code() == 631) {
throw new JeesuiteBaseException(404, "bucketName[" + bucketName + "]不存在");
}
if (e.code() == 614) {
throw new JeesuiteBaseException(406, "bucketName[" + bucketName + "]已存在");
}
if (e.code() == 612) {
throw new JeesuiteBaseException(404, "资源不存在");
}
String message;
try {
message = r.bodyString();
} catch (Exception e2) {
message = r.toString();
}
throw new JeesuiteBaseException(message);
}
use of com.mendmix.common.JeesuiteBaseException in project jeesuite-libs by vakinge.
the class CurrentSystemHolder method initModuleApiInfos.
private static void initModuleApiInfos(BizSystemModule module) {
try {
String url;
AppMetadata appMetadata;
if (GlobalRuntimeContext.APPID.equals(module.getRouteName())) {
appMetadata = AppMetadataHolder.getMetadata();
} else {
url = module.getMetadataUri();
appMetadata = HttpRequestEntity.get(url).backendInternalCall().execute().toObject(AppMetadata.class);
}
for (ApiInfo api : appMetadata.getApis()) {
module.addApiInfo(api);
}
moduleApiInfos.put(module.getServiceId(), module.getApiInfos());
log.info(">>initModuleApiInfos success -> serviceId:{},nums:{}", module.getServiceId(), module.getApiInfos().size());
} catch (Exception e) {
boolean ignore = e instanceof ClassCastException;
if (!ignore && e instanceof JeesuiteBaseException) {
JeesuiteBaseException ex = (JeesuiteBaseException) e;
ignore = ex.getCode() == 404 || ex.getCode() == 401 || ex.getCode() == 403;
}
if (ignore) {
module.setApiInfos(new HashMap<>(0));
moduleApiInfos.put(module.getServiceId(), module.getApiInfos());
} else if (fetchApiMetaRound <= 1) {
log.error(">>initModuleApiInfos error -> serviceId:[" + module.getServiceId() + "]", e);
}
}
}
use of com.mendmix.common.JeesuiteBaseException in project jeesuite-libs by vakinge.
the class LogFactory method setImplementation.
private static void setImplementation(Class<? extends Logger> implClass) {
try {
Constructor<? extends Logger> candidate = implClass.getConstructor(String.class);
Logger log = candidate.newInstance(LogFactory.class.getName());
if (log.isDebugEnabled()) {
log.debug("Logging initialized using '" + implClass + "' adapter.");
}
logConstructor = candidate;
} catch (Throwable t) {
throw new JeesuiteBaseException("Error setting Log implementation. Cause: " + t);
}
}
use of com.mendmix.common.JeesuiteBaseException in project jeesuite-libs by vakinge.
the class CosProviderServiceFacade method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
//
if (defaultBucket == null) {
defaultBucket = ResourceUtils.getProperty("cos.defaultBucket");
}
if (type == null) {
type = ResourceUtils.getAndValidateProperty("cos.provider");
}
if (config == null) {
config = new CosProviderConfig();
config.setAccessKey(ResourceUtils.getProperty("cos.accessKey"));
config.setSecretKey(ResourceUtils.getProperty("cos.secretKey"));
config.setAppId(ResourceUtils.getProperty("cos.appId"));
config.setRegionName(ResourceUtils.getProperty("cos.regionName"));
config.setMaxConnectionsCount(ResourceUtils.getInt("cos.maxConnections", 200));
}
if (AliyunProvider.NAME.equals(type)) {
provider = new AliyunProvider(config);
} else if (QcloudProvider.NAME.equals(type)) {
provider = new QcloudProvider(config);
} else if (QiniuProvider.NAME.equals(type)) {
provider = new QiniuProvider(config);
} else {
throw new JeesuiteBaseException("cos[" + type + "] not support");
}
if (defaultBucket != null) {
BucketConfig bucketConfig = provider.getBucketConfig(defaultBucket);
bucketConfig.setUrlPrefix(ResourceUtils.getProperty("cos.defaultUrlPrefix"));
((AbstractProvider) provider).addBucketConfig(bucketConfig);
} else {
Map<String, String> urlPrefixMappings = ResourceUtils.getMappingValues("cos.bucket.urlPrefix.mapping");
if (urlPrefixMappings != null) {
urlPrefixMappings.forEach((bucket, urlPrefix) -> {
BucketConfig bucketConfig = provider.getBucketConfig(defaultBucket);
bucketConfig.setUrlPrefix(ResourceUtils.getProperty("cos.defaultUrlPrefix"));
((AbstractProvider) provider).addBucketConfig(bucketConfig);
});
}
}
logUrl = ResourceUtils.getProperty("cos.loghandler.url");
if (logUrl != null && Boolean.parseBoolean(ResourceUtils.getProperty("cos.loghandler.enabled", "true"))) {
int nThread = ResourceUtils.getInt("cos.loghandler.threads", 1);
int capacity = ResourceUtils.getInt("cos.loghandler.queueSize", 1000);
logHandleExecutor = new ThreadPoolExecutor(nThread, nThread, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(capacity), new StandardThreadFactory("cosLogHandleExecutor"));
logger.info("init logHandleExecutor OK ,nThread:{},queue:{}", nThread, capacity);
}
}
Aggregations