Tabnine Logo
ConfigurationException
Code IndexAdd Tabnine to your IDE (free)

How to use
ConfigurationException
in
com.nextdoor.bender.config

Best Java code snippets using com.nextdoor.bender.config.ConfigurationException (Showing top 20 results out of 315)

origin: Nextdoor/bender

public BenderSchema(File schemaFile) {
 ObjectMapper objectMapper = new ObjectMapper();
 objectMapper.registerSubtypes(BenderConfig.subtypes);
 try {
  this.schema = objectMapper.readTree(schemaFile);
 } catch (IOException e) {
  throw new ConfigurationException("unable to load schema file", e);
 }
}
origin: Nextdoor/bender

} catch (ConfigurationException e) {
 System.out.println("Invalid");
 e.printStackTrace();
 hasFailures = true;
origin: Nextdoor/bender

public BenderSchema(File schemaFile) {
 ObjectMapper objectMapper = new ObjectMapper();
 objectMapper.registerSubtypes(BenderConfig.subtypes);
 try {
  this.schema = objectMapper.readTree(schemaFile);
 } catch (IOException e) {
  throw new ConfigurationException("unable to load schema file", e);
 }
}
origin: Nextdoor/bender

public Subtypes() {
 long start = System.nanoTime();
 try {
  subtypes.addAll(ClassScanner.getSubtypes(abstractConfigClasses));
 } catch (InterruptedException | ExecutionException e) {
  throw new ConfigurationException("unable to find config classes", e);
 }
 logger.debug(
   "Generating config subtype list took " + ((System.nanoTime() - start) / 1000000) + "ms");
 /*
  * Sort the subtypes so that the order is deterministic. Without this locally generated
  * schemas differ in order from those generated by CircleCI.
  */
 subtypes.sort(new Comparator<Class>() {
  @Override
  public int compare(Class o1, Class o2) {
   return o1.getName().compareToIgnoreCase(o2.getName());
  }
 });
}
origin: Nextdoor/bender

public Subtypes() {
 long start = System.nanoTime();
 try {
  subtypes.addAll(ClassScanner.getSubtypes(abstractConfigClasses));
 } catch (InterruptedException | ExecutionException e) {
  throw new ConfigurationException("unable to find config classes", e);
 }
 logger.debug(
   "Generating config subtype list took " + ((System.nanoTime() - start) / 1000000) + "ms");
 /*
  * Sort the subtypes so that the order is deterministic. Without this locally generated
  * schemas differ in order from those generated by CircleCI.
  */
 subtypes.sort(new Comparator<Class>() {
  @Override
  public int compare(Class o1, Class o2) {
   return o1.getName().compareToIgnoreCase(o2.getName());
  }
 });
}
origin: Nextdoor/bender

public static BenderConfig load(String filename, String data, ObjectMapper mapper,
  boolean validate) {
 String swappedData = swapEnvironmentVariables(data);
 if (validate) {
  BenderConfig.validate(swappedData, mapper);
 }
 BenderConfig config = null;
 try {
  config = mapper.readValue(swappedData, BenderConfig.class);
 } catch (IOException e) {
  throw new ConfigurationException("invalid config file", e);
 }
 return config;
}
origin: Nextdoor/bender

public static BenderConfig load(String filename, String data, ObjectMapper mapper,
  boolean validate) {
 String swappedData = swapEnvironmentVariables(data);
 if (validate) {
  BenderConfig.validate(swappedData, mapper);
 }
 BenderConfig config = null;
 try {
  config = mapper.readValue(swappedData, BenderConfig.class);
 } catch (IOException e) {
  throw new ConfigurationException("invalid config file", e);
 }
 return config;
}
origin: Nextdoor/bender

 throw new ConfigurationException("unable to find " + resource);
 data = IOUtils.toString(new InputStreamReader(url.openStream(), "UTF-8"));
} catch (NullPointerException | IOException e) {
 throw new ConfigurationException("unable to read " + resource, e);
origin: Nextdoor/bender

 throw new ConfigurationException("unable to find " + resource);
 data = IOUtils.toString(new InputStreamReader(url.openStream(), "UTF-8"));
} catch (NullPointerException | IOException e) {
 throw new ConfigurationException("unable to read " + resource, e);
origin: Nextdoor/bender

public String getValue() {
 if (this.value == null) {
  return value;
 }
 /*
  * Ensure that the value is only decrypted once regardless of usage. This prevents KMS from
  * being called over and over from within the function to decrypt the same field.
  */
 if (!this.decrypted) {
  try {
   this.value = Passwords.decrypt(this.value, Region.getRegion(this.region));
  } catch (UnsupportedEncodingException e) {
   throw new ConfigurationException("Unable to decrypt", e);
  }
  this.decrypted = true;
 }
 return this.value;
}
origin: Nextdoor/bender

 return this.schema;
} catch (Exception e) {
 throw new ConfigurationException("unable generate schema");
origin: Nextdoor/bender

 return this.schema;
} catch (Exception e) {
 throw new ConfigurationException("unable generate schema");
origin: Nextdoor/bender

public String getValue() {
 if (this.value == null) {
  return value;
 }
 /*
  * Ensure that the value is only decrypted once regardless of usage. This prevents KMS from
  * being called over and over from within the function to decrypt the same field.
  */
 if (!this.decrypted) {
  try {
   this.value = Passwords.decrypt(this.value, Region.getRegion(this.region));
  } catch (UnsupportedEncodingException e) {
   throw new ConfigurationException("Unable to decrypt", e);
  }
  this.decrypted = true;
 }
 return this.value;
}
origin: Nextdoor/bender

public static BenderConfig load(AmazonS3ClientFactory s3ClientFactory, AmazonS3URI s3Uri) {
 AmazonS3Client s3 = s3ClientFactory.newInstance();
 S3Object s3object = s3.getObject(s3Uri.getBucket(), s3Uri.getKey());
 StringWriter writer = new StringWriter();
 try {
  IOUtils.copy(s3object.getObjectContent(), writer, "UTF-8");
 } catch (IOException e) {
  throw new ConfigurationException("Unable to read file from s3", e);
 }
 BenderConfig config = load(s3Uri.getKey().toString(), writer.toString());
 config.setConfigFile(s3Uri.getURI().toString());
 return config;
}
origin: Nextdoor/bender

public static BenderConfig load(AmazonS3ClientFactory s3ClientFactory, AmazonS3URI s3Uri) {
 AmazonS3Client s3 = s3ClientFactory.newInstance();
 S3Object s3object = s3.getObject(s3Uri.getBucket(), s3Uri.getKey());
 StringWriter writer = new StringWriter();
 try {
  IOUtils.copy(s3object.getObjectContent(), writer, "UTF-8");
 } catch (IOException e) {
  throw new ConfigurationException("Unable to read file from s3", e);
 }
 BenderConfig config = load(s3Uri.getKey().toString(), writer.toString());
 config.setConfigFile(s3Uri.getURI().toString());
 return config;
}
origin: Nextdoor/bender

/**
 * Parses an input String and replaces instances of {@literal <XXX>}" with the value of the XXX OS
 * Environment Variable. This is used as a pre-parser for the Config files, allowing environment
 * variables to be swapped at run-time.
 *
 * @param raw A raw string (not necessarily valid configuration data)
 * @return A parsed string with OS variables swapped in
 * @throws ConfigurationException If any discovered {@literal <WRAPPED_VALUES>} are not found in
 *         System.getenv().
 */
public static String swapEnvironmentVariables(String raw) throws ConfigurationException {
 ErrorBuffer errors = new ErrorBuffer();
 ST template = new ST(raw);
 STGroup g = template.groupThatCreatedThisInstance;
 g.setListener(errors);
 Map<String, String> env = System.getenv();
 for (String envName : env.keySet()) {
  if (envName.contains(".")) {
   logger.warn("skipping " + envName + " because it contains '.' which is not allowed");
   continue;
  }
  template.add(envName, env.get(envName));
 }
 String parsed = template.render();
 if (errors.errors.size() > 0) {
  throw new ConfigurationException(errors.toString());
 }
 return parsed;
}
origin: Nextdoor/bender

/**
 * Parses an input String and replaces instances of {@literal <XXX>}" with the value of the XXX OS
 * Environment Variable. This is used as a pre-parser for the Config files, allowing environment
 * variables to be swapped at run-time.
 *
 * @param raw A raw string (not necessarily valid configuration data)
 * @return A parsed string with OS variables swapped in
 * @throws ConfigurationException If any discovered {@literal <WRAPPED_VALUES>} are not found in
 *         System.getenv().
 */
public static String swapEnvironmentVariables(String raw) throws ConfigurationException {
 ErrorBuffer errors = new ErrorBuffer();
 ST template = new ST(raw);
 STGroup g = template.groupThatCreatedThisInstance;
 g.setListener(errors);
 Map<String, String> env = System.getenv();
 for (String envName : env.keySet()) {
  if (envName.contains(".")) {
   logger.warn("skipping " + envName + " because it contains '.' which is not allowed");
   continue;
  }
  template.add(envName, env.get(envName));
 }
 String parsed = template.render();
 if (errors.errors.size() > 0) {
  throw new ConfigurationException(errors.toString());
 }
 return parsed;
}
origin: Nextdoor/bender

public static boolean validate(String data, ObjectMapper objectMapper, BenderSchema benderSchema)
  throws ConfigurationException {
 ProcessingReport report;
 try {
  /*
   * Create object
   */
  JsonNode node = objectMapper.readTree(data);
  /*
   * Create JSON schema
   */
  JsonNode jsonSchema = benderSchema.getSchema();
  /*
   * Validate
   */
  final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
  final JsonSchema schema = factory.getJsonSchema(jsonSchema);
  report = schema.validate(node);
 } catch (IOException | ProcessingException ioe) {
  throw new ConfigurationException("unable to validate config", ioe);
 }
 if (report.isSuccess()) {
  return true;
 } else {
  throw new ConfigurationException("invalid config file",
    report.iterator().next().asException());
 }
}
origin: Nextdoor/bender

public static boolean validate(String data, ObjectMapper objectMapper, BenderSchema benderSchema)
  throws ConfigurationException {
 ProcessingReport report;
 try {
  /*
   * Create object
   */
  JsonNode node = objectMapper.readTree(data);
  /*
   * Create JSON schema
   */
  JsonNode jsonSchema = benderSchema.getSchema();
  /*
   * Validate
   */
  final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
  final JsonSchema schema = factory.getJsonSchema(jsonSchema);
  report = schema.validate(node);
 } catch (IOException | ProcessingException ioe) {
  throw new ConfigurationException("unable to validate config", ioe);
 }
 if (report.isSuccess()) {
  return true;
 } else {
  throw new ConfigurationException("invalid config file",
    report.iterator().next().asException());
 }
}
origin: Nextdoor/bender

 @Override
 public void setConf(AbstractConfig config) {
  this.config = (GeoIpOperationConfig) config;
  AmazonS3Client client = this.s3Factory.newInstance();

  AmazonS3URI uri = new AmazonS3URI(this.config.getGeoLiteDb());
  GetObjectRequest req = new GetObjectRequest(uri.getBucket(), uri.getKey());
  S3Object obj = client.getObject(req);

  try {
   this.databaseReader =
     new DatabaseReader.Builder(obj.getObjectContent()).withCache(new CHMCache()).build();
  } catch (IOException e) {
   throw new ConfigurationException("Unable to read " + this.config.getGeoLiteDb(), e);
  }
 }
}
com.nextdoor.bender.configConfigurationException

Most used methods

  • <init>
  • printStackTrace

Popular in Java

  • Reactive rest calls using spring rest template
  • setScale (BigDecimal)
  • startActivity (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now