init.properties增加配置
--comp-name-1=message-archive
--comp-class-1=tigase.archive.MessageArchiveComponent
message-archive/archive-repo-uri=jdbc:mysql://192.168.1.15:3306/tigasedb?user=tigase&password=tigase&useUnicode=true&characterEncoding=UTF-8
--sm-plugins=+message-archive-xep-0136
sess-man/plugins-conf/message-archive-xep-0136/component-jid=message-archive@s3-1
sess-man/plugins-conf/message-archive-xep-0136/default-store-method=body
sess-man/plugins-conf/message-archive-xep-0136/required-store-method=body
历史记录全部保存,和记录类型指定为body,修改类MessageArchivePlugin
//~--- get methods ----------------------------------------------------------
private boolean getAutoSave(final XMPPResourceConnection session)
throws NotAuthorizedException {
/** comment by guahao
if (requiredStoreMethod != StoreMethod.False)
return true;
Boolean auto = (Boolean) session.getCommonSessionData(ID + "/" + AUTO);
if (auto == null) {
try {
String data = session.getData(SETTINGS, AUTO, "false");
auto = Boolean.parseBoolean(data);
session.putCommonSessionData(ID + "/" + AUTO, auto);
} catch (TigaseDBException ex) {
log.log(Level.WARNING, "Error getting Message Archive state: {0}", ex
.getMessage());
auto = false;
}
}
return auto;
**/
//modified for all save;
return true;
}
private StoreMethod getStoreMethod(XMPPResourceConnection session)
throws NotAuthorizedException {
/**comment by guahao
StoreMethod save = (StoreMethod) session.getCommonSessionData(ID + "/" + DEFAULT_SAVE);
if (save == null) {
try {
String data = session.getData(SETTINGS, DEFAULT_SAVE, defaultStoreMethod.toString());
save = StoreMethod.valueof(data);
session.putCommonSessionData(ID + "/" + DEFAULT_SAVE, save);
} catch (TigaseDBException ex) {
log.log(Level.WARNING, "Error getting Message Archive state: {0}", ex
.getMessage());
save = StoreMethod.False;
}
}
if (save.ordinal() < requiredStoreMethod.ordinal()) {
save = requiredStoreMethod;
session.putCommonSessionData(ID + "/" + DEFAULT_SAVE, save);
try {
setStoreMethod(session, save);
} catch (TigaseDBException ex) {
log.log(Level.WARNING, "Error updating message archiving level to required level {0}", ex.getMessage());
}
}
return save;
**/
StoreMethod save = requiredStoreMethod;
session.putCommonSessionData(ID + "/" + DEFAULT_SAVE, save);
try {
setStoreMethod(session, save);
} catch (TigaseDBException ex) {
log.log(Level.WARNING, "Error updating message archiving level to required level {0}", ex.getMessage());
}
return save;
}
|