/** * Throws out a {@link ConfigurationException} with message specified. * @param message * the error message format pattern. * @param args * the error message format arguments. */ public static ConfigurationException invalidConfiguration(String message, Object... args) { throw new ConfigurationException(message, args); }
/** * Throws out a {@link ConfigurationException} with cause and message specified. * @param cause * the cause of the configuration error. * @param message * the error message format pattern. * @param args * the error message format arguments. */ public static ConfigurationException invalidConfiguration(Throwable cause, String message, Object... args) { throw new ConfigurationException(cause, message, args); }
/** * Throws out a {@link ConfigurationException} with message specified. * @param message * the error message format pattern. * @param args * the error message format arguments. */ public static ConfigurationException invalidConfiguration(String message, Object... args) { throw new ConfigurationException(message, args); }
/** * Throws out a {@link ConfigurationException} with cause and message specified. * @param cause * the cause of the configuration error. * @param message * the error message format pattern. * @param args * the error message format arguments. */ public static ConfigurationException invalidConfiguration(Throwable cause, String message, Object... args) { throw new ConfigurationException(cause, message, args); }
public int httpMaxParams() { if (-1 == httpMaxParams) { httpMaxParams = getInteger(HTTP_MAX_PARAMS, 128); if (httpMaxParams < 0) { throw new ConfigurationException("http.params.max setting cannot be negative number. Found: %s", httpMaxParams); } } return httpMaxParams; }
public int httpMaxParams() { if (-1 == httpMaxParams) { httpMaxParams = getInteger(HTTP_MAX_PARAMS, 128); if (httpMaxParams < 0) { throw new ConfigurationException("http.params.max setting cannot be negative number. Found: %s", httpMaxParams); } } return httpMaxParams; }
private WebRenderExt getWebRenderExt(String clsName) { try { return Act.app().getInstance(clsName); } catch (Exception ex) { throw new ConfigurationException(ex, "Error loading WebRenderExt: %s", ex.getMessage()); } }
private void _defPasswordSpec(String spec) { try { defPasswordValidator = PasswordSpec.parse(spec); } catch (IllegalArgumentException e) { // try to check if the spec is a PasswordValidator try { defPasswordValidator = app.getInstance(spec); } catch (Exception e2) { throw new ConfigurationException("Password spec unrecognized: " + spec); } } }
<T> T getImpl(Map<String, ?> configuration, String key, String suffix, $.F0<?> defVal) { Object v = getValFromAliases(configuration, key, "impl", defVal); if (null == v) return null; if (v instanceof Class) { try { return instanceOf((Class<T>) v); } catch (Exception e) { throw new ConfigurationException(e, "Error getting implementation configuration: %s", key); } } if (!(v instanceof String)) return (T) v; String clsName = (String) v; try { return instanceOf(clsName); } catch (Exception e) { throw new ConfigurationException(e, "Error getting implementation configuration: %s", key); } }
public ReturnValueAdvice globalReturnValueAdvice() { if (null != globalReturnValueAdviceSet) { return globalReturnValueAdvice; } String s = get(GLOBAL_RETURN_VALUE_ADVICE, null); if (null != s) { try { globalReturnValueAdvice = app.getInstance(s); } catch (Exception e) { throw new ConfigurationException("Error loading global returnValueAdvice: " + s); } } globalReturnValueAdviceSet = true; return globalReturnValueAdvice; }
private void _defPasswordSpec(String spec) { try { defPasswordValidator = PasswordSpec.parse(spec); } catch (IllegalArgumentException e) { // try to check if the spec is a PasswordValidator try { defPasswordValidator = app.getInstance(spec); } catch (Exception e2) { throw new ConfigurationException("Password spec unrecognized: " + spec); } } }
<T> T getImpl(Map<String, ?> configuration, String key, String suffix, $.F0<?> defVal) { Object v = getValFromAliases(configuration, key, "impl", defVal); if (null == v) return null; if (v instanceof Class) { try { return instanceOf((Class<T>) v); } catch (Exception e) { throw new ConfigurationException(e, "Error getting implementation configuration: %s", key); } } if (!(v instanceof String)) return (T) v; String clsName = (String) v; try { return instanceOf(clsName); } catch (Exception e) { throw new ConfigurationException(e, "Error getting implementation configuration: %s", key); } }
public ValidateViolationAdvice globalValidateViolationAdvice() { if (null != globalValidateViolationAdviceSet) { return globalValidateViolationAdvice; } String s = get(GLOBAL_VALIDATE_VIOLATION_ADVICE, null); if (null != s) { try { globalValidateViolationAdvice = app.getInstance(s); } catch (Exception e) { throw new ConfigurationException("Error loading global returnValueAdvice: " + s); } } globalValidateViolationAdviceSet = true; return globalValidateViolationAdvice; }
public ReturnValueAdvice globalReturnValueAdvice() { if (null != globalReturnValueAdviceSet) { return globalReturnValueAdvice; } String s = get(GLOBAL_RETURN_VALUE_ADVICE, null); if (null != s) { try { globalReturnValueAdvice = app.getInstance(s); } catch (Exception e) { throw new ConfigurationException("Error loading global returnValueAdvice: " + s); } } globalReturnValueAdviceSet = true; return globalReturnValueAdvice; }
public ValidateViolationAdvice globalValidateViolationAdvice() { if (null != globalValidateViolationAdviceSet) { return globalValidateViolationAdvice; } String s = get(GLOBAL_VALIDATE_VIOLATION_ADVICE, null); if (null != s) { try { globalValidateViolationAdvice = app.getInstance(s); } catch (Exception e) { throw new ConfigurationException("Error loading global returnValueAdvice: " + s); } } globalValidateViolationAdviceSet = true; return globalValidateViolationAdvice; }
private void initService(String dbId, Map<String, String> conf) { Map<String, String> svcConf = new HashMap<>(); String prefix = "db." + (S.blank(dbId) ? "" : dbId + "."); for (String key : conf.keySet()) { if (key.startsWith(prefix)) { String o = conf.get(key); svcConf.put(key.substring(prefix.length()), o); } } String impl = svcConf.remove("impl"); String svcId = S.empty(dbId) ? DEFAULT : dbId; if (null == impl) { throw new ConfigurationException("Cannot init db service[%s]: implementation not specified", svcId); } DbPlugin plugin = Act.dbManager().plugin(impl); if (null == plugin) { throw new ConfigurationException("Cannot init db service[%s]: implementation not found: %s", svcId, impl); } DbService svc = plugin.initDbService(S.blank(dbId) ? DEFAULT : dbId, app(), svcConf); serviceMap.put(svcId, svc); logger.info("db service[%s] initialized", svcId); }
/** * Create a connection to Azure Blob file storage system */ private void connect(String protocol, String accountName, String accountKey, String bucketName) { if (bucketName == null || bucketName.trim().isEmpty()) throw new ConfigurationException("Defined Azure Blog bucket is invalid."); //container name MUST be lowercase bucketName = bucketName.toLowerCase(); String connectionString = MessageFormat.format(CONNECTION_PATTERN, protocol, accountName, accountKey); try { CloudStorageAccount blobAccount = CloudStorageAccount.parse(connectionString); this.blobClient = blobAccount.createCloudBlobClient(); this.blobContainer = blobClient.getContainerReference(bucketName); boolean isBucketNotExist = blobContainer.createIfNotExists(); if (isBucketNotExist) log.info("New Azure Blob container created: " + bucketName); //Set access to public for blob resource BlobContainerPermissions containerPermissions = new BlobContainerPermissions(); containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER); blobContainer.uploadPermissions(containerPermissions); } catch (Exception exception) { log.error(exception.getMessage(), exception); throw new ConfigurationException(exception); } }
private void initService(String dbId, Map<String, String> conf) { Map<String, String> svcConf = new HashMap<>(); String prefix = "db." + (S.blank(dbId) ? "" : dbId + "."); for (String key : conf.keySet()) { if (key.startsWith(prefix)) { String o = conf.get(key); svcConf.put(key.substring(prefix.length()), o); } } String impl = svcConf.remove("impl"); String svcId = S.empty(dbId) ? DEFAULT : dbId; if (null == impl) { throw new ConfigurationException("Cannot init db service[%s]: implementation not specified", svcId); } DbPlugin plugin = Act.dbManager().plugin(impl); if (null == plugin) { throw new ConfigurationException("Cannot init db service[%s]: implementation not found: %s", svcId, impl); } DbService svc = plugin.initDbService(S.blank(dbId) ? DEFAULT : dbId, app(), svcConf); serviceMap.put(svcId, svc); logger.info("db service[%s] initialized", svcId); }
String pkg = sp[i]; if (pkg.startsWith("act.") || "act".equals(pkg)) { throw new ConfigurationException("Scan package cannot be 'act' or starts with 'act.'");
public void initClient() throws IOException { System.setProperty("net.spy.log.LoggerImpl", "org.osgl.cache.impl.SpyMemcachedLogger"); List<InetSocketAddress> addrs = MemcachedClientConfigurator.getHosts(); if (addrs.isEmpty()) { throw new ConfigurationException("Bad configuration for memcached: missing host(s)"); } String username = MemcachedClientConfigurator.getUsername(); if (S.notBlank(username)) { String password = MemcachedClientConfigurator.getPassword(); if (null == password) { throw new ConfigurationException("Bad configuration for memcached: missing password"); } // Use plain SASL to connect to memcached AuthDescriptor ad = new AuthDescriptor(new String[]{"PLAIN"}, new PlainCallbackHandler(username, password)); ConnectionFactory cf = new ConnectionFactoryBuilder() .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY) .setAuthDescriptor(ad) .build(); client = new MemcachedClient(cf, addrs); } else { client = new MemcachedClient(addrs); } }