working on wiki db transition
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -9,11 +9,14 @@ import static de.srsoftware.umbrella.core.ResponseCode.HTTP_UNPROCESSABLE;
|
||||
import static de.srsoftware.umbrella.core.Util.mapValues;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
|
||||
import static de.srsoftware.umbrella.notes.Constants.CONFIG_DATABASE;
|
||||
import static de.srsoftware.umbrella.notes.Constants.TABLE_NOTES;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import de.srsoftware.configuration.Configuration;
|
||||
import de.srsoftware.tools.Path;
|
||||
import de.srsoftware.tools.SessionToken;
|
||||
import de.srsoftware.tools.jdbc.Condition;
|
||||
import de.srsoftware.tools.jdbc.Query;
|
||||
import de.srsoftware.umbrella.core.BaseHandler;
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
import de.srsoftware.umbrella.core.api.NoteService;
|
||||
@@ -180,4 +183,8 @@ public class NoteModule extends BaseHandler implements NoteService {
|
||||
return notesDb.save(note);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateId(String module, Object oldId, Object newId) {
|
||||
notesDb.updateId(module,oldId,newId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,4 +29,6 @@ public interface NotesDb {
|
||||
Note load(long noteId);
|
||||
|
||||
Note save(Note note);
|
||||
|
||||
void updateId(String module, Object oldId, Object newId);
|
||||
}
|
||||
|
||||
@@ -6,6 +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.exceptions.UmbrellaException.databaseException;
|
||||
import static de.srsoftware.umbrella.notes.Constants.*;
|
||||
import static java.lang.System.Logger.Level.*;
|
||||
import static java.text.MessageFormat.format;
|
||||
@@ -177,7 +178,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
rs.close();
|
||||
return notes;
|
||||
} catch (SQLException e) {
|
||||
throw new UmbrellaException("Failed to search notes");
|
||||
throw databaseException("Failed to search notes");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +195,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
rs.close();
|
||||
return notes;
|
||||
} catch (SQLException e) {
|
||||
throw new UmbrellaException("Failed to load notes");
|
||||
throw databaseException("Failed to load notes");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +211,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
rs.close();
|
||||
return notes;
|
||||
} catch (SQLException e) {
|
||||
throw new UmbrellaException("Failed to load notes");
|
||||
throw databaseException("Failed to load notes");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +224,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
rs.close();
|
||||
return note;
|
||||
} catch (SQLException e) {
|
||||
throw new UmbrellaException("Failed to load note {0}",noteId);
|
||||
throw databaseException("Failed to load note {0}",noteId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +248,16 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
}
|
||||
return note;
|
||||
} catch (SQLException e){
|
||||
throw new UmbrellaException("Failed to save note: {0}",note.text());
|
||||
throw databaseException("Failed to save note: {0}",note.text());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateId(String module, Object oldId, Object newId) {
|
||||
try {
|
||||
update(TABLE_NOTES).set(ENTITY_ID).where(MODULE,equal(module)).where(ENTITY_ID,equal(oldId)).prepare(db).apply(newId).close();
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to update {0}.{1} → {0}.{2}",module,oldId,newId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user