/** {@inheritDoc} */ @Override public void execute() { if (database == null) { throw new BuildException("database attribute is not set"); } if (user == null) { throw new BuildException("user attribute is not set"); } if (perm == null) { throw new BuildException("perm attribute is not set"); } try { Database db = DatabaseFactory.getDatabase(database); DatabaseUtil.grant(db, user, perm); } catch (Exception e) { throw new BuildException(e); } }
/** * Run the task * * @throws BuildException if a problem occurs */ @Override public void execute() { if (clsName == null) { throw new BuildException("clsName attribute is not set"); } if (getOsName() == null) { throw new BuildException("osName attribute is not set"); } if (getModelName() == null) { throw new BuildException("modelName attribute is not set"); } if (dbAlias == null) { throw new BuildException("dbAlias attribute is not set"); } try { ObjectStoreWriter osw = ObjectStoreWriterFactory.getObjectStoreWriter(getOsName()); ObjectStoreItemWriter writer = new ObjectStoreItemWriter(osw); Database database = DatabaseFactory.getDatabase(dbAlias); Class<?> c = Class.forName(clsName); if (!DBConverter.class.isAssignableFrom(c)) { throw new IllegalArgumentException( "Class (" + clsName + ") is not a subclass of " + DBConverter.class.getName()); } Constructor<?> m = c.getConstructor(new Class[] {Database.class, Model.class, ItemWriter.class}); Model model = Model.getInstanceByName(getModelName()); DBConverter converter = (DBConverter) m.newInstance(new Object[] {database, model, writer}); configureDynamicAttributes(converter); converter.process(); converter.close(); converter.getItemWriter().close(); osw.close(); } catch (Exception e) { throw new BuildException("problem while running converter reading from db: " + dbAlias, e); } }