List of usage examples for java.util InvalidPropertiesFormatException InvalidPropertiesFormatException
public InvalidPropertiesFormatException(String message)
From source file:edu.usc.goffish.gofs.namenode.DataNode.java
private DataNode(Path dataNodePath) throws IOException { _dataNodePath = dataNodePath.normalize().toAbsolutePath(); _dataNodeSliceDirPath = _dataNodePath.resolve(DATANODE_SLICE_DIR); _config = new PropertiesConfiguration(); _config.setDelimiterParsingDisabled(true); try {//from w w w.ja va 2 s.c o m _config.load(Files.newInputStream(_dataNodePath.resolve(DATANODE_CONFIG))); } catch (ConfigurationException e) { throw new IOException(e); } // ensure this is valid data node boolean installed = _config.getBoolean(DATANODE_INSTALLED_KEY); if (!installed) { throw new InvalidPropertiesFormatException( "data node config must contain key " + DATANODE_INSTALLED_KEY); } // retrieve localhost uri { String localhostString = _config.getString(DATANODE_LOCALHOSTURI_KEY); if (localhostString == null) { throw new InvalidPropertiesFormatException( "data node config must contain key " + DATANODE_LOCALHOSTURI_KEY); } try { _localhostURI = new URI(localhostString); } catch (URISyntaxException e) { throw new InvalidPropertiesFormatException("data node config key " + DATANODE_LOCALHOSTURI_KEY + " has invalid format - " + e.getMessage()); } } // retrieve name node try { _nameNode = NameNodeProvider.loadNameNodeFromConfig(_config, DATANODE_NAMENODE_TYPE_KEY, DATANODE_NAMENODE_LOCATION_KEY); } catch (ReflectiveOperationException e) { throw new RuntimeException("Unable to load name node", e); } // retrieve slice manager _sliceSerializer = _nameNode.getSerializer(); }
From source file:com.publicuhc.pluginframework.translate.YamlControl.java
@Override public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException { Validate.notNull(baseName);/* ww w . j a v a 2 s . c o m*/ Validate.notNull(locale); Validate.notNull(format); Validate.notNull(loader); String bundleName = toBundleName(baseName, locale); //we only know how to handle yml, if its a properties send to parent method if (!format.equals("yml")) { return super.newBundle(bundleName, locale, format, loader, reload); } //get the actual name of the file String resourceName = toResourceName(bundleName, format); try { Optional<FileConfiguration> file = YamlUtil.loadConfigWithDefaults(resourceName, loader, dataDir); if (!file.isPresent()) { //say we couldn't find it return null; } return new YamlResourceBundle(file.get()); } catch (InvalidConfigurationException e) { throw new InvalidPropertiesFormatException(e); } }
From source file:ru.gkpromtech.exhibition.db.Table.java
protected Table(Class<T> entityClass, SQLiteOpenHelper sqlHelper) throws InvalidPropertiesFormatException { mEntityClass = entityClass;// w ww . j a v a 2 s. co m mSqlHelper = sqlHelper; TableRef tableRef = entityClass.getAnnotation(TableRef.class); mTableName = tableRef.name(); // mTr = tableRef.tr(); List<Field> fields = new ArrayList<>(); for (Field field : mEntityClass.getFields()) if (!Modifier.isStatic(field.getModifiers())) fields.add(field); List<FkInfo> fks = new ArrayList<>(); mFields = fields.toArray(new Field[fields.size()]); mColumns = new String[mFields.length]; mType = new int[mFields.length]; for (int i = 0; i < mFields.length; ++i) { Field field = mFields[i]; mColumns[i] = field.getName(); switch (field.getType().getSimpleName()) { case "int": case "Integer": mType[i] = INTEGER; break; case "Short": case "short": mType[i] = SHORT; break; case "long": case "Long": mType[i] = LONG; break; case "float": case "Float": mType[i] = FLOAT; break; case "double": case "Double": mType[i] = DOUBLE; break; case "String": mType[i] = STRING; break; case "byte[]": mType[i] = BYTE_ARRAY; break; case "Date": mType[i] = DATE; break; case "boolean": mType[i] = BOOLEAN; break; default: throw new InvalidPropertiesFormatException( "Unsupported type: " + field.getType().getCanonicalName()); } FK fk = field.getAnnotation(FK.class); if (fk != null) fks.add(new FkInfo(fk.entity(), fk.field(), field.getName())); } mFks = fks.toArray(new FkInfo[fks.size()]); }
From source file:ru.gkpromtech.exhibition.db.Table.java
public String getCreateQuery() throws InvalidPropertiesFormatException { String query = "CREATE TABLE " + mTableName + " ("; for (int i = 0; i < mFields.length; ++i) { Field field = mFields[i]; if (i != 0) query += ","; query += "\n " + field.getName() + " " + getSqlType(mType[i]); String clauses = ""; boolean isNull = false; boolean isTr = false; boolean isAutoincrement = false; for (Annotation annotation : field.getDeclaredAnnotations()) { if (annotation instanceof Null) { isNull = true;/*w w w. j a v a 2 s . co m*/ } else if (annotation instanceof Translatable) { isTr = true; } else if (annotation instanceof FK) { FK refs = (FK) annotation; clauses += " REFERENCES " + refs.entity().getAnnotation(TableRef.class).name() + "(" + refs.field() + ")"; if (!refs.onDelete().isEmpty()) clauses += " ON DELETE " + refs.onDelete(); if (!refs.onUpdate().isEmpty()) clauses += " ON UPDATE " + refs.onUpdate(); } else if (annotation instanceof PK) { clauses += " PRIMARY KEY"; if (isAutoincrement) clauses += " AUTOINCREMENT"; } else if (annotation instanceof Autoincrement) { isAutoincrement = true; } else if (annotation instanceof Unique) { clauses += " UNIQUE"; } else if (annotation instanceof Default) { clauses += " DEFAULT('" + ((Default) annotation).value() + "')"; } else { throw new InvalidPropertiesFormatException( "Unsupported annotation [" + annotation.getClass().getCanonicalName() + "] for entity [" + mEntityClass.getCanonicalName() + "]"); } } if (!isNull && !isTr) query += " NOT"; query += " NULL" + clauses; } query += ");"; return query; }