提交 928bdbc1 编写于 作者: O o2null

Merge branch 'feature/messages' into 'develop'

升级messages配置文件

See merge request o2oa/o2oa!866
......@@ -27,11 +27,11 @@ import com.x.base.core.project.config.ConfigObject;
import com.x.base.core.project.config.Dingding;
import com.x.base.core.project.config.DumpRestoreData;
import com.x.base.core.project.config.Exmail;
import com.x.base.core.project.config.General;
import com.x.base.core.project.config.HuaweiPushConfig;
import com.x.base.core.project.config.JpushConfig;
import com.x.base.core.project.config.MPweixin;
import com.x.base.core.project.config.Messages;
import com.x.base.core.project.config.General;
import com.x.base.core.project.config.Node;
import com.x.base.core.project.config.Person;
import com.x.base.core.project.config.Portal;
......@@ -55,8 +55,6 @@ import com.x.base.core.project.tools.DefaultCharset;
*/
public class CreateConfigSample {
private static final Logger LOGGER = LoggerFactory.getLogger(CreateConfigSample.class);
private static final String DEFAULTINSTANCE = "defaultInstance";
public static void main(String... args) throws Exception {
......
......@@ -28,26 +28,15 @@ public class Message extends GsonPropertyObject {
Gson gson = XGsonBuilder.instance();
if (null != consumers) {
for (String arg : conusmers) {
// this.consumersV2.put(arg, "");
this.consumers.add(gson.toJsonTree(concreteConsumer(arg)));
}
}
}
// public Message(Map<String, String> map) {
// if (map != null) {
// this.consumersV2.putAll(map);
// }
// }
public static Message defaultInstance() {
return new Message();
}
// @FieldDescribe("早期配置,已经废弃")
// @Deprecated
// private Map<String, String> consumersV2 = new HashMap<>();
@FieldDescribe("消费通道配置")
private List<JsonElement> consumers = new ArrayList<>();
......@@ -62,14 +51,6 @@ public class Message extends GsonPropertyObject {
return consumers;
}
// public Map<String, String> getConsumersV2() {
// return consumersV2;
// }
//
// public void setConsumersV2(Map<String, String> consumersV2) {
// this.consumersV2 = consumersV2;
// }
public static class Consumer implements Serializable {
private static final long serialVersionUID = 392932139617988800L;
......@@ -81,11 +62,14 @@ public class Message extends GsonPropertyObject {
private static final String DEFAULT_LOADER = "";
private static final String DEFAULT_FILTER = "";
private static final String DEFAULT_CONSUMER = "";
public Consumer() {
this.type = DEFAULT_TYPE;
this.enable = DEFAULT_ENABLE;
this.loader = DEFAULT_LOADER;
this.filter = DEFAULT_FILTER;
this.consumer = DEFAULT_CONSUMER;
}
public Consumer(String type, boolean enable) {
......@@ -93,6 +77,7 @@ public class Message extends GsonPropertyObject {
this.enable = enable;
this.loader = DEFAULT_LOADER;
this.filter = DEFAULT_FILTER;
this.consumer = DEFAULT_CONSUMER;
}
public Consumer(String type) {
......@@ -109,6 +94,8 @@ public class Message extends GsonPropertyObject {
private String loader;
@FieldDescribe("过滤脚本")
private String filter;
@FieldDescribe("配置项")
private String consumer;
public Boolean getEnable() {
return (null == this.enable) ? DEFAULT_ENABLE : this.enable;
......@@ -125,6 +112,10 @@ public class Message extends GsonPropertyObject {
public String getLoader() {
return StringUtils.isBlank(this.loader) ? DEFAULT_LOADER : this.loader;
}
public String getConsumer() {
return StringUtils.isBlank(this.consumer) ? DEFAULT_CONSUMER: this.consumer;
}
}
......
package com.x.base.core.project.config;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -32,9 +35,9 @@ import com.x.base.core.project.config.Message.ZhengwudingdingConsumer;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.message.MessageConnector;
public class Messages extends ConcurrentSkipListMap<String, Message> {
public class Messages extends ConfigObject {
private static final long serialVersionUID = 1336172131736006743L;
private static final long serialVersionUID = 7251058521510812856L;
private static final Message MESSAGE_ALL = new Message(MessageConnector.CONSUME_WS,
MessageConnector.CONSUME_PMS_INNER, MessageConnector.CONSUME_DINGDING, MessageConnector.CONSUME_WELINK,
......@@ -58,77 +61,694 @@ public class Messages extends ConcurrentSkipListMap<String, Message> {
super();
}
@FieldDescribe("消费器配置.")
private Map<String, JsonElement> consumers = new LinkedHashMap<>();
@FieldDescribe("装载器脚本.")
private Map<String, String> loaders = new LinkedHashMap<>();
@FieldDescribe("过滤器脚本.")
private Map<String, String> filters = new LinkedHashMap<>();
@FieldDescribe("创建应用.")
private Message application_create;
@FieldDescribe("更新应用.")
private Message application_update;
@FieldDescribe("删除应用.")
private Message application_delete;
@FieldDescribe("创建流程.")
private Message process_create;
@FieldDescribe("更新流程.")
private Message process_update;
@FieldDescribe("删除流程.")
private Message process_delete;
@FieldDescribe("有新的工作通过消息节点.")
private Message activity_message;
@FieldDescribe("工作完成转已完成工作.")
private Message work_to_workCompleted;
@FieldDescribe("创建工作.")
private Message work_create;
@FieldDescribe("删除工作.")
private Message work_delete;
@FieldDescribe("创建已完成工作.")
private Message workCompleted_create;
@FieldDescribe("删除已完成工作.")
private Message workCompleted_delete;
@FieldDescribe("待办完成转已办.")
private Message task_to_taskCompleted;
@FieldDescribe("创建待办.")
private Message task_create;
@FieldDescribe("删除待办.")
private Message task_delete;
@FieldDescribe("待办即将过期催办.")
private Message task_urge;
@FieldDescribe("待办过期.")
private Message task_expire;
@FieldDescribe("待办提醒.")
private Message task_press;
@FieldDescribe("创建已办.")
private Message taskCompleted_create;
@FieldDescribe("删除已办.")
private Message taskCompleted_delete;
@FieldDescribe("待阅转已阅.")
private Message read_to_readCompleted;
@FieldDescribe("创建待阅.")
private Message read_create;
@FieldDescribe("删除待阅.")
private Message read_delete;
@FieldDescribe("创建已阅.")
private Message readCompleted_create;
@FieldDescribe("删除已阅.")
private Message readCompleted_delete;
@FieldDescribe("创建参阅.")
private Message review_create;
@FieldDescribe("删除参阅.")
private Message review_delete;
@FieldDescribe("会议邀请.")
private Message meeting_invite;
@FieldDescribe("删除会议.")
private Message meeting_delete;
@FieldDescribe("会议邀请接受.")
private Message meeting_accept;
@FieldDescribe("会议邀请拒绝.")
private Message meeting_reject;
@FieldDescribe("创建附件.")
private Message attachment_create;
@FieldDescribe("删除附件.")
private Message attachment_delete;
@FieldDescribe("附件分享.")
private Message attachment_share;
@FieldDescribe("附件取消分享.")
private Message attachment_shareCancel;
@FieldDescribe("附件可编辑设置.")
private Message attachment_editor;
@FieldDescribe("附件可编辑取消.")
private Message attachment_editorCancel;
@FieldDescribe("附件可编辑修改.")
private Message attachment_editorModify;
@FieldDescribe("日历通知.")
private Message calendar_alarm;
@FieldDescribe("自定义消息创建.")
private Message custom_create;
@FieldDescribe("工作管理任务创建.")
private Message teamwork_taskCreate;
@FieldDescribe("工作管理任务更新.")
private Message teamwork_taskUpdate;
@FieldDescribe("工作管理任务删除.")
private Message teamwork_taskDelete;
@FieldDescribe("工作管理任务超时.")
private Message teamwork_taskOvertime;
@FieldDescribe("工作管理聊天.")
private Message teamwork_chat;
@FieldDescribe("内容管理发布.")
private Message cms_publish;
@FieldDescribe("内容管理发布创建者通知.")
private Message cms_publish_to_creator;
@FieldDescribe("论坛创建贴子.")
private Message bbs_subjectCreate;
@FieldDescribe("论坛创建回复.")
private Message bbs_replyCreate;
@FieldDescribe("脑图发送.")
private Message mind_fileSend;
@FieldDescribe("脑图分享.")
private Message mind_fileShare;
@FieldDescribe("聊聊消息.")
private Message im_create;
public static Messages defaultInstance() {
Messages o = new Messages();
o.put(MessageConnector.TYPE_APPLICATION_CREATE, MESSAGE_OUTER.cloneThenSetDescription("创建应用"));
o.put(MessageConnector.TYPE_APPLICATION_UPDATE, MESSAGE_OUTER.cloneThenSetDescription("更新应用"));
o.put(MessageConnector.TYPE_APPLICATION_DELETE, MESSAGE_OUTER.cloneThenSetDescription("删除应用"));
o.put(MessageConnector.TYPE_PROCESS_CREATE, MESSAGE_OUTER.cloneThenSetDescription("创建流程"));
o.put(MessageConnector.TYPE_PROCESS_UPDATE, MESSAGE_OUTER.cloneThenSetDescription("创建流程"));
o.put(MessageConnector.TYPE_PROCESS_DELETE, MESSAGE_OUTER.cloneThenSetDescription("删除流程"));
o.put(MessageConnector.TYPE_ACTIVITY_MESSAGE, MESSAGE_OUTER.cloneThenSetDescription("有新的工作通过消息节点"));
o.put(MessageConnector.TYPE_WORK_TO_WORKCOMPLETED, MESSAGE_OUTER.cloneThenSetDescription("工作完成转已完成工作"));
o.put(MessageConnector.TYPE_WORK_CREATE, MESSAGE_OUTER.cloneThenSetDescription("创建工作"));
o.put(MessageConnector.TYPE_WORK_DELETE, MESSAGE_OUTER.cloneThenSetDescription("删除工作"));
o.put(MessageConnector.TYPE_WORKCOMPLETED_CREATE, MESSAGE_OUTER.cloneThenSetDescription("创建已完成工作"));
o.put(MessageConnector.TYPE_WORKCOMPLETED_DELETE, MESSAGE_OUTER.cloneThenSetDescription("删除已完成工作"));
o.put(MessageConnector.TYPE_TASK_TO_TASKCOMPLETED, MESSAGE_OUTER.cloneThenSetDescription("待办完成转已办"));
o.put(MessageConnector.TYPE_TASK_CREATE, MESSAGE_ALL.cloneThenSetDescription("创建待办"));
o.put(MessageConnector.TYPE_TASK_DELETE, MESSAGE_OUTER.cloneThenSetDescription("删除待办"));
o.put(MessageConnector.TYPE_TASK_URGE, MESSAGE_ALL.cloneThenSetDescription("待办即将过期催办"));
o.put(MessageConnector.TYPE_TASK_EXPIRE, MESSAGE_ALL.cloneThenSetDescription("待办过期"));
o.put(MessageConnector.TYPE_TASK_PRESS, MESSAGE_ALL.cloneThenSetDescription("待办提醒"));
o.put(MessageConnector.TYPE_TASKCOMPLETED_CREATE, MESSAGE_OUTER.cloneThenSetDescription("已办创建"));
o.put(MessageConnector.TYPE_TASKCOMPLETED_DELETE, MESSAGE_OUTER.cloneThenSetDescription("删除已办"));
o.put(MessageConnector.TYPE_READ_TO_READCOMPLETED, MESSAGE_OUTER.cloneThenSetDescription("待阅转已阅"));
o.put(MessageConnector.TYPE_READ_CREATE, MESSAGE_ALL.cloneThenSetDescription("待阅创建"));
o.put(MessageConnector.TYPE_READ_DELETE, MESSAGE_OUTER.cloneThenSetDescription("待阅删除"));
o.put(MessageConnector.TYPE_READCOMPLETED_CREATE, MESSAGE_OUTER.cloneThenSetDescription("已阅创建"));
o.put(MessageConnector.TYPE_READCOMPLETED_DELETE, MESSAGE_OUTER.cloneThenSetDescription("已阅删除"));
o.put(MessageConnector.TYPE_REVIEW_CREATE, MESSAGE_OUTER.cloneThenSetDescription("创建参阅"));
o.put(MessageConnector.TYPE_REVIEW_DELETE, MESSAGE_OUTER.cloneThenSetDescription("删除参阅"));
o.put(MessageConnector.TYPE_MEETING_INVITE, MESSAGE_ALL.cloneThenSetDescription("会议邀请"));
o.put(MessageConnector.TYPE_MEETING_DELETE, MESSAGE_OUTER.cloneThenSetDescription("会议删除"));
o.put(MessageConnector.TYPE_MEETING_ACCEPT, MESSAGE_ALL.cloneThenSetDescription("会议邀请接受"));
o.put(MessageConnector.TYPE_MEETING_REJECT, MESSAGE_ALL.cloneThenSetDescription("会议邀请拒绝"));
o.put(MessageConnector.TYPE_ATTACHMENT_CREATE, MESSAGE_OUTER.cloneThenSetDescription("创建附件"));
o.put(MessageConnector.TYPE_ATTACHMENT_DELETE, MESSAGE_OUTER.cloneThenSetDescription("删除附件"));
o.put(MessageConnector.TYPE_ATTACHMENT_SHARE, MESSAGE_ALL.cloneThenSetDescription("附件分享"));
o.put(MessageConnector.TYPE_ATTACHMENT_SHARECANCEL, MESSAGE_ALL.cloneThenSetDescription("附件取消分享"));
o.put(MessageConnector.TYPE_ATTACHMENT_EDITOR, MESSAGE_OUTER.cloneThenSetDescription("附件可编辑设置"));
o.put(MessageConnector.TYPE_ATTACHMENT_EDITORCANCEL, MESSAGE_OUTER.cloneThenSetDescription("附件可编辑取消"));
o.put(MessageConnector.TYPE_ATTACHMENT_EDITORMODIFY, MESSAGE_OUTER.cloneThenSetDescription("附件可编辑修改"));
o.put(MessageConnector.TYPE_CALENDAR_ALARM, MESSAGE_ALL.cloneThenSetDescription("日历通知"));
o.put(MessageConnector.TYPE_CUSTOM_CREATE, MESSAGE_ALL.cloneThenSetDescription("自定义消息创建"));
o.put(MessageConnector.TYPE_TEAMWORK_TASKCREATE, MESSAGE_ALL.cloneThenSetDescription("工作管理任务创建"));
o.put(MessageConnector.TYPE_TEAMWORK_TASKUPDATE, MESSAGE_ALL.cloneThenSetDescription("工作管理任务更新"));
o.put(MessageConnector.TYPE_TEAMWORK_TASKDELETE, MESSAGE_ALL.cloneThenSetDescription("工作管理任务删除"));
o.put(MessageConnector.TYPE_TEAMWORK_TASKOVERTIME, MESSAGE_ALL.cloneThenSetDescription("工作管理任务超时"));
o.put(MessageConnector.TYPE_TEAMWORK_CHAT, MESSAGE_NOTICE.cloneThenSetDescription("工作管理聊天"));
o.put(MessageConnector.TYPE_CMS_PUBLISH, MESSAGE_OUTER.cloneThenSetDescription("内容管理发布"));
o.put(MessageConnector.TYPE_CMS_PUBLISH_TO_CREATOR, MESSAGE_NOTICE.cloneThenSetDescription("内容管理发布创建者通知"));
o.put(MessageConnector.TYPE_BBS_SUBJECTCREATE, MESSAGE_ALL.cloneThenSetDescription("论坛创建贴子"));
o.put(MessageConnector.TYPE_BBS_REPLYCREATE, MESSAGE_ALL.cloneThenSetDescription("论坛创建回复"));
o.put(MessageConnector.TYPE_MIND_FILESEND, MESSAGE_ALL.cloneThenSetDescription("脑图发送"));
o.put(MessageConnector.TYPE_MIND_FILESHARE, MESSAGE_ALL.cloneThenSetDescription("脑图分享"));
o.put(MessageConnector.TYPE_IM_CREATE,
new Message(MessageConnector.CONSUME_WS, MessageConnector.CONSUME_PMS_INNER)
.cloneThenSetDescription("聊聊消息"));
o.application_create = MESSAGE_OUTER.cloneThenSetDescription("创建应用.");
o.application_update = MESSAGE_OUTER.cloneThenSetDescription("更新应用.");
o.application_delete = MESSAGE_OUTER.cloneThenSetDescription("删除应用.");
o.process_create = MESSAGE_OUTER.cloneThenSetDescription("创建流程.");
o.process_update = MESSAGE_OUTER.cloneThenSetDescription("更新流程.");
o.process_delete = MESSAGE_OUTER.cloneThenSetDescription("删除流程.");
o.activity_message = MESSAGE_OUTER.cloneThenSetDescription("有新的工作通过消息节点.");
o.work_to_workCompleted = MESSAGE_OUTER.cloneThenSetDescription("工作完成转已完成工作.");
o.work_create = MESSAGE_OUTER.cloneThenSetDescription("创建工作.");
o.work_delete = MESSAGE_OUTER.cloneThenSetDescription("删除工作.");
o.workCompleted_create = MESSAGE_OUTER.cloneThenSetDescription("创建已完成工作.");
o.workCompleted_delete = MESSAGE_OUTER.cloneThenSetDescription("删除已完成工作.");
o.task_to_taskCompleted = MESSAGE_OUTER.cloneThenSetDescription("待办完成转已办.");
o.task_create = MESSAGE_ALL.cloneThenSetDescription("创建待办.");
o.task_delete = MESSAGE_OUTER.cloneThenSetDescription("删除待办.");
o.task_urge = MESSAGE_ALL.cloneThenSetDescription("待办即将过期催办.");
o.task_expire = MESSAGE_ALL.cloneThenSetDescription("待办过期.");
o.task_press = MESSAGE_ALL.cloneThenSetDescription("待办提醒.");
o.taskCompleted_create = MESSAGE_OUTER.cloneThenSetDescription("创建已办.");
o.taskCompleted_delete = MESSAGE_OUTER.cloneThenSetDescription("删除已办.");
o.read_to_readCompleted = MESSAGE_OUTER.cloneThenSetDescription("待阅转已阅.");
o.read_create = MESSAGE_ALL.cloneThenSetDescription("创建待阅.");
o.read_delete = MESSAGE_OUTER.cloneThenSetDescription("删除待阅.");
o.readCompleted_create = MESSAGE_OUTER.cloneThenSetDescription("创建已阅.");
o.readCompleted_delete = MESSAGE_OUTER.cloneThenSetDescription("删除已阅.");
o.review_create = MESSAGE_OUTER.cloneThenSetDescription("创建参阅.");
o.review_delete = MESSAGE_OUTER.cloneThenSetDescription("删除参阅.");
o.meeting_invite = MESSAGE_ALL.cloneThenSetDescription("会议邀请.");
o.meeting_delete = MESSAGE_OUTER.cloneThenSetDescription("删除会议.");
o.meeting_accept = MESSAGE_ALL.cloneThenSetDescription("会议邀请接受.");
o.meeting_reject = MESSAGE_ALL.cloneThenSetDescription("会议邀请拒绝.");
o.attachment_create = MESSAGE_OUTER.cloneThenSetDescription("创建附件.");
o.attachment_delete = MESSAGE_OUTER.cloneThenSetDescription("删除附件.");
o.attachment_share = MESSAGE_ALL.cloneThenSetDescription("附件分享.");
o.attachment_shareCancel = MESSAGE_ALL.cloneThenSetDescription("附件取消分享.");
o.attachment_editor = MESSAGE_OUTER.cloneThenSetDescription("附件可编辑设置.");
o.attachment_editorCancel = MESSAGE_OUTER.cloneThenSetDescription("附件可编辑取消.");
o.attachment_editorModify = MESSAGE_OUTER.cloneThenSetDescription("附件可编辑修改.");
o.calendar_alarm = MESSAGE_ALL.cloneThenSetDescription("日历通知.");
o.custom_create = MESSAGE_ALL.cloneThenSetDescription("自定义消息创建.");
o.teamwork_taskCreate = MESSAGE_ALL.cloneThenSetDescription("工作管理任务创建.");
o.teamwork_taskUpdate = MESSAGE_ALL.cloneThenSetDescription("工作管理任务更新.");
o.teamwork_taskDelete = MESSAGE_ALL.cloneThenSetDescription("工作管理任务删除.");
o.teamwork_taskOvertime = MESSAGE_ALL.cloneThenSetDescription("工作管理任务超时.");
o.teamwork_chat = MESSAGE_NOTICE.cloneThenSetDescription("工作管理聊天.");
o.cms_publish = MESSAGE_OUTER.cloneThenSetDescription("内容管理发布.");
o.cms_publish_to_creator = MESSAGE_NOTICE.cloneThenSetDescription("内容管理发布创建者通知.");
o.bbs_subjectCreate = MESSAGE_ALL.cloneThenSetDescription("论坛创建贴子.");
o.bbs_replyCreate = MESSAGE_ALL.cloneThenSetDescription("论坛创建回复.");
o.mind_fileSend = MESSAGE_ALL.cloneThenSetDescription("脑图发送.");
o.mind_fileShare = MESSAGE_ALL.cloneThenSetDescription("脑图分享.");
o.im_create = new Message(MessageConnector.CONSUME_WS, MessageConnector.CONSUME_PMS_INNER)
.cloneThenSetDescription("聊聊消息.");
o.consumers = new LinkedHashMap<>();
o.loaders = new LinkedHashMap<>();
o.filters = new LinkedHashMap<>();
return o;
}
public String getLoader(String name) {
String text = "";
if ((null != this.loaders) && StringUtils.isNotEmpty(name)) {
text = this.loaders.get(name);
}
return text;
}
public String getFilter(String name) {
String text = "";
if ((null != this.filters) && StringUtils.isNotEmpty(name)) {
text = this.filters.get(name);
}
return text;
}
public List<Consumer> getConsumers(String type) {
Message o = this.get(type);
Gson gson = XGsonBuilder.instance();
Optional<Message> o = this.getMessage(type);
List<Consumer> list = new ArrayList<>();
if ((null != o) && (null != o.getConsumers())) {
for (JsonElement jsonElement : o.getConsumers()) {
jsonToConsumer(gson, jsonElement, list);
Gson gson = XGsonBuilder.instance();
if (o.isPresent() && (null != o.get().getConsumers())) {
for (JsonElement jsonElement : o.get().getConsumers()) {
String key = XGsonBuilder.extractString(jsonElement, "consumer");
if (StringUtils.isNotBlank(key)) {
JsonElement element = this.consumers.get(key);
if (null != element) {
jsonToConsumer(gson, element, list);
} else {
jsonToConsumer(gson, jsonElement, list);
}
} else {
jsonToConsumer(gson, jsonElement, list);
}
}
}
return list;
}
private Message getApplicationCreate() {
if (null == this.application_create) {
this.application_create = MESSAGE_OUTER.cloneThenSetDescription("创建应用.");
}
return this.application_create;
}
private Message getApplicationUpdate() {
if (null == this.application_update) {
this.application_update = MESSAGE_OUTER.cloneThenSetDescription("更新应用.");
}
return this.application_update;
}
private Message getApplicationDelete() {
if (null == this.application_delete) {
this.application_delete = MESSAGE_OUTER.cloneThenSetDescription("删除应用.");
}
return this.application_delete;
}
private Message getProcessCreate() {
if (null == this.process_create) {
this.process_create = MESSAGE_OUTER.cloneThenSetDescription("创建流程.");
}
return this.process_create;
}
private Message getProcessUpdate() {
if (null == this.process_update) {
this.process_update = MESSAGE_OUTER.cloneThenSetDescription("更新流程.");
}
return this.process_update;
}
private Message getProcessDelete() {
if (null == this.process_delete) {
this.process_delete = MESSAGE_OUTER.cloneThenSetDescription("删除流程.");
}
return this.process_delete;
}
private Message getActivityMessage() {
if (null == this.activity_message) {
this.activity_message = MESSAGE_OUTER.cloneThenSetDescription("有新的工作通过消息节点.");
}
return this.activity_message;
}
private Message getWorkToWorkCompleted() {
if (null == this.work_to_workCompleted) {
this.work_to_workCompleted = MESSAGE_OUTER.cloneThenSetDescription("工作完成转已完成工作.");
}
return this.work_to_workCompleted;
}
private Message getWorkCreate() {
if (null == this.work_create) {
this.work_create = MESSAGE_OUTER.cloneThenSetDescription("创建工作.");
}
return this.work_create;
}
private Message getWorkDelete() {
if (null == this.work_delete) {
this.work_delete = MESSAGE_OUTER.cloneThenSetDescription("删除工作.");
}
return this.work_delete;
}
private Message getWorkCompletedCreate() {
if (null == this.workCompleted_create) {
this.workCompleted_create = MESSAGE_OUTER.cloneThenSetDescription("创建已完成工作.");
}
return this.workCompleted_create;
}
private Message getWorkCompletedDelete() {
if (null == this.workCompleted_delete) {
this.workCompleted_delete = MESSAGE_OUTER.cloneThenSetDescription("删除已完成工作.");
}
return this.workCompleted_delete;
}
private Message getTaskToTaskCompleted() {
if (null == this.task_to_taskCompleted) {
this.task_to_taskCompleted = MESSAGE_OUTER.cloneThenSetDescription("待办完成转已办.");
}
return this.task_to_taskCompleted;
}
private Message getTaskCreate() {
if (null == this.task_create) {
this.task_create = MESSAGE_ALL.cloneThenSetDescription("创建待办.");
}
return this.task_create;
}
private Message getTaskDelete() {
if (null == this.task_delete) {
this.task_delete = MESSAGE_OUTER.cloneThenSetDescription("删除待办.");
}
return this.task_delete;
}
private Message getTaskUrge() {
if (null == this.task_urge) {
this.task_urge = MESSAGE_ALL.cloneThenSetDescription("待办即将过期催办.");
}
return this.task_urge;
}
private Message getTaskExpire() {
if (null == this.task_expire) {
this.task_expire = MESSAGE_ALL.cloneThenSetDescription("待办过期.");
}
return this.task_expire;
}
private Message getTaskPress() {
if (null == this.task_press) {
this.task_press = MESSAGE_ALL.cloneThenSetDescription("待办提醒.");
}
return this.task_press;
}
private Message getTaskCompletedCreate() {
if (null == this.taskCompleted_create) {
this.taskCompleted_create = MESSAGE_OUTER.cloneThenSetDescription("创建已办.");
}
return this.taskCompleted_create;
}
private Message getTaskCompletedDelete() {
if (null == this.taskCompleted_delete) {
this.taskCompleted_delete = MESSAGE_OUTER.cloneThenSetDescription("删除已办.");
}
return this.taskCompleted_delete;
}
private Message getReadToReadCompleted() {
if (null == this.read_to_readCompleted) {
this.read_to_readCompleted = MESSAGE_OUTER.cloneThenSetDescription("待阅转已阅.");
}
return this.read_to_readCompleted;
}
private Message getReadCreate() {
if (null == this.read_create) {
this.read_create = MESSAGE_ALL.cloneThenSetDescription("创建待阅.");
}
return this.read_create;
}
private Message getReadDelete() {
if (null == this.read_delete) {
this.read_delete = MESSAGE_OUTER.cloneThenSetDescription("待阅删除.");
}
return this.read_delete;
}
private Message getReadCompletedCreate() {
if (null == this.readCompleted_create) {
this.readCompleted_create = MESSAGE_OUTER.cloneThenSetDescription("创建已阅.");
}
return this.readCompleted_create;
}
private Message getReadCompletedDelete() {
if (null == this.readCompleted_delete) {
this.readCompleted_delete = MESSAGE_OUTER.cloneThenSetDescription("已阅删除.");
}
return this.readCompleted_delete;
}
private Message getReviewCreate() {
if (null == this.review_create) {
this.review_create = MESSAGE_OUTER.cloneThenSetDescription("创建参阅.");
}
return this.review_create;
}
private Message getReviewDelete() {
if (null == this.review_delete) {
this.review_delete = MESSAGE_OUTER.cloneThenSetDescription("删除参阅.");
}
return this.review_delete;
}
private Message getMeetingInvite() {
if (null == this.meeting_invite) {
this.meeting_invite = MESSAGE_ALL.cloneThenSetDescription("会议邀请.");
}
return this.meeting_invite;
}
private Message getMeetingDelete() {
if (null == this.meeting_delete) {
this.meeting_delete = MESSAGE_OUTER.cloneThenSetDescription("删除会议.");
}
return this.meeting_delete;
}
private Message getMeetingAccept() {
if (null == this.meeting_accept) {
this.meeting_accept = MESSAGE_ALL.cloneThenSetDescription("会议邀请接受.");
}
return this.meeting_accept;
}
private Message getMeetingReject() {
if (null == this.meeting_reject) {
this.meeting_reject = MESSAGE_ALL.cloneThenSetDescription("会议邀请拒绝.");
}
return this.meeting_reject;
}
private Message getAttachmentCreate() {
if (null == this.attachment_create) {
this.attachment_create = MESSAGE_OUTER.cloneThenSetDescription("创建附件.");
}
return this.attachment_create;
}
private Message getAttachmentDelete() {
if (null == this.attachment_delete) {
this.attachment_delete = MESSAGE_OUTER.cloneThenSetDescription("删除附件.");
}
return this.attachment_delete;
}
private Message getAttachmentShare() {
if (null == this.attachment_share) {
this.attachment_share = MESSAGE_ALL.cloneThenSetDescription("附件分享.");
}
return this.attachment_share;
}
private Message getAttachmentShareCancel() {
if (null == this.attachment_shareCancel) {
this.attachment_shareCancel = MESSAGE_ALL.cloneThenSetDescription("附件取消分享.");
}
return this.attachment_shareCancel;
}
private Message getAttachmentEditor() {
if (null == this.attachment_editor) {
this.attachment_editor = MESSAGE_OUTER.cloneThenSetDescription("附件可编辑设置.");
}
return this.attachment_editor;
}
private Message getAttachmentEditorCancel() {
if (null == this.attachment_editorCancel) {
this.attachment_editorCancel = MESSAGE_OUTER.cloneThenSetDescription("附件可编辑取消.");
}
return this.attachment_editorCancel;
}
private Message getAttachmentEditorModify() {
if (null == this.attachment_editorModify) {
this.attachment_editorModify = MESSAGE_OUTER.cloneThenSetDescription("附件可编辑修改.");
}
return this.attachment_editorModify;
}
private Message getCalendarAlarm() {
if (null == this.calendar_alarm) {
this.calendar_alarm = MESSAGE_ALL.cloneThenSetDescription("日历通知.");
}
return this.calendar_alarm;
}
private Message getCustomCreate() {
if (null == this.custom_create) {
this.custom_create = MESSAGE_ALL.cloneThenSetDescription("自定义消息创建.");
}
return this.custom_create;
}
private Message getTeamworkTaskCreate() {
if (null == this.teamwork_taskCreate) {
this.teamwork_taskCreate = MESSAGE_ALL.cloneThenSetDescription("工作管理任务创建.");
}
return this.teamwork_taskCreate;
}
private Message getTeamworkTaskUpdate() {
if (null == this.teamwork_taskUpdate) {
this.teamwork_taskUpdate = MESSAGE_ALL.cloneThenSetDescription("工作管理任务更新.");
}
return this.teamwork_taskUpdate;
}
private Message getTeamworkTaskDelete() {
if (null == this.teamwork_taskDelete) {
this.teamwork_taskDelete = MESSAGE_ALL.cloneThenSetDescription("工作管理任务删除.");
}
return this.teamwork_taskDelete;
}
private Message getTeamworkTaskOvertime() {
if (null == this.teamwork_taskOvertime) {
this.teamwork_taskOvertime = MESSAGE_ALL.cloneThenSetDescription("工作管理任务超时.");
}
return this.teamwork_taskOvertime;
}
private Message getTeamworkChat() {
if (null == this.teamwork_chat) {
this.teamwork_chat = MESSAGE_NOTICE.cloneThenSetDescription("工作管理聊天.");
}
return this.teamwork_chat;
}
private Message getCmsPublish() {
if (null == this.cms_publish) {
this.cms_publish = MESSAGE_OUTER.cloneThenSetDescription("内容管理发布.");
}
return this.cms_publish;
}
private Message getCmsPublishToCreator() {
if (null == this.cms_publish_to_creator) {
this.cms_publish_to_creator = MESSAGE_NOTICE.cloneThenSetDescription("内容管理发布创建者通知.");
}
return this.cms_publish_to_creator;
}
private Message getBbsSubjectCreate() {
if (null == this.bbs_subjectCreate) {
this.bbs_subjectCreate = MESSAGE_ALL.cloneThenSetDescription("论坛创建贴子.");
}
return this.bbs_subjectCreate;
}
private Message getBbsReplyCreate() {
if (null == this.bbs_replyCreate) {
this.bbs_replyCreate = MESSAGE_ALL.cloneThenSetDescription("论坛创建回复.");
}
return this.bbs_replyCreate;
}
private Message getMindFileSend() {
if (null == this.mind_fileSend) {
this.mind_fileSend = MESSAGE_ALL.cloneThenSetDescription("脑图发送.");
}
return this.mind_fileSend;
}
private Message getMindFileShare() {
if (null == this.mind_fileShare) {
this.mind_fileShare = MESSAGE_ALL.cloneThenSetDescription("脑图分享.");
}
return this.mind_fileShare;
}
private Message getImCreate() {
if (null == this.im_create) {
this.im_create = MESSAGE_ALL.cloneThenSetDescription("聊聊消息.");
}
return this.im_create;
}
private Optional<Message> getMessage(String type) {
switch (Objects.toString(type, "")) {
case MessageConnector.TYPE_APPLICATION_CREATE:
return Optional.of(getApplicationCreate());
case MessageConnector.TYPE_APPLICATION_UPDATE:
return Optional.of(getApplicationUpdate());
case MessageConnector.TYPE_APPLICATION_DELETE:
return Optional.of(getApplicationDelete());
case MessageConnector.TYPE_PROCESS_CREATE:
return Optional.of(getProcessCreate());
case MessageConnector.TYPE_PROCESS_UPDATE:
return Optional.of(getProcessUpdate());
case MessageConnector.TYPE_PROCESS_DELETE:
return Optional.of(getProcessDelete());
case MessageConnector.TYPE_ACTIVITY_MESSAGE:
return Optional.of(getActivityMessage());
case MessageConnector.TYPE_WORK_TO_WORKCOMPLETED:
return Optional.of(getWorkToWorkCompleted());
case MessageConnector.TYPE_WORK_CREATE:
return Optional.of(getWorkCreate());
case MessageConnector.TYPE_WORK_DELETE:
return Optional.of(getWorkDelete());
case MessageConnector.TYPE_WORKCOMPLETED_CREATE:
return Optional.of(getWorkCompletedCreate());
case MessageConnector.TYPE_WORKCOMPLETED_DELETE:
return Optional.of(getWorkCompletedDelete());
case MessageConnector.TYPE_TASK_TO_TASKCOMPLETED:
return Optional.of(getTaskToTaskCompleted());
case MessageConnector.TYPE_TASK_CREATE:
return Optional.of(getTaskCreate());
case MessageConnector.TYPE_TASK_DELETE:
return Optional.of(getTaskDelete());
case MessageConnector.TYPE_TASK_URGE:
return Optional.of(getTaskUrge());
case MessageConnector.TYPE_TASK_EXPIRE:
return Optional.of(getTaskExpire());
case MessageConnector.TYPE_TASK_PRESS:
return Optional.of(getTaskPress());
case MessageConnector.TYPE_TASKCOMPLETED_CREATE:
return Optional.of(getTaskCompletedCreate());
case MessageConnector.TYPE_TASKCOMPLETED_DELETE:
return Optional.of(getTaskCompletedDelete());
case MessageConnector.TYPE_READ_TO_READCOMPLETED:
return Optional.of(getReadToReadCompleted());
case MessageConnector.TYPE_READ_CREATE:
return Optional.of(getReadCreate());
case MessageConnector.TYPE_READ_DELETE:
return Optional.of(getReadDelete());
case MessageConnector.TYPE_READCOMPLETED_CREATE:
return Optional.of(getReadCompletedCreate());
case MessageConnector.TYPE_READCOMPLETED_DELETE:
return Optional.of(getReadCompletedDelete());
case MessageConnector.TYPE_REVIEW_CREATE:
return Optional.of(getReviewCreate());
case MessageConnector.TYPE_REVIEW_DELETE:
return Optional.of(getReviewDelete());
case MessageConnector.TYPE_MEETING_INVITE:
return Optional.of(getMeetingInvite());
case MessageConnector.TYPE_MEETING_DELETE:
return Optional.of(getMeetingDelete());
case MessageConnector.TYPE_MEETING_ACCEPT:
return Optional.of(getMeetingAccept());
case MessageConnector.TYPE_MEETING_REJECT:
return Optional.of(getMeetingReject());
case MessageConnector.TYPE_ATTACHMENT_CREATE:
return Optional.of(getAttachmentCreate());
case MessageConnector.TYPE_ATTACHMENT_DELETE:
return Optional.of(getAttachmentDelete());
case MessageConnector.TYPE_ATTACHMENT_SHARE:
return Optional.of(getAttachmentShare());
case MessageConnector.TYPE_ATTACHMENT_SHARECANCEL:
return Optional.of(getAttachmentShareCancel());
case MessageConnector.TYPE_ATTACHMENT_EDITOR:
return Optional.of(getAttachmentEditor());
case MessageConnector.TYPE_ATTACHMENT_EDITORCANCEL:
return Optional.of(getAttachmentEditorCancel());
case MessageConnector.TYPE_ATTACHMENT_EDITORMODIFY:
return Optional.of(getAttachmentEditorModify());
case MessageConnector.TYPE_CALENDAR_ALARM:
return Optional.of(getCalendarAlarm());
case MessageConnector.TYPE_CUSTOM_CREATE:
return Optional.of(getCustomCreate());
case MessageConnector.TYPE_TEAMWORK_TASKCREATE:
return Optional.of(getTeamworkTaskCreate());
case MessageConnector.TYPE_TEAMWORK_TASKUPDATE:
return Optional.of(getTeamworkTaskUpdate());
case MessageConnector.TYPE_TEAMWORK_TASKDELETE:
return Optional.of(getTeamworkTaskDelete());
case MessageConnector.TYPE_TEAMWORK_TASKOVERTIME:
return Optional.of(getTeamworkTaskOvertime());
case MessageConnector.TYPE_TEAMWORK_CHAT:
return Optional.of(getTeamworkChat());
case MessageConnector.TYPE_CMS_PUBLISH:
return Optional.of(getCmsPublish());
case MessageConnector.TYPE_CMS_PUBLISH_TO_CREATOR:
return Optional.of(getCmsPublishToCreator());
case MessageConnector.TYPE_BBS_SUBJECTCREATE:
return Optional.of(getBbsSubjectCreate());
case MessageConnector.TYPE_BBS_REPLYCREATE:
return Optional.of(getBbsReplyCreate());
case MessageConnector.TYPE_MIND_FILESEND:
return Optional.of(getMindFileSend());
case MessageConnector.TYPE_MIND_FILESHARE:
return Optional.of(getMindFileShare());
case MessageConnector.TYPE_IM_CREATE:
return Optional.of(getImCreate());
default:
return Optional.empty();
}
}
private void jsonToConsumer(Gson gson, JsonElement jsonElement, List<Consumer> list) {
if ((null != jsonElement) && jsonElement.isJsonObject()) {
JsonObject jsonObject = jsonElement.getAsJsonObject();
......@@ -199,7 +819,60 @@ public class Messages extends ConcurrentSkipListMap<String, Message> {
}
public static class Clean extends ConfigObject {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = -8460670679002519408L;
public static Clean defaultInstance() {
return new Clean();
}
public static final Boolean DEFAULT_ENABLE = true;
public static final Integer DEFAULT_KEEP = 7;
public static final String DEFAULT_CRON = "30 30 6 * * ?";
@FieldDescribe("是否启用")
private Boolean enable = DEFAULT_ENABLE;
@FieldDescribe("定时cron表达式")
private String cron = DEFAULT_CRON;
@FieldDescribe("消息保留天数")
private Integer keep = DEFAULT_KEEP;
public Integer getKeep() {
if ((null == this.keep) || (this.keep < 1)) {
return DEFAULT_KEEP;
} else {
return this.keep;
}
}
public String getCron() {
if (StringUtils.isNotEmpty(this.cron) && CronExpression.isValidExpression(this.cron)) {
return this.cron;
} else {
return DEFAULT_CRON;
}
}
public Boolean getEnable() {
return BooleanUtils.isTrue(this.enable);
}
public void setCron(String cron) {
this.cron = cron;
}
public void setEnable(Boolean enable) {
this.enable = enable;
}
}
public static class Store extends ConfigObject {
private static final long serialVersionUID = -476407490360557845L;
public static Clean defaultInstance() {
return new Clean();
......
package com.x.base.core.project.message;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.x.base.core.project.Context;
......@@ -149,13 +152,13 @@ public class MessageConnector {
public static final String TYPE_TEAMWORK_TASKUPDATE = "teamwork_taskUpdate";
// 工作管理任务删除
public static final String TYPE_TEAMWORK_TASKDELETE = "teamwork_taskDelelte";
public static final String TYPE_TEAMWORK_TASKDELETE = "teamwork_taskDelete";
// 工作管理任务超时
public static final String TYPE_TEAMWORK_TASKOVERTIME = "teamwork_taskOvertime";
// 工作管理聊天
public static final String TYPE_TEAMWORK_CHAT = "teamwork_taskChat";
public static final String TYPE_TEAMWORK_CHAT = "teamwork_chat";
// 内容管理发布
public static final String TYPE_CMS_PUBLISH = "cms_publish";
......@@ -175,12 +178,12 @@ public class MessageConnector {
// 脑图文件分享
public static final String TYPE_MIND_FILESHARE = "mind_fileShare";
// 审计日志通知
public static final String TYPE_AUDIT_LOG = "audit_log";
// IM 聊天消息发送
public static final String TYPE_IM_CREATE = "im_create";
// 审计日志通知
// public static final String TYPE_AUDIT_LOG = "audit_log";
public static final String CONSUME_WS = "ws";
public static final String CONSUME_PMS_INNER = "pmsinner";
......@@ -215,6 +218,20 @@ public class MessageConnector {
// 自定消费者类型前缀
public static final String CONSUME_CUSTOM_PREFIX = "custom_";
public static final Set<String> TYPES = Collections.unmodifiableSet(Sets.newHashSet(TYPE_APPLICATION_CREATE,
TYPE_APPLICATION_UPDATE, TYPE_APPLICATION_DELETE, TYPE_PROCESS_CREATE, TYPE_PROCESS_UPDATE,
TYPE_PROCESS_DELETE, TYPE_ACTIVITY_MESSAGE, TYPE_WORK_TO_WORKCOMPLETED, TYPE_WORK_CREATE, TYPE_WORK_DELETE,
TYPE_WORKCOMPLETED_CREATE, TYPE_WORKCOMPLETED_DELETE, TYPE_TASK_TO_TASKCOMPLETED, TYPE_TASK_CREATE,
TYPE_TASK_DELETE, TYPE_TASK_URGE, TYPE_TASK_EXPIRE, TYPE_TASK_PRESS, TYPE_TASKCOMPLETED_CREATE,
TYPE_TASKCOMPLETED_DELETE, TYPE_READ_TO_READCOMPLETED, TYPE_READ_CREATE, TYPE_READ_DELETE,
TYPE_READCOMPLETED_CREATE, TYPE_READCOMPLETED_DELETE, TYPE_REVIEW_CREATE, TYPE_REVIEW_DELETE,
TYPE_MEETING_INVITE, TYPE_MEETING_DELETE, TYPE_MEETING_ACCEPT, TYPE_MEETING_REJECT, TYPE_ATTACHMENT_CREATE,
TYPE_ATTACHMENT_DELETE, TYPE_ATTACHMENT_SHARE, TYPE_ATTACHMENT_SHARECANCEL, TYPE_ATTACHMENT_EDITOR,
TYPE_ATTACHMENT_EDITORCANCEL, TYPE_ATTACHMENT_EDITORMODIFY, TYPE_CALENDAR_ALARM, TYPE_CUSTOM_CREATE,
TYPE_TEAMWORK_TASKCREATE, TYPE_TEAMWORK_TASKUPDATE, TYPE_TEAMWORK_TASKDELETE, TYPE_TEAMWORK_TASKOVERTIME,
TYPE_TEAMWORK_CHAT, TYPE_CMS_PUBLISH, TYPE_CMS_PUBLISH_TO_CREATOR, TYPE_BBS_SUBJECTCREATE,
TYPE_BBS_REPLYCREATE, TYPE_MIND_FILESEND, TYPE_MIND_FILESHARE, TYPE_IM_CREATE));
private static Context context;
private static LinkedBlockingQueue<Wrap> connectQueue = new LinkedBlockingQueue<>(10000);
......@@ -249,7 +266,7 @@ public class MessageConnector {
}
}
public static class ConnectorThread extends Thread {
private static class ConnectorThread extends Thread {
@Override
public void run() {
while (true) {
......@@ -320,7 +337,7 @@ public class MessageConnector {
}
public static class StopSignal extends Wrap {
private static class StopSignal extends Wrap {
private static final long serialVersionUID = -5631247237688117035L;
......
package com.x.message.assemble.communicate.jaxrs.connector;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Collectors;
import javax.script.Bindings;
......@@ -17,6 +12,7 @@ import javax.script.ScriptContext;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
......@@ -46,8 +42,6 @@ class ActionCreate extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionCreate.class);
private static ConcurrentMap<String, CompiledScript> scriptMap = new ConcurrentHashMap<>();
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
LOGGER.debug("execute:{}, jsonElement:{}.", effectivePerson::getDistinguishedName, () -> jsonElement);
......@@ -56,405 +50,25 @@ class ActionCreate extends BaseAction {
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
List<Consumer> consumers = Config.messages().getConsumers(wi.getType());
consumers = consumers.stream().filter(Consumer::getEnable).collect(Collectors.toList());
// if (!ListTools.isEmpty(consumers)) {
Instant instant = v3instant(wi);
List<Message> messages = v3Assemble(wi, instant, consumers);
v3Save(instant, messages);
this.v3SendMessage(messages);
// } else {
// Map<String, String> consumersV2 = Config.messages().getConsumersV2(wi.getType());
// Instant instant = this.instant(wi, new ArrayList<>(consumersV2.keySet()));
// List<Message> messages = assemble(wi, consumersV2, instant);
// save(instant, messages);
// this.sendMessage(messages);
// }
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
// @Deprecated
// private void save(Instant instant, List<Message> messages) throws Exception {
// try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
// emc.beginTransaction(Instant.class);
// emc.persist(instant, CheckPersistType.all);
// if (ListTools.isNotEmpty(messages)) {
// emc.beginTransaction(Message.class);
// for (Message message : messages) {
// emc.persist(message, CheckPersistType.all);
// }
// }
// emc.commit();
// }
// }
//
// @Deprecated
// private List<Message> assemble(Wi wi, Map<String, String> consumersV2, Instant instant) throws Exception {
// List<Message> messages = new ArrayList<>();
// if (!consumersV2.isEmpty()) {
// for (Map.Entry<String, String> en : consumersV2.entrySet()) {
// String func = consumersV2.get(en.getKey());
// Wi cpWi = this.executeFun(wi, func, en.getKey());
// if (cpWi != null) {
// Message message = this.assembleMessage(en.getKey(), cpWi, instant);
// if (message != null) {
// messages.add(message);
// }
// }
// }
// }
// return messages;
// }
//
// @Deprecated
// private Wi executeFun(Wi wi, String func, String consumer) {
// Wi cpWi = wi;
// try {
// if (StringUtils.isNoneBlank(func)) {
// cpWi = (Wi) BeanUtils.cloneBean(wi);
// JsonObject body = cpWi.getBody().deepCopy().getAsJsonObject();
// CompiledScript compiledScript = scriptMap.get(func);
// if (compiledScript == null) {
// String eval = Config.messageSendRuleScript();
// if (StringUtils.isNotEmpty(eval)) {
// eval = eval + "\r\n return " + func + "();";
// compiledScript = ScriptingFactory.functionalizationCompile(eval);
// scriptMap.put(func, compiledScript);
// }
// }
// if (compiledScript != null) {
// ScriptContext scriptContext = ScriptingFactory.scriptContextEvalInitialServiceScript();
// Bindings bindings = scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);
// bindings.put(ScriptingFactory.BINDING_NAME_SERVICE_BODY, body);
// bindings.put(ScriptingFactory.BINDING_NAME_SERVICE_MESSAGE, cpWi);
// Boolean ifSend = JsonScriptingExecutor.evalBoolean(compiledScript, scriptContext);
// if (BooleanUtils.isNotTrue(ifSend)) {
// LOGGER.info("消息类型{}.{}的消息[{}]不满足发送条件.", wi.getType(), consumer, wi.getTitle());
// cpWi = null;
// } else {
// cpWi.setBody(body);
// }
// }
// }
// } catch (Exception e) {
// LOGGER.warn("执行消息发送脚本[{}]方法异常:{}", func, e.getMessage());
// }
// return cpWi;
// }
//
// @Deprecated
// private Message assembleMessage(String consumer, Wi cpWi, Instant instant) throws Exception {
// Message message = null;
// String type = StringUtils.lowerCase(Objects.toString(consumer, ""));
// switch (type) {
// case MessageConnector.CONSUME_WS:
// message = this.wsMessage(cpWi, instant);
// break;
// case MessageConnector.CONSUME_PMS_INNER:
// message = this.pmsInnerMessage(cpWi, instant);
// break;
// case MessageConnector.CONSUME_DINGDING:
// message = this.dingdingMessage(cpWi, instant);
// break;
// case MessageConnector.CONSUME_ZHENGWUDINGDING:
// message = this.zhengwudingdingMessage(cpWi, instant);
// break;
// case MessageConnector.CONSUME_QIYEWEIXIN:
// message = this.qiyeweixinMessage(cpWi, instant);
// break;
// case MessageConnector.CONSUME_CALENDAR:
// message = this.calendarMessage(cpWi, instant);
// break;
// case MessageConnector.CONSUME_WELINK:
// message = this.weLinkMessage(cpWi, instant);
// break;
// case MessageConnector.CONSUME_MPWEIXIN:
// message = this.mpweixinMessage(cpWi, instant);
// break;
// default:
// break;
// }
// return message;
//
// }
//
// @Deprecated
// private void sendMessage(List<Message> messages) throws Exception {
// for (Message message : messages) {
// switch (StringUtils.lowerCase(message.getConsumer())) {
// case MessageConnector.CONSUME_WS:
// sendMessageWs(message);
// break;
// case MessageConnector.CONSUME_CALENDAR:
// sendMessageCalendar(message);
// break;
// case MessageConnector.CONSUME_DINGDING:
// sendMessageDingding(message);
// break;
// case MessageConnector.CONSUME_WELINK:
// sendMessageWeLink(message);
// break;
// case MessageConnector.CONSUME_ZHENGWUDINGDING:
// sendMessageZhengwuDingding(message);
// break;
// case MessageConnector.CONSUME_QIYEWEIXIN:
// sendMessageQiyeweixin(message);
// break;
// case MessageConnector.CONSUME_PMS_INNER:
// sendMessagePmsInner(message);
// break;
// case MessageConnector.CONSUME_MPWEIXIN:
// sendMessageMPWeixin(message);
// break;
// default:
// break;
// }
// }
// }
//
// @Deprecated
// private void sendMessageMPWeixin(Message message) throws Exception {
// if (BooleanUtils.isTrue(Config.mPweixin().getEnable())
// && BooleanUtils.isTrue(Config.mPweixin().getMessageEnable())) {
// ThisApplication.mpweixinConsumeQueue.send(message);
// }
// }
//
// @Deprecated
// private void sendMessagePmsInner(Message message) throws Exception {
// if (BooleanUtils.isTrue(Config.pushConfig().getEnable())) {
// ThisApplication.pmsinnerConsumeQueue.send(message);
// }
//
// }
//
// @Deprecated
// private void sendMessageQiyeweixin(Message message) throws Exception {
// if (BooleanUtils.isTrue(Config.qiyeweixin().getEnable())
// && BooleanUtils.isTrue(Config.qiyeweixin().getMessageEnable())) {
// ThisApplication.qiyeweixinConsumeQueue.send(message);
// }
// }
//
// @Deprecated
// private void sendMessageZhengwuDingding(Message message) throws Exception {
// if (BooleanUtils.isTrue(Config.zhengwuDingding().getEnable())
// && BooleanUtils.isTrue(Config.zhengwuDingding().getMessageEnable())) {
// ThisApplication.zhengwudingdingConsumeQueue.send(message);
// }
// }
//
// @Deprecated
// private void sendMessageWeLink(Message message) throws Exception {
// if (BooleanUtils.isTrue(Config.weLink().getEnable())
// && BooleanUtils.isTrue(Config.weLink().getMessageEnable())) {
// ThisApplication.welinkConsumeQueue.send(message);
// }
// }
//
// @Deprecated
// private void sendMessageDingding(Message message) throws Exception {
// if (BooleanUtils.isTrue(Config.dingding().getEnable())
// && BooleanUtils.isTrue(Config.dingding().getMessageEnable())) {
// ThisApplication.dingdingConsumeQueue.send(message);
// }
// }
//
// @Deprecated
// private void sendMessageCalendar(Message message) throws Exception {
// if (BooleanUtils.isTrue(Config.communicate().calendarEnable())) {
// ThisApplication.calendarConsumeQueue.send(message);
// }
// }
//
// @Deprecated
// private void sendMessageWs(Message message) throws Exception {
// if (BooleanUtils.isTrue(Config.communicate().wsEnable())) {
// ThisApplication.wsConsumeQueue.send(message);
// }
// }
//
// @Deprecated
// private Instant instant(Wi wi, List<String> consumers) {
// Instant instant = new Instant();
// instant.setBody(Objects.toString(wi.getBody()));
// instant.setType(wi.getType());
// instant.setPerson(wi.getPerson());
// instant.setTitle(wi.getTitle());
// instant.setConsumerList(consumers);
// instant.setConsumed(false);
// return instant;
// }
//
// @Deprecated
// private Message wsMessage(Wi wi, Instant instant) throws Exception {
// Message message = null;
// if (BooleanUtils.isTrue(Config.communicate().wsEnable())) {
// message = new Message();
// message.setBody(Objects.toString(wi.getBody()));
// message.setType(wi.getType());
// message.setPerson(wi.getPerson());
// message.setTitle(wi.getTitle());
// message.setConsumer(MessageConnector.CONSUME_WS);
// message.setConsumed(false);
// message.setInstant(instant.getId());
// }
// return message;
// }
//
// @Deprecated
// private Message pmsInnerMessage(Wi wi, Instant instant) {
// Message message = null;
// try {
// if (BooleanUtils.isTrue(Config.pushConfig().getEnable())) {
// message = new Message();
// message.setBody(Objects.toString(wi.getBody()));
// message.setType(wi.getType());
// message.setPerson(wi.getPerson());
// message.setTitle(wi.getTitle());
// message.setConsumer(MessageConnector.CONSUME_PMS_INNER);
// message.setConsumed(false);
// message.setInstant(instant.getId());
// }
// } catch (Exception e) {
// LOGGER.error(e);
// }
// return message;
// }
//
// @Deprecated
// private Message dingdingMessage(Wi wi, Instant instant) {
// Message message = null;
// try {
// if (BooleanUtils.isTrue(Config.dingding().getEnable())
// && BooleanUtils.isTrue(Config.dingding().getMessageEnable())) {
// message = new Message();
// message.setBody(Objects.toString(wi.getBody()));
// message.setType(wi.getType());
// message.setPerson(wi.getPerson());
// message.setTitle(wi.getTitle());
// message.setConsumer(MessageConnector.CONSUME_DINGDING);
// message.setConsumed(false);
// message.setInstant(instant.getId());
// }
// } catch (Exception e) {
// LOGGER.error(e);
// }
// return message;
// }
//
// @Deprecated
// private Message weLinkMessage(Wi wi, Instant instant) {
// Message message = null;
// try {
// if (BooleanUtils.isTrue(Config.weLink().getEnable())
// && BooleanUtils.isTrue(Config.weLink().getMessageEnable())) {
// message = new Message();
// message.setBody(Objects.toString(wi.getBody()));
// message.setType(wi.getType());
// message.setPerson(wi.getPerson());
// message.setTitle(wi.getTitle());
// message.setConsumer(MessageConnector.CONSUME_WELINK);
// message.setConsumed(false);
// message.setInstant(instant.getId());
// }
// } catch (Exception e) {
// LOGGER.error(e);
// }
// return message;
// }
//
// @Deprecated
// private Message zhengwudingdingMessage(Wi wi, Instant instant) {
// Message message = null;
// try {
// if (Config.zhengwuDingding().getEnable() && Config.zhengwuDingding().getMessageEnable()) {
// message = new Message();
// message.setBody(Objects.toString(wi.getBody()));
// message.setType(wi.getType());
// message.setPerson(wi.getPerson());
// message.setTitle(wi.getTitle());
// message.setConsumer(MessageConnector.CONSUME_ZHENGWUDINGDING);
// message.setConsumed(false);
// message.setInstant(instant.getId());
// }
// } catch (Exception e) {
// LOGGER.error(e);
// }
// return message;
// }
//
// @Deprecated
// private Message qiyeweixinMessage(Wi wi, Instant instant) {
// Message message = null;
// try {
// if (BooleanUtils.isTrue(Config.qiyeweixin().getEnable())
// && BooleanUtils.isTrue(Config.qiyeweixin().getMessageEnable())) {
// message = new Message();
// message.setBody(Objects.toString(wi.getBody()));
// message.setType(wi.getType());
// message.setPerson(wi.getPerson());
// message.setTitle(wi.getTitle());
// message.setConsumer(MessageConnector.CONSUME_QIYEWEIXIN);
// message.setConsumed(false);
// message.setInstant(instant.getId());
// }
// } catch (Exception e) {
// LOGGER.error(e);
// }
// return message;
// }
//
// @Deprecated
// private Message mpweixinMessage(Wi wi, Instant instant) {
// Message message = null;
// try {
// if (BooleanUtils.isTrue(Config.mPweixin().getEnable())
// && BooleanUtils.isTrue(Config.mPweixin().getMessageEnable())) {
// message = new Message();
// message.setBody(Objects.toString(wi.getBody()));
// message.setType(wi.getType());
// message.setPerson(wi.getPerson());
// message.setTitle(wi.getTitle());
// message.setConsumer(MessageConnector.CONSUME_MPWEIXIN);
// message.setConsumed(false);
// message.setInstant(instant.getId());
// }
// } catch (Exception e) {
// LOGGER.error(e);
// }
// return message;
// }
//
// @Deprecated
// private Message calendarMessage(Wi wi, Instant instant) {
// Message message = null;
// try {
// if (BooleanUtils.isTrue(Config.communicate().calendarEnable())) {
// message = new Message();
// message.setBody(Objects.toString(wi.getBody()));
// message.setType(wi.getType());
// message.setPerson(wi.getPerson());
// message.setTitle(wi.getTitle());
// message.setConsumer(MessageConnector.CONSUME_CALENDAR);
// message.setConsumed(false);
// message.setInstant(instant.getId());
// }
// } catch (Exception e) {
// LOGGER.error(e);
// }
// return message;
// }
public static class Wi extends MessageConnector.Wrap {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 4821344908870350699L;
}
public static class Wo extends WrapBoolean {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 7383440916383187868L;
}
......@@ -663,9 +277,7 @@ class ActionCreate extends BaseAction {
private Message v3CalendarMessage(Wi wi, Consumer consumer) {
Message message = null;
try {
// if (BooleanUtils.isTrue(Config.communicate().calendarEnable())) {
message = this.v3Message(wi, consumer);
// }
} catch (Exception e) {
LOGGER.error(e);
}
......@@ -675,16 +287,18 @@ class ActionCreate extends BaseAction {
private boolean v3Filter(Wi wi, String filter) {
try {
if (StringUtils.isNotBlank(filter)) {
CacheKey cacheKey = new CacheKey(this.getClass(), filter);
CacheKey cacheKey = new CacheKey(this.getClass(), "filter:" + filter);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
CompiledScript compiledScript = null;
if (optional.isPresent()) {
compiledScript = (CompiledScript) optional.get();
} else {
Path path = Config.dir_config().toPath().resolve(filter);
compiledScript = ScriptingFactory
.functionalizationCompile(Files.readString(path, StandardCharsets.UTF_8));
CacheManager.put(cacheCategory, cacheKey, compiledScript);
String text = Config.messages().getFilter(filter);
if (StringUtils.isNotBlank(text)) {
compiledScript = ScriptingFactory
.functionalizationCompile(StringEscapeUtils.unescapeJson(text));
CacheManager.put(cacheCategory, cacheKey, compiledScript);
}
}
if (compiledScript != null) {
ScriptContext scriptContext = ScriptingFactory.scriptContextEvalInitialServiceScript();
......@@ -712,16 +326,18 @@ class ActionCreate extends BaseAction {
private EvalMessage v3Load(Wi wi, String loader) {
try {
if (StringUtils.isNotBlank(loader)) {
CacheKey cacheKey = new CacheKey(this.getClass(), loader);
CacheKey cacheKey = new CacheKey(this.getClass(), "loader:" + loader);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
CompiledScript compiledScript = null;
if (optional.isPresent()) {
compiledScript = (CompiledScript) optional.get();
} else {
Path path = Config.dir_config().toPath().resolve(loader);
compiledScript = ScriptingFactory
.functionalizationCompile(Files.readString(path, StandardCharsets.UTF_8));
CacheManager.put(cacheCategory, cacheKey, compiledScript);
String text = Config.messages().getLoader(loader);
if (StringUtils.isNotBlank(text)) {
compiledScript = ScriptingFactory
.functionalizationCompile(StringEscapeUtils.unescapeJson(text));
CacheManager.put(cacheCategory, cacheKey, compiledScript);
}
}
if (compiledScript != null) {
ScriptContext scriptContext = ScriptingFactory.scriptContextEvalInitialServiceScript();
......
......@@ -10,7 +10,7 @@ import com.x.base.core.project.x_message_assemble_communicate;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.config.Messages;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -27,16 +27,16 @@ class ActionCustomCreate extends BaseAction {
private static final String CUSTOM_PREFIX = "custom_";
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
if (!StringUtils.startsWith(wi.getType(), CUSTOM_PREFIX)) {
throw new ExceptionNotCustomMessage(wi.getType());
}
if (!Config.messages().containsKey(wi.getType())) {
if (!MessageConnector.TYPES.contains(wi.getType())) {
throw new ExceptionUndefinedMessageType(wi.getType());
}
Wo wo = ThisApplication.context().applications()
......@@ -52,7 +52,7 @@ class ActionCustomCreate extends BaseAction {
static WrapCopier<Wi, MessageConnector.Wrap> copier = WrapCopierFactory.wi(Wi.class,
MessageConnector.Wrap.class, null, JpaObject.FieldsUnmodify);
@FieldDescribe("类型")
private String type;
......
package com.x.organization.assemble.authentication.jaxrs.authentication;
import java.io.IOException;
import java.net.URISyntaxException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.organization.core.express.assemble.authentication.jaxrs.authentication.ActionCaptchaLoginRSAPublicKeyWo;
import com.x.organization.core.express.assemble.authentication.jaxrs.authentication.ActionCaptchaRSAPublicKeyWo;
import io.swagger.v3.oas.annotations.media.Schema;
public class ActionCaptchaLoginRSAPublicKey extends BaseAction {
public class ActionCaptchaRSAPublicKey extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionCaptchaLoginRSAPublicKey.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ActionCaptchaRSAPublicKey.class);
ActionResult<Wo> execute(HttpServletRequest request, HttpServletResponse response, EffectivePerson effectivePerson)
throws IOException, URISyntaxException {
ActionResult<Wo> execute(EffectivePerson effectivePerson) throws Exception {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
wo.setPublicKey(Config.publicKey());
wo.setRsaEnable(Config.token().getRsaEnable());
result.setData(wo);
return result;
}
@Schema(name = "com.x.organization.assemble.authentication.jaxrs.authentication.ActionCaptchaLoginRSAPublicKey$Wo")
public static class Wo extends ActionCaptchaLoginRSAPublicKeyWo {
@Schema(name = "com.x.organization.assemble.authentication.jaxrs.authentication.ActionCaptchaRSAPublicKey$Wo")
public static class Wo extends ActionCaptchaRSAPublicKeyWo {
private static final long serialVersionUID = 4078969835023141099L;
......
......@@ -181,17 +181,17 @@ public class AuthenticationAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "获取公钥publicKey", action = ActionCaptchaLoginRSAPublicKey.class)
@JaxrsMethodDescribe(value = "获取公钥publicKey", action = ActionCaptchaRSAPublicKey.class)
@GET
@Path("captchaRSAPublicKey")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void captchaRSAPublicKey(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@Context HttpServletResponse response) {
ActionResult<ActionCaptchaLoginRSAPublicKey.Wo> result = new ActionResult<>();
ActionResult<ActionCaptchaRSAPublicKey.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionCaptchaLoginRSAPublicKey().execute(request, response, effectivePerson);
result = new ActionCaptchaRSAPublicKey().execute(effectivePerson);
} catch (Exception e) {
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
......
......@@ -103,6 +103,7 @@ abstract class BaseAction extends StandardJaxrsAction {
}
public static class WoPersonAbstract extends Person {
private static final long serialVersionUID = -8698017750369215370L;
@FieldDescribe("对个人的操作权限")
......@@ -119,6 +120,8 @@ abstract class BaseAction extends StandardJaxrsAction {
public static class Control extends GsonPropertyObject {
private static final long serialVersionUID = -7663080651519557860L;
private Boolean allowEdit = false;
private Boolean allowDelete = false;
......
......@@ -5,7 +5,7 @@ import com.x.base.core.project.gson.GsonPropertyObject;
import io.swagger.v3.oas.annotations.media.Schema;
public class ActionCaptchaLoginRSAPublicKeyWo extends GsonPropertyObject {
public class ActionCaptchaRSAPublicKeyWo extends GsonPropertyObject {
private static final long serialVersionUID = 8305484005167999793L;
......@@ -13,6 +13,18 @@ public class ActionCaptchaLoginRSAPublicKeyWo extends GsonPropertyObject {
@Schema(description = "RSA公钥.")
private String publicKey;
@FieldDescribe("是否启用rsa加密.")
@Schema(description = "是否启用rsa加密.")
private Boolean rsaEnable;
public Boolean getRsaEnable() {
return rsaEnable;
}
public void setRsaEnable(Boolean rsaEnable) {
this.rsaEnable = rsaEnable;
}
public String getPublicKey() {
return publicKey;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册