Skip to content

Commit 53e8082

Browse files
committed
2 parents b250671 + 1354a97 commit 53e8082

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

knowage-core/src/main/java/it/eng/spagobi/api/v2/DataSourceResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ public Response testDataSource(IDataSource dataSource) throws Exception {
418418
throw new SpagoBIRestServiceException("Driver not found: " + driver, buildLocaleFromSession(), e);
419419
}
420420

421-
try (Connection connection = DriverManager.getConnection(url, user, pwd)) {
421+
try (Connection connection = DriverManager.getConnection(url, user, pwd == null ? dataSource.getPwd() : pwd)) {
422422
LOGGER.debug("Connection performed successfully");
423423
} catch (SQLException sqlException) {
424424
LOGGER.error("Connection failure", sqlException);

knowage-core/src/main/java/it/eng/spagobi/tools/dataset/service/ManageDataSetsForREST.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ protected IDataSet getGuiGenericDatasetToInsert(JSONObject json, UserProfile use
466466
IDataSet existingDataSet = null;
467467

468468
try {
469-
existingDataSet = DAOFactory.getDataSetDAO().loadDataSetById(new Integer(id));
469+
existingDataSet = DAOFactory.getDataSetDAO().loadDataSetById(Integer.parseInt(id));
470470
} catch (Exception e) {
471471
LOGGER.error("Error while getting dataset metadataa", e);
472472
throw e;
@@ -1665,12 +1665,6 @@ protected String datasetInsert(IDataSet ds, IDataSetDAO dsDao, Locale locale, Us
16651665

16661666
if (ds != null) {
16671667

1668-
List<String> persistenceTableNames = dsDao.loadPersistenceTableNames(ds.getId());
1669-
1670-
if (persistenceTableNames.stream().anyMatch(tableName -> tableName != null && !tableName.isBlank() && tableName.equalsIgnoreCase(ds.getPersistTableName()))) {
1671-
throw new SpagoBIRuntimeException("The persistence table with name <" + ds.getPersistTableName().toUpperCase(Locale.ROOT) + "> already exists");
1672-
}
1673-
16741668
String dsLabel = ds.getLabel();
16751669
String dsName = ds.getName();
16761670
logParam.put("NAME", dsName);
@@ -1681,9 +1675,16 @@ protected String datasetInsert(IDataSet ds, IDataSetDAO dsDao, Locale locale, Us
16811675
IDataSet existingByName = dsDao.loadDataSetByName(ds.getName());
16821676
IDataSet existingByLabel = dsDao.loadDataSetByLabel(ds.getLabel());
16831677

1684-
if (id != null && !id.equals("") && !id.equals("0")) {
1678+
if (id != null && !id.isEmpty() && !id.equals("0")) {
16851679
validateLabelAndName(id, dsName, dsLabel, existingByName, existingByLabel);
1686-
ds.setId(Integer.valueOf(id));
1680+
ds.setId(Integer.parseInt(id));
1681+
1682+
List<String> persistenceTableNames = dsDao.loadPersistenceTableNames(ds.getId());
1683+
1684+
if (persistenceTableNames.stream().anyMatch(tableName -> tableName != null && !tableName.isBlank() && tableName.equalsIgnoreCase(ds.getPersistTableName()))) {
1685+
throw new SpagoBIRuntimeException("The persistence table with name <" + ds.getPersistTableName().toUpperCase(Locale.ROOT) + "> already exists");
1686+
}
1687+
16871688
IDataSet existingDataset = dsDao.loadDataSetById(Integer.valueOf(id));
16881689
clearCacheForDataset(existingDataset);
16891690

0 commit comments

Comments
 (0)