implemented restoring of wiki tags from tag and bookmark database
This commit is contained in:
@@ -5,7 +5,7 @@ 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.ModuleRegistry.noteService;
|
||||
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;
|
||||
import static de.srsoftware.umbrella.core.model.Permission.EDIT;
|
||||
@@ -22,6 +22,7 @@ import de.srsoftware.umbrella.core.model.WikiPage;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class SqliteDb extends BaseDb implements WikiDb {
|
||||
private static final System.Logger LOG = System.getLogger("WikiDb");
|
||||
@@ -241,11 +242,34 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
|
||||
}
|
||||
var notes = noteService();
|
||||
var tags = tagService();
|
||||
for (var entry : pageMap.entrySet()){
|
||||
var oldId = entry.getKey();
|
||||
var newId = entry.getValue();
|
||||
notes.updateId("wiki",oldId,newId);
|
||||
}
|
||||
|
||||
var urls = bookmarkService().find("%/wiki/%/view");
|
||||
var pattern = Pattern.compile("/wiki/([^/]+)/view");
|
||||
|
||||
var users = userService().list(null,null,null);
|
||||
for (var entry : urls.entrySet()){
|
||||
var urlId = entry.getKey();
|
||||
var url = entry.getValue();
|
||||
var match = pattern.matcher(url);
|
||||
if (match.find()){
|
||||
var title = match.group(1);
|
||||
var pageId = pageMap.get(title);
|
||||
if (pageId == null) continue;
|
||||
for (var user : users.values()){
|
||||
var tagList = tags.getTags("bookmark",urlId,user);
|
||||
if (!tagList.isEmpty()){
|
||||
LOG.log(DEBUG,"{0} has tags for page {1}: {2}",user.name(),title,tagList);
|
||||
tags.save("wiki",pageId,List.of(user.id()),tagList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int wikiPermissionCode(Permission perm){
|
||||
|
||||
Reference in New Issue
Block a user