com.google.gwt.core.ext.BadPropertyValueException Java Examples

The following examples show how to use com.google.gwt.core.ext.BadPropertyValueException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GssResourceGenerator.java    From gss.gwt with Apache License 2.0 6 votes vote down vote up
private Set<String> getPermutationsConditions(ResourceContext context,
    List<String> permutationAxes) {
  Builder<String> setBuilder = ImmutableSet.builder();
  PropertyOracle oracle = context.getGeneratorContext().getPropertyOracle();

  for (String permutationAxis : permutationAxes) {
    String propValue = null;
    try {
      SelectionProperty selProp = oracle.getSelectionProperty(null,
          permutationAxis);
      propValue = selProp.getCurrentValue();
    } catch (BadPropertyValueException e) {
      try {
        ConfigurationProperty confProp = oracle.getConfigurationProperty(permutationAxis);
        propValue = confProp.getValues().get(0);
      } catch (BadPropertyValueException e1) {
        e1.printStackTrace();
      }
    }

    if (propValue != null) {
      setBuilder.add(permutationAxis + ":" + propValue);
    }
  }
  return setBuilder.build();
}
 
Example #2
Source File: Mvp4gConfiguration.java    From mvp4g with Apache License 2.0 5 votes vote down vote up
private String[] getGinModulesByProperties()
  throws InvalidMvp4gConfigurationException {
  String[] properties = ginModule.getModuleProperties();
  String[] propertiesValue;
  if (properties != null) {
    int size = properties.length;
    propertiesValue = new String[size];
    String moduleClassName;
    List<String> modules = ginModule.getModules();
    if (modules == null) {
      ginModule.setModules(new String[0]);
      modules = ginModule.getModules();
    }
    String property;
    for (int i = 0; i < size; i++) {
      property = properties[i];
      try {
        moduleClassName = propertyOracle.getSelectionProperty(logger,
                                                              property)
                                        .getCurrentValue()
                                        .replace("$",
                                                 ".");
      } catch (BadPropertyValueException e) {
        throw new InvalidMvp4gConfigurationException(String.format(GIN_MODULE_UNKNOWN_PROPERTY,
                                                                   module.getSimpleSourceName(),
                                                                   property,
                                                                   e.getMessage()));
      }
      modules.add(moduleClassName);
      propertiesValue[i] = moduleClassName;
    }
  } else {
    propertiesValue = null;
  }
  return propertiesValue;
}
 
Example #3
Source File: PropertyOracleStub.java    From mvp4g with Apache License 2.0 5 votes vote down vote up
public SelectionProperty getSelectionProperty(TreeLogger logger,
                                              String propertyName)
  throws BadPropertyValueException {
  SelectionProperty property = properties.get(propertyName);
  if (property == null) {
    throw new BadPropertyValueException("error");
  }
  return properties.get(propertyName);
}
 
Example #4
Source File: GssResourceGenerator.java    From gss.gwt with Apache License 2.0 5 votes vote down vote up
private String getObfuscationPrefix(PropertyOracle propertyOracle, ResourceContext context)
    throws BadPropertyValueException {
  String prefix = propertyOracle.getConfigurationProperty(KEY_OBFUSCATION_PREFIX)
      .getValues().get(0);
  if ("empty".equalsIgnoreCase(prefix)) {
    return "";
  } else if ("default".equalsIgnoreCase(prefix)) {
    return getDefaultObfuscationPrefix(context);
  }

  return prefix;
}
 
Example #5
Source File: ProductConfigGenerator.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String failFastGetProperty(PropertyOracle propertyOracle, String name) throws BadPropertyValueException {
    ConfigurationProperty property = propertyOracle.getConfigurationProperty(name);
    if (property != null) {
        List<String> values = property.getValues();
        if (values != null && !values.isEmpty()) {
            return values.get(0);
        } else {
            throw new BadPropertyValueException("Missing configuration property '" + name + "'!");
        }
    } else {
        throw new BadPropertyValueException("Missing configuration property '" + name + "'!");
    }
}
 
