working on backend-side translations
This commit is contained in:
@@ -6,7 +6,7 @@ import static de.srsoftware.tools.jdbc.Condition.like;
|
||||
import static de.srsoftware.tools.jdbc.Query.*;
|
||||
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.Constants.ERROR_FAILED_CREATE_TABLE;
|
||||
import static de.srsoftware.umbrella.core.Errors.*;
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.*;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.notFound;
|
||||
@@ -85,8 +85,7 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR, ERROR_FAILED_CREATE_TABLE, newPages, e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,newPages).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,8 +96,7 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR, ERROR_FAILED_CREATE_TABLE, TABLE_PAGES, e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_PAGES).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +107,7 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR, ERROR_FAILED_CREATE_TABLE, TABLE_PAGES, e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_PAGES_USERS).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +117,7 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
delete().from(TABLE_PAGES).where(ID,equal(page.id())).where(VERSION,equal(page.version())).execute(db);
|
||||
return page;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to delete page version!");
|
||||
throw databaseException(FAILED_TO_DROP_ENTITY,"page version").causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,14 +125,12 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
try {
|
||||
db.prepareStatement(format("DROP TABLE {0}",TABLE_PAGES)).execute();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR, "Failed to drop table {0}", TABLE_PAGES, e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_DROP_ENTITY,TABLE_PAGES).causedBy(e);
|
||||
}
|
||||
try {
|
||||
db.prepareStatement(format("DROP TABLE {0}",TABLE_PAGES_USERS)).execute();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR, "Failed to drop table {0}", TABLE_PAGES, e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_DROP_ENTITY,TABLE_PAGES_USERS).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +143,7 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
rs.close();
|
||||
return id+1;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to query next free page id!");
|
||||
throw databaseException(FAILED_TO_GET_FREE_ID).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +161,7 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
rs.close();
|
||||
return map;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to search \"{0}\" in wiki pages",String.join(" "+keys));
|
||||
throw databaseException(FAILED_TO_SEARCH_DB,"wiki pages").causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +175,7 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
rs.close();
|
||||
return count < 1;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to query availability of {0}!",title);
|
||||
throw databaseException(FAILED_TO_CHECK_ENTITY_AVAILABLE,title).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +188,7 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
rs.close();
|
||||
return set;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to list wiki articles for user {0}",userId);
|
||||
throw databaseException(FAILED_TO_LIST_ENTITIES,"wiki pages").causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +209,7 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
} catch (NumberFormatException ignored){
|
||||
// title is not an id, go on…
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to load wiki page \"{0}\" from database!",title);
|
||||
throw databaseException(FAILED_TO_LOAD_ENTITY_BY_ID,"wiki page",title).causedBy(e);
|
||||
}
|
||||
if (page == null) try { // page was not loaded by ID
|
||||
var query = select(ALL).from(TABLE_PAGES).where(TITLE, equal(title));
|
||||
@@ -227,9 +222,9 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
if (rs.next()) page = WikiPage.of(rs);
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to load wiki page \"{0}\" from database!",title);
|
||||
throw databaseException(FAILED_TO_LOAD_ENTITY_BY_ID,"wiki page",title).causedBy(e);
|
||||
}
|
||||
if (page == null) throw notFound("Failed to load wiki page \"{0}\" from database!",title);
|
||||
if (page == null) throw notFound(FAILED_TO_LOAD_ENTITY_BY_ID,"wiki page",title);
|
||||
try {
|
||||
var rs = select(VERSION).from(TABLE_PAGES).where(ID, equal(page.id())).sort(VERSION).exec(db);
|
||||
var versions = page.versions();
|
||||
@@ -237,7 +232,7 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
rs.close();
|
||||
return page;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to load wiki page \"{0}\" from database!",title);
|
||||
throw databaseException(FAILED_TO_LOAD_ENTITY_BY_ID,"wiki page",title).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +248,7 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
rs.close();
|
||||
return map;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to load members of \"{0}\" from database!",page.title());
|
||||
throw databaseException(FAILED_TO_LOAD_ENTITY_MEMBERS,"wiki page",page.title()).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,14 +256,12 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
try {
|
||||
db.prepareStatement(format("ALTER TABLE {0} RENAME TO {1}",newPages,TABLE_PAGES)).execute();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR, "Failed to rename table {0} → {1}", newPages, TABLE_PAGES, e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_UPDATE_TABLE,format("{0} → {1}", newPages, TABLE_PAGES)).causedBy(e);
|
||||
}
|
||||
try {
|
||||
db.prepareStatement(format("ALTER TABLE {0} RENAME TO {1}",newUsers,TABLE_PAGES_USERS)).execute();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR, "Failed to rename table {0} → {1}", newUsers, TABLE_PAGES_USERS, e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_UPDATE_TABLE,format("{0} → {1}", newPages, TABLE_PAGES_USERS)).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +285,7 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
}
|
||||
return page;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to write wiki page \"{0}\" to database",page.title(),e);
|
||||
throw databaseException(FAILED_TO_STORE_ENTITY,page.title()).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,9 +327,7 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,"Failed to transfer entries from {0} → {0}_new!",TABLE_PAGES,e);
|
||||
throw new RuntimeException(e);
|
||||
|
||||
throw databaseException(FAILED_TO_MOVE,TABLE_PAGES,TABLE_PAGES+"_new").causedBy(e);
|
||||
}
|
||||
var notes = noteService();
|
||||
var tags = tagService();
|
||||
|
||||
Reference in New Issue
Block a user