* @param topMsg
* @return the moved message
*/
@SuppressWarnings("unchecked")
public Message moveMessage(Message msg, Message topMsg) {
DB db = DBFactory.getInstance();
List<Message> oldThreadList = getThread(msg.getThreadtop().getKey());
List<Message> subThreadList = new ArrayList<Message>();
this.getSubthread(msg, oldThreadList, subThreadList);
// one has to set a new parent for all childs of the moved message
// first message of sublist has to get the parent from the moved message
for(Message childMessage : subThreadList) {
childMessage = (Message)db.loadObject(childMessage);
childMessage.setParent(msg.getParent());
updateMessage(childMessage, null);
}
// now move the message to the choosen thread
Message oldMessage = (Message)db.loadObject(msg);
Message message = createMessage();
message.setCreator(oldMessage.getCreator());
message.setForum(oldMessage.getForum());
message.setModifier(oldMessage.getModifier());
message.setTitle(oldMessage.getTitle());