Example #6
Source File: ProductConfigGenerator.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String failSafeGetProperty(PropertyOracle propertyOracle, String name, String defaultValue) {
    String value = defaultValue;
    try {
        ConfigurationProperty property = propertyOracle.getConfigurationProperty(name);
        if (property != null) {
            List<String> values = property.getValues();
            if (values != null && !values.isEmpty()) {
                value = values.get(0);
            }
        }
    } catch (BadPropertyValueException e) {
        // ignore and return defaul value
    }
    return value;
}
 
Example #7
Source File: PropertyOracleStub.java    From mvp4g with Apache License 2.0 4 votes vote down vote up
public ConfigurationProperty getConfigurationProperty(String propertyName)
  throws BadPropertyValueException {
  // nothing to do
  return null;
}
 
Example #8
Source File: PropertyOracleStub.java    From mvp4g with Apache License 2.0 4 votes vote down vote up
public String getPropertyValue(TreeLogger logger,
                               String propertyName)
  throws BadPropertyValueException {
  // nothing to do
  return null;
}
 
Example #9
Source File: PropertyOracleStub.java    From mvp4g with Apache License 2.0 4 votes vote down vote up
public String[] getPropertyValueSet(TreeLogger logger,
                                    String propertyName)
  throws BadPropertyValueException {
  // TODO Auto-generated method stub
  return null;
}
 
Example #10
Source File: ProductConfigGenerator.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void generateMethods(final TreeLogger logger, SourceWriter sourceWriter, GeneratorContext context) throws Throwable {
    PropertyOracle propertyOracle = context.getPropertyOracle();

    // console.profile - mandatory
    String consoleProfile = failFastGetProperty(propertyOracle, "console.profile");
    sourceWriter.println("public ProductConfig.Profile getProfile() { ");
    sourceWriter.indent();
    if ("product".equals(consoleProfile)) {
        sourceWriter.println("return ProductConfig.Profile.PRODUCT;");
    } else if ("community".equals(consoleProfile)) {
        sourceWriter.println("return ProductConfig.Profile.COMMUNITY;");
    } else {
        throw new BadPropertyValueException(
                "Invalid value for 'console.profile'. Valid values are 'community' or 'product'!");
    }
    sourceWriter.outdent();
    sourceWriter.println("}");

    // console.core.version - mandatory
    String coreConsoleVersion = failFastGetProperty(propertyOracle, "console.core.version");
    sourceWriter.println("public String getCoreVersion() { ");
    sourceWriter.indent();
    sourceWriter.println("return \"%s\";", coreConsoleVersion);
    sourceWriter.outdent();
    sourceWriter.println("}");

    // hal.version - optional
    // If this is not built using the HAL release stream, this property is undefined
    String consoleVersion = failSafeGetProperty(propertyOracle, "hal.version", null);
    sourceWriter.println("public String getConsoleVersion() { ");
    sourceWriter.indent();
    if (consoleVersion == null) {
        sourceWriter.println("return null;");
    } else {
        sourceWriter.println("return \"%s\";", consoleVersion);
    }
    sourceWriter.outdent();
    sourceWriter.println("}");

    // getProductName() - delegates to the BootstrapContext
    sourceWriter.println("public String getProductName() { ");
    sourceWriter.indent();
    sourceWriter.println("return org.jboss.as.console.client.Console.MODULES.getBootstrapContext().getProductName();");
    sourceWriter.outdent();
    sourceWriter.println("}");

    // getProductVersion() - delegates to the BootstrapContext
    sourceWriter.println("public String getProductVersion() { ");
    sourceWriter.indent();
    sourceWriter.println("return org.jboss.as.console.client.Console.MODULES.getBootstrapContext().getProductVersion();");
    sourceWriter.outdent();
    sourceWriter.println("}");

    // supported locales
    LocaleUtils localeUtils = LocaleUtils.getInstance(logger, context.getPropertyOracle(), context);
    Set<GwtLocale> locales = localeUtils.getAllCompileLocales();
    sourceWriter.println("public List<String> getLocales() { ");
    sourceWriter.indent();
    sourceWriter.println("List<String> locales = new LinkedList<String>();");
    for (GwtLocale locale : locales) {
        if (locale.getAsString() != null && locale.getAsString().length() != 0) {
            sourceWriter.println("locales.add(\"" + locale.getAsString() + "\");");
        }
    }
    sourceWriter.println("return locales;");
    sourceWriter.outdent();
    sourceWriter.println("}");
}