public void setSchemaName(String schemaName) { this.schemaName = StringUtils.trimToNull(schemaName); }
protected Date parseDate(String date) throws ParseException { ISODateFormat isoFormat = new ISODateFormat(); try { return isoFormat.parse(date); } catch (ParseException e) { DateFormat format = DateFormat.getDateInstance(); try { return format.parse(date); } catch (ParseException e1) { throw new ParseException("Date must match ISODateFormat or STANDARD platform format.\n"+e.getMessage(), 0); } } } }
@Transient @JsonProperty("avatar") public String getAvatar() { return "https://www.gravatar.com/avatar/" + MD5Util.computeMD5(getUsername()); }
@Override public String toString() { String description; if (classLoader instanceof URLClassLoader) { List<String> urls = new ArrayList<String>(); for (URL url : ((URLClassLoader) classLoader).getURLs()) { urls.add(url.toExternalForm()); } description = StringUtils.join(urls, ","); } else { description = classLoader.getClass().getName(); } return getClass().getName() + "(" + description + ")"; } }
private boolean isAllEmpty(Row row, int startCol) { for (int i = startCol; i < row.getLastCellNum(); i++) { Cell cell = row.getCell(i); if (cell != null && StringUtils.isNotEmpty(getCellValue(cell))) { return false; } } return true; }
private void setName(String originName) { this.name = originName; if (originName.startsWith("*")) { name = originName.substring(1); gen = true; } else if (originName.startsWith("#")) { unique = true; name = originName.substring(1); } int sem = name.indexOf(':'); if (sem > 0) { String localLang = name.substring(sem + 1); name = name.substring(0, sem); if (StringUtils.isEmpty(localLang)) { throw new LiquibaseException("invalid tl language :" + name); } this.lang = localLang; } int lb = name.indexOf('('); if (lb > 0) { type = name.substring(lb + 1, name.indexOf(')')).trim(); name = name.substring(0, lb).trim(); } }
@PostConstruct public void onStartup() { log.info(LogType.LOG, "Booting Liquibase " + LiquibaseUtil.getBuildVersion()); String hostName; try { hostName = NetUtil.getLocalHostName(); } catch (Exception e) { log.warning(LogType.LOG, "Cannot find hostname: " + e.getMessage()); log.debug(LogType.LOG, "", e); return; } LiquibaseConfiguration liquibaseConfiguration = LiquibaseConfiguration.getInstance(); if (!liquibaseConfiguration.getConfiguration(GlobalConfiguration.class).getShouldRun()) { log.info(LogType.LOG, String.format("Liquibase did not run on %s because %s was set to false.", hostName, liquibaseConfiguration.describeValueLookupLogic( GlobalConfiguration.class, GlobalConfiguration.SHOULD_RUN) )); return; } initialized = true; try { performUpdate(); } catch (LiquibaseException e) { throw new UnexpectedLiquibaseException(e); } }
public DatabaseDataType toDatabaseDataType(Database database) { if (database instanceof HibernateSpringDatabase) { String originalDefinition = StringUtils.trimToEmpty(getRawDefinition()); return new DatabaseDataType(originalDefinition.toUpperCase(), getParameters()); } // use defaults for all the others return super.toDatabaseDataType(database); } }
public void configureFieldsAndValues(ResourceAccessor fo) throws MojoExecutionException, MojoFailureException { // Load the properties file if there is one, but only for values that the user has not // already specified. if (propertyFile != null) { getLog().info("Parsing Liquibase Properties File"); getLog().info(" File: " + propertyFile); InputStream is; try { is = StreamUtil.singleInputStream(propertyFile, fo); } catch (IOException e) { throw new UnexpectedLiquibaseException(e); } if (is == null) { throw new MojoFailureException("Failed to resolve the properties file."); } parsePropertiesFile(is); getLog().info(MavenUtils.LOG_SEPARATOR); } }
private void setProperty(final Object object, final String attributeName, final String attributeValue) throws IllegalAccessException, InvocationTargetException, CustomChangeException { if (object instanceof CustomChangeWrapper) { if (attributeName.equals("class")) { ((CustomChangeWrapper) object).setClass(changeLogParameters.expandExpressions(attributeValue)); } else { ((CustomChangeWrapper) object).setParam(attributeName, changeLogParameters.expandExpressions(attributeValue)); } } else { ObjectUtil.setProperty(object, attributeName, changeLogParameters.expandExpressions(attributeValue)); } }
private void outputChangeLogTableCreationScript(Liquibase liquibase, final Writer exportWriter) throws DatabaseException { Database database = liquibase.getDatabase(); Executor oldTemplate = ExecutorService.getInstance().getExecutor(database); LoggingExecutor executor = new LoggingExecutor(ExecutorService.getInstance().getExecutor(database), exportWriter, database); ExecutorService.getInstance().setExecutor(database, executor); executor.comment("*********************************************************************"); executor.comment("* Keycloak database creation script - apply this script to empty DB *"); executor.comment("*********************************************************************" + StreamUtil.getLineSeparator()); executor.execute(new CreateDatabaseChangeLogTableStatement()); // DatabaseChangeLogLockTable is created before this code is executed and recreated if it does not exist automatically // in org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService.init() called indirectly from // KeycloakApplication constructor (search for waitForLock() call). Hence it is not included in the creation script. executor.comment("*********************************************************************" + StreamUtil.getLineSeparator()); ExecutorService.getInstance().setExecutor(database, oldTemplate); }
@Override public ValidationErrors validate(RefreshMaterializedViewStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors validationErrors = new ValidationErrors(); validationErrors.checkRequiredField("viewName", StringUtils.trimToNull(statement.getViewName())); validationErrors.checkRequiredField("refreshType", StringUtils.trimToNull(statement.getRefreshType())); validationErrors.checkRequiredField("atomicRefresh", statement.getAtomicRefresh()); return validationErrors; }
public String getPermissionList() { List<String> permissions = new ArrayList<String>(5); if ( getSelect() ) { permissions.add( "SELECT" ); } if ( getUpdate() ) { permissions.add( "UPDATE" ); } if ( getInsert() ) { permissions.add( "INSERT" ); } if ( getDelete() ) { permissions.add( "DELETE" ); } if ( getExecute() ) { permissions.add( "EXECUTE" ); } return StringUtils.join(permissions, ","); }
private boolean isAllEmpty(Row row, int startCol) { for (int i = startCol; i < row.getLastCellNum(); i++) { Cell cell = row.getCell(i); if (cell != null && StringUtils.isNotEmpty(getCellValue(cell))) { return false; } } return true; }
private void setName(String originName) { this.name = originName; if (originName.startsWith("*")) { name = originName.substring(1); gen = true; } else if (originName.startsWith("#")) { unique = true; name = originName.substring(1); } int sem = name.indexOf(':'); if (sem > 0) { String localLang = name.substring(sem + 1); name = name.substring(0, sem); if (StringUtils.isEmpty(localLang)) { throw new LiquibaseException("invalid tl language :" + name); } this.lang = localLang; } int lb = name.indexOf('('); if (lb > 0) { type = name.substring(lb + 1, name.indexOf(')')).trim(); name = name.substring(0, lb).trim(); } }
protected DataType toDataType(String hibernateType, Integer sqlTypeCode) throws DatabaseException { Matcher matcher = pattern.matcher(hibernateType); if (!matcher.matches()) { return null; } DataType dataType = new DataType(matcher.group(1)); if (matcher.group(3).isEmpty()) { if (!matcher.group(2).isEmpty()) dataType.setColumnSize(Integer.parseInt(matcher.group(2))); } else { dataType.setColumnSize(Integer.parseInt(matcher.group(2))); dataType.setDecimalDigits(Integer.parseInt(matcher.group(3))); } String extra = StringUtils.trimToNull(matcher.group(4)); if (extra != null) { if (extra.equalsIgnoreCase("char")) { dataType.setColumnSizeUnit(DataType.ColumnSizeUnit.CHAR); } } dataType.setDataTypeId(sqlTypeCode); return dataType; }
private boolean tableRowIsEmpty(TableData.TableRow tableRow) { return Optional.ofNullable(tableRow).map(row -> { List<TableData.TableCellValue> tableCellValues = row.getTableCellValues(); boolean allBlank = true; for (TableData.TableCellValue cell : tableCellValues) { if (StringUtils.isNotEmpty(cell.getValue())) { allBlank = false; break; } } return allBlank; }).orElse(true); }
protected Database createDatabase(Connection c, ResourceAccessor resourceAccessor) throws DatabaseException { Object liquibaseConnection; if (c == null) { this.log.warning("Null connection returned by liquibase datasource. Using offline unknown database"); liquibaseConnection = new OfflineConnection("offline:unknown", resourceAccessor); } else { liquibaseConnection = new JdbcConnection(c); } Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation((DatabaseConnection)liquibaseConnection); if (StringUtils.trimToNull(this.defaultSchema) != null) { database.setDefaultSchemaName(this.defaultSchema); } return database; }
private boolean tableRowIsEmpty(TableData.TableRow tableRow) { return Optional.ofNullable(tableRow).map(row -> { List<TableData.TableCellValue> tableCellValues = row.getTableCellValues(); boolean allBlank = true; for (TableData.TableCellValue cell : tableCellValues) { if (StringUtils.isNotEmpty(cell.getValue())) { allBlank = false; break; } } return allBlank; }).orElse(true); }
protected String getFieldString(String fieldName) { for (FieldExtension fieldExtension : decisionTask.getFieldExtensions()) { if (fieldName.equals(fieldExtension.getFieldName())) { if (StringUtils.isNotEmpty(fieldExtension.getStringValue())) { return fieldExtension.getStringValue(); } else if (StringUtils.isNotEmpty(fieldExtension.getExpression())) { return fieldExtension.getExpression(); } } } return null; }