提交 7f3906df 编写于 作者: O o2null

Merge branch 'fix/门户分类展现应用图标未获取' into 'develop'

Merge of fix/[门户]门户分类展现应用图标未获取 to develop

See merge request o2oa/o2oa!698
......@@ -66,7 +66,7 @@ class ActionListSummaryWithPortalCategory extends BaseAction {
private static final long serialVersionUID = 4546727999450453639L;
static WrapCopier<Portal, Wo> copier = WrapCopierFactory.wo(Portal.class, Wo.class,
JpaObject.singularAttributeField(Portal.class, true, true), null);
JpaObject.singularAttributeField(Portal.class, true, false), null);
private List<WoPage> pageList = new ArrayList<>();
......
{
"jaxrs": [
{
"name": "CacheAction",
"className": "com.x.base.core.project.jaxrs.cache.CacheAction",
"description": "缓存操作",
"methods": [
{
"name": "configFlush",
"className": "com.x.base.core.project.jaxrs.cache.ActionConfigFlush",
"description": "接收config flush 信号.",
"type": "GET",
"path": "jaxrs/cache/config/flush",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "value",
"type": "Boolean",
"isCollection": false,
"description": "布尔值."
}
]
},
{
"name": "receive",
"className": "com.x.base.core.project.jaxrs.cache.ActionReceive",
"description": "接收Cache刷新信息.",
"type": "PUT",
"path": "jaxrs/cache",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "nodeName",
"type": "String",
"isCollection": false,
"description": "节点名",
"isBaseType": true
},
{
"name": "className",
"type": "String",
"isCollection": false,
"description": "类名",
"isBaseType": true
},
{
"name": "keys",
"type": "List\u003cObject\u003e",
"isCollection": true,
"description": "关键字",
"isBaseType": false
}
],
"outs": [
{
"name": "value",
"type": "String",
"isCollection": false,
"description": "字符串值"
}
]
}
]
},
{
"name": "EchoAction",
"className": "com.x.base.core.project.jaxrs.echo.EchoAction",
"description": "响应",
"methods": [
{
"name": "get",
"className": "com.x.base.core.project.jaxrs.echo.ActionGet",
"description": "获取应答.",
"type": "GET",
"path": "jaxrs/echo",
"contentType": "application/json",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "servletContextName",
"type": "String",
"isCollection": false,
"description": "上下文根"
},
{
"name": "serverTime",
"type": "Date",
"isCollection": false,
"description": "服务器时间"
}
]
}
]
},
{
"name": "FileAction",
"className": "com.x.portal.assemble.designer.jaxrs.file.FileAction",
"description": "文件",
"methods": [
{
"name": "create",
"className": "com.x.portal.assemble.designer.jaxrs.file.ActionCreate",
"description": "创建文件.",
"type": "POST",
"path": "jaxrs/file",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成.",
"isBaseType": true
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "文件名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "文件别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "文件所属门户.",
"isBaseType": true
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "最后的编辑者.",
"isBaseType": true
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "最后的编辑时间.",
"isBaseType": true
},
{
"name": "fileName",
"type": "String",
"isCollection": false,
"description": "文件名称.",
"isBaseType": true
},
{
"name": "length",
"type": "Long",
"isCollection": false,
"description": "文件大小.",
"isBaseType": true
}
],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
},
{
"name": "delete",
"className": "com.x.portal.assemble.designer.jaxrs.file.ActionDelete",
"description": "删除文件.",
"type": "DELETE",
"path": "jaxrs/file/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
},
{
"name": "download",
"className": "com.x.portal.assemble.designer.jaxrs.file.ActionDownload",
"description": "获取文件内容.",
"type": "GET",
"path": "jaxrs/file/{id}/download",
"contentType": "application/json",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "contentDisposition",
"type": "String",
"isCollection": false,
"description": "说明"
},
{
"name": "contentType",
"type": "String",
"isCollection": false,
"description": "类型"
},
{
"name": "bytes",
"type": "byte[]",
"isCollection": false,
"description": "字节内容."
}
]
},
{
"name": "get",
"className": "com.x.portal.assemble.designer.jaxrs.file.ActionGet",
"description": "获取文件内容.",
"type": "GET",
"path": "jaxrs/file/{flag}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "flag",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "文件名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "文件别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "文件所属门户."
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "最后的编辑者."
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "最后的编辑时间."
},
{
"name": "fileName",
"type": "String",
"isCollection": false,
"description": "文件名称."
},
{
"name": "length",
"type": "Long",
"isCollection": false,
"description": "文件大小."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
},
{
"name": "listNext",
"className": "com.x.portal.assemble.designer.jaxrs.file.ActionListNext",
"description": "列示文件对象,下一页.",
"type": "GET",
"path": "jaxrs/file/list/{id}/next/{count}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
},
{
"name": "count",
"type": "Integer",
"description": "数量"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "rank",
"type": "Long",
"isCollection": false,
"description": "排序号"
},
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "文件名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "文件别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "文件所属门户."
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "最后的编辑者."
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "最后的编辑时间."
},
{
"name": "fileName",
"type": "String",
"isCollection": false,
"description": "文件名称."
},
{
"name": "length",
"type": "Long",
"isCollection": false,
"description": "文件大小."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
},
{
"name": "listPrev",
"className": "com.x.portal.assemble.designer.jaxrs.file.ActionListPrev",
"description": "列示文件对象,上一页.",
"type": "GET",
"path": "jaxrs/file/list/{id}/prev/{count}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
},
{
"name": "count",
"type": "Integer",
"description": "数量"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "rank",
"type": "Long",
"isCollection": false,
"description": "排序号"
},
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "文件名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "文件别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "文件所属门户."
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "最后的编辑者."
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "最后的编辑时间."
},
{
"name": "fileName",
"type": "String",
"isCollection": false,
"description": "文件名称."
},
{
"name": "length",
"type": "Long",
"isCollection": false,
"description": "文件大小."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
},
{
"name": "listWithApplication",
"className": "com.x.portal.assemble.designer.jaxrs.file.ActionListWithPortal",
"description": "根据应用列示文件.",
"type": "GET",
"path": "jaxrs/file/list/application/{applicationFlag}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "applicationFlag",
"type": "String",
"description": "应用标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "文件名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "文件别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "文件所属门户."
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "最后的编辑者."
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "最后的编辑时间."
},
{
"name": "fileName",
"type": "String",
"isCollection": false,
"description": "文件名称."
},
{
"name": "length",
"type": "Long",
"isCollection": false,
"description": "文件大小."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
},
{
"name": "update",
"className": "com.x.portal.assemble.designer.jaxrs.file.ActionEdit",
"description": "更新文件.",
"type": "PUT",
"path": "jaxrs/file/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "文件名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "文件别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "文件所属门户.",
"isBaseType": true
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "最后的编辑者.",
"isBaseType": true
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "最后的编辑时间.",
"isBaseType": true
},
{
"name": "data",
"type": "String",
"isCollection": false,
"description": "编码后文本内容.",
"isBaseType": true
},
{
"name": "fileName",
"type": "String",
"isCollection": false,
"description": "文件名称.",
"isBaseType": true
},
{
"name": "length",
"type": "Long",
"isCollection": false,
"description": "文件大小.",
"isBaseType": true
}
],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
},
{
"name": "upload",
"className": "com.x.portal.assemble.designer.jaxrs.file.ActionUpload",
"description": "上传文件内容.",
"type": "POST",
"path": "jaxrs/file/{id}/upload",
"contentType": "multipart/form-data",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": true,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [
{
"name": "file",
"type": "File",
"description": "文件内容"
},
{
"name": "fileName",
"type": "String",
"description": "附件名称"
}
],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "value",
"type": "Boolean",
"isCollection": false,
"description": "布尔值."
}
]
}
]
},
{
"name": "FireScheduleAction",
"className": "com.x.base.core.project.jaxrs.fireschedule.FireScheduleAction",
"description": "触发任务",
"methods": [
{
"name": "execute",
"className": "com.x.base.core.project.jaxrs.fireschedule.ActionExecute",
"description": "接受x_program_center发送过来的运行schedule.",
"type": "GET",
"path": "jaxrs/fireschedule/classname/{className}",
"contentType": "application/json",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "className",
"type": "String",
"description": "运行类"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "value",
"type": "Boolean",
"isCollection": false,
"description": "布尔值."
}
]
}
]
},
{
"name": "IdAction",
"className": "com.x.portal.assemble.designer.jaxrs.id.IdAction",
"description": "标识",
"methods": [
{
"name": "get",
"className": "com.x.portal.assemble.designer.jaxrs.id.ActionGet",
"description": "创建用于ID值的UUID",
"type": "GET",
"path": "jaxrs/id/{count}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "count",
"type": "Integer",
"description": "创建数量"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
}
]
},
{
"name": "InputAction",
"className": "com.x.portal.assemble.designer.jaxrs.input.InputAction",
"description": "导入",
"methods": [
{
"name": "compare",
"className": "com.x.portal.assemble.designer.jaxrs.input.ActionCompare",
"description": "上传对比数据内容.",
"type": "PUT",
"path": "jaxrs/input/compare",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成.",
"isBaseType": true
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "availableIdentityList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的用户.",
"isBaseType": true
},
{
"name": "availableUnitList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的组织.",
"isBaseType": true
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类.",
"isBaseType": true
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本.",
"isBaseType": true
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页.",
"isBaseType": true
},
{
"name": "controllerList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "应用管理者。",
"isBaseType": true
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。",
"isBaseType": true
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。",
"isBaseType": true
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者",
"isBaseType": true
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示.",
"isBaseType": true
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示.",
"isBaseType": true
},
{
"name": "distributeFactor",
"type": "Integer",
"isCollection": false,
"description": "分布式存储标识位.",
"isBaseType": true
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中.",
"isBaseType": true
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中.",
"isBaseType": true
},
{
"name": "sequence",
"type": "String",
"isCollection": false,
"description": "列表序号,由创建时间以及ID组成.在保存时自动生成,索引创建在约束中.",
"isBaseType": true
}
],
"outs": [
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "导入名称"
},
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "导入id"
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "导入别名"
},
{
"name": "exist",
"type": "Boolean",
"isCollection": false,
"description": "是否已经存在"
},
{
"name": "existName",
"type": "String",
"isCollection": false,
"description": "已经存在名称"
},
{
"name": "existId",
"type": "String",
"isCollection": false,
"description": "已经存在id"
},
{
"name": "existAlias",
"type": "String",
"isCollection": false,
"description": "已经存在别名"
}
]
},
{
"name": "cover",
"className": "com.x.portal.assemble.designer.jaxrs.input.ActionCover",
"description": "覆盖应用.",
"type": "PUT",
"path": "jaxrs/input/cover",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成.",
"isBaseType": true
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "availableIdentityList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的用户.",
"isBaseType": true
},
{
"name": "availableUnitList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的组织.",
"isBaseType": true
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类.",
"isBaseType": true
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本.",
"isBaseType": true
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页.",
"isBaseType": true
},
{
"name": "controllerList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "应用管理者。",
"isBaseType": true
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。",
"isBaseType": true
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。",
"isBaseType": true
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者",
"isBaseType": true
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示.",
"isBaseType": true
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示.",
"isBaseType": true
},
{
"name": "distributeFactor",
"type": "Integer",
"isCollection": false,
"description": "分布式存储标识位.",
"isBaseType": true
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中.",
"isBaseType": true
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中.",
"isBaseType": true
},
{
"name": "sequence",
"type": "String",
"isCollection": false,
"description": "列表序号,由创建时间以及ID组成.在保存时自动生成,索引创建在约束中.",
"isBaseType": true
}
],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
},
{
"name": "create",
"className": "com.x.portal.assemble.designer.jaxrs.input.ActionCreate",
"description": "创建应用.",
"type": "PUT",
"path": "jaxrs/input/create",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成.",
"isBaseType": true
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "availableIdentityList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的用户.",
"isBaseType": true
},
{
"name": "availableUnitList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的组织.",
"isBaseType": true
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类.",
"isBaseType": true
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本.",
"isBaseType": true
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页.",
"isBaseType": true
},
{
"name": "controllerList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "应用管理者。",
"isBaseType": true
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。",
"isBaseType": true
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。",
"isBaseType": true
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者",
"isBaseType": true
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示.",
"isBaseType": true
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示.",
"isBaseType": true
},
{
"name": "distributeFactor",
"type": "Integer",
"isCollection": false,
"description": "分布式存储标识位.",
"isBaseType": true
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中.",
"isBaseType": true
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中.",
"isBaseType": true
},
{
"name": "sequence",
"type": "String",
"isCollection": false,
"description": "列表序号,由创建时间以及ID组成.在保存时自动生成,索引创建在约束中.",
"isBaseType": true
}
],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
},
{
"name": "prepareCover",
"className": "com.x.portal.assemble.designer.jaxrs.input.ActionPrepareCover",
"description": "准备覆盖应用.",
"type": "PUT",
"path": "jaxrs/input/prepare/cover",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成.",
"isBaseType": true
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "availableIdentityList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的用户.",
"isBaseType": true
},
{
"name": "availableUnitList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的组织.",
"isBaseType": true
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类.",
"isBaseType": true
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本.",
"isBaseType": true
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页.",
"isBaseType": true
},
{
"name": "controllerList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "应用管理者。",
"isBaseType": true
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。",
"isBaseType": true
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。",
"isBaseType": true
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者",
"isBaseType": true
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示.",
"isBaseType": true
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示.",
"isBaseType": true
},
{
"name": "distributeFactor",
"type": "Integer",
"isCollection": false,
"description": "分布式存储标识位.",
"isBaseType": true
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中.",
"isBaseType": true
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中.",
"isBaseType": true
},
{
"name": "sequence",
"type": "String",
"isCollection": false,
"description": "列表序号,由创建时间以及ID组成.在保存时自动生成,索引创建在约束中.",
"isBaseType": true
}
],
"outs": []
},
{
"name": "prepareCreate",
"className": "com.x.portal.assemble.designer.jaxrs.input.ActionPrepareCreate",
"description": "准备创建应用.",
"type": "PUT",
"path": "jaxrs/input/prepare/create",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成.",
"isBaseType": true
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "availableIdentityList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的用户.",
"isBaseType": true
},
{
"name": "availableUnitList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的组织.",
"isBaseType": true
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类.",
"isBaseType": true
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本.",
"isBaseType": true
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页.",
"isBaseType": true
},
{
"name": "controllerList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "应用管理者。",
"isBaseType": true
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。",
"isBaseType": true
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。",
"isBaseType": true
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者",
"isBaseType": true
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示.",
"isBaseType": true
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示.",
"isBaseType": true
},
{
"name": "distributeFactor",
"type": "Integer",
"isCollection": false,
"description": "分布式存储标识位.",
"isBaseType": true
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中.",
"isBaseType": true
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中.",
"isBaseType": true
},
{
"name": "sequence",
"type": "String",
"isCollection": false,
"description": "列表序号,由创建时间以及ID组成.在保存时自动生成,索引创建在约束中.",
"isBaseType": true
}
],
"outs": []
}
]
},
{
"name": "LoggerAction",
"className": "com.x.base.core.project.jaxrs.logger.LoggerAction",
"description": "日志操作",
"methods": [
{
"name": "debug",
"className": "com.x.base.core.project.jaxrs.logger.ActionDebug",
"description": "设置日志级别为DEBUG.",
"type": "GET",
"path": "jaxrs/logger/debug",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "value",
"type": "Boolean",
"isCollection": false,
"description": "布尔值."
}
]
},
{
"name": "get",
"className": "com.x.base.core.project.jaxrs.logger.ActionGet",
"description": "获取当前日志级别.",
"type": "GET",
"path": "jaxrs/logger",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "value",
"type": "String",
"isCollection": false,
"description": "字符串值"
}
]
},
{
"name": "info",
"className": "com.x.base.core.project.jaxrs.logger.ActionInfo",
"description": "设置日志级别为INFO",
"type": "GET",
"path": "jaxrs/logger/info",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "value",
"type": "Boolean",
"isCollection": false,
"description": "布尔值."
}
]
},
{
"name": "trace",
"className": "com.x.base.core.project.jaxrs.logger.ActionTrace",
"description": "设置日志级别为TRACE.",
"type": "GET",
"path": "jaxrs/logger/trace",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "value",
"type": "Boolean",
"isCollection": false,
"description": "布尔值."
}
]
},
{
"name": "warn",
"className": "com.x.base.core.project.jaxrs.logger.ActionWarn",
"description": "设置日志级别为WARN",
"type": "GET",
"path": "jaxrs/logger/warn",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "value",
"type": "Boolean",
"isCollection": false,
"description": "布尔值."
}
]
}
]
},
{
"name": "OutputAction",
"className": "com.x.portal.assemble.designer.jaxrs.output.OutputAction",
"description": "导出",
"methods": [
{
"name": "list",
"className": "com.x.portal.assemble.designer.jaxrs.output.ActionList",
"description": "查看所有应用.",
"type": "GET",
"path": "jaxrs/output/list",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类."
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页."
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。"
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。"
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者"
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示."
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
},
{
"name": "select",
"className": "com.x.portal.assemble.designer.jaxrs.output.ActionSelect",
"description": "选择门户结构.",
"type": "PUT",
"path": "jaxrs/output/{portalFlag}/select",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "portalFlag",
"type": "String",
"description": "应用标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成.",
"isBaseType": true
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "availableIdentityList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的用户.",
"isBaseType": true
},
{
"name": "availableUnitList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的组织.",
"isBaseType": true
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类.",
"isBaseType": true
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本.",
"isBaseType": true
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页.",
"isBaseType": true
},
{
"name": "controllerList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "应用管理者。",
"isBaseType": true
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。",
"isBaseType": true
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。",
"isBaseType": true
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者",
"isBaseType": true
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示.",
"isBaseType": true
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示.",
"isBaseType": true
},
{
"name": "distributeFactor",
"type": "Integer",
"isCollection": false,
"description": "分布式存储标识位.",
"isBaseType": true
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中.",
"isBaseType": true
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中.",
"isBaseType": true
},
{
"name": "sequence",
"type": "String",
"isCollection": false,
"description": "列表序号,由创建时间以及ID组成.在保存时自动生成,索引创建在约束中.",
"isBaseType": true
}
],
"outs": [
{
"name": "flag",
"type": "String",
"isCollection": false,
"description": "返回标识"
},
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "availableIdentityList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的用户."
},
{
"name": "availableUnitList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的组织."
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类."
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本."
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页."
},
{
"name": "controllerList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "应用管理者。"
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。"
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。"
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者"
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示."
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示."
},
{
"name": "distributeFactor",
"type": "Integer",
"isCollection": false,
"description": "分布式存储标识位."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
},
{
"name": "sequence",
"type": "String",
"isCollection": false,
"description": "列表序号,由创建时间以及ID组成.在保存时自动生成,索引创建在约束中."
}
]
},
{
"name": "selectOutput",
"className": "com.x.portal.assemble.designer.jaxrs.output.ActionSelectFile",
"description": "以文件方式导出应用.",
"type": "GET",
"path": "jaxrs/output/{flag}/select/file",
"contentType": "application/json",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "flag",
"type": "String",
"description": "输出文件标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "contentDisposition",
"type": "String",
"isCollection": false,
"description": "说明"
},
{
"name": "contentType",
"type": "String",
"isCollection": false,
"description": "类型"
},
{
"name": "bytes",
"type": "byte[]",
"isCollection": false,
"description": "字节内容."
}
]
}
]
},
{
"name": "PageAction",
"className": "com.x.portal.assemble.designer.jaxrs.page.PageAction",
"description": "页面",
"methods": [
{
"name": "create",
"className": "com.x.portal.assemble.designer.jaxrs.page.ActionCreate",
"description": "创建新的Page.",
"type": "POST",
"path": "jaxrs/page",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成.",
"isBaseType": true
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "所属的Portal.",
"isBaseType": true
},
{
"name": "data",
"type": "String",
"isCollection": false,
"description": "文本内容.",
"isBaseType": true
},
{
"name": "mobileData",
"type": "String",
"isCollection": false,
"description": "移动端文本内容.",
"isBaseType": true
},
{
"name": "hasMobile",
"type": "Boolean",
"isCollection": false,
"description": "是否有移动端内容.",
"isBaseType": true
}
],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
},
{
"name": "delete",
"className": "com.x.portal.assemble.designer.jaxrs.page.ActionDelete",
"description": "删除指定的Page",
"type": "DELETE",
"path": "jaxrs/page/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "value",
"type": "Boolean",
"isCollection": false,
"description": "布尔值."
}
]
},
{
"name": "edit",
"className": "com.x.portal.assemble.designer.jaxrs.page.ActionEdit",
"description": "更新指定的Page.",
"type": "PUT",
"path": "jaxrs/page/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "所属的Portal.",
"isBaseType": true
},
{
"name": "data",
"type": "String",
"isCollection": false,
"description": "文本内容.",
"isBaseType": true
},
{
"name": "mobileData",
"type": "String",
"isCollection": false,
"description": "移动端文本内容.",
"isBaseType": true
},
{
"name": "hasMobile",
"type": "Boolean",
"isCollection": false,
"description": "是否有移动端内容.",
"isBaseType": true
}
],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
},
{
"name": "get",
"className": "com.x.portal.assemble.designer.jaxrs.page.ActionGet",
"description": "获取Page.",
"type": "GET",
"path": "jaxrs/page/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "所属的Portal."
},
{
"name": "data",
"type": "String",
"isCollection": false,
"description": "文本内容."
},
{
"name": "mobileData",
"type": "String",
"isCollection": false,
"description": "移动端文本内容."
},
{
"name": "hasMobile",
"type": "Boolean",
"isCollection": false,
"description": "是否有移动端内容."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
},
{
"name": "listWithPortal",
"className": "com.x.portal.assemble.designer.jaxrs.page.ActionListWithPortal",
"description": "列示指定Portal下的Page.",
"type": "GET",
"path": "jaxrs/page/list/portal/{portalId}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "portalId",
"type": "String",
"description": "Portal标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "所属的Portal."
},
{
"name": "hasMobile",
"type": "Boolean",
"isCollection": false,
"description": "是否有移动端内容."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
}
]
},
{
"name": "PortalAction",
"className": "com.x.portal.assemble.designer.jaxrs.portal.PortalAction",
"description": "门户操作",
"methods": [
{
"name": "create",
"className": "com.x.portal.assemble.designer.jaxrs.portal.ActionCreate",
"description": "创建新的Portal.需要对Portal模块的管理权限",
"type": "POST",
"path": "jaxrs/portal",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成.",
"isBaseType": true
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "availableIdentityList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的用户.",
"isBaseType": true
},
{
"name": "availableUnitList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的组织.",
"isBaseType": true
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类.",
"isBaseType": true
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本.",
"isBaseType": true
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页.",
"isBaseType": true
},
{
"name": "controllerList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "应用管理者。",
"isBaseType": true
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。",
"isBaseType": true
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。",
"isBaseType": true
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者",
"isBaseType": true
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示.",
"isBaseType": true
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示.",
"isBaseType": true
}
],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
},
{
"name": "delete",
"className": "com.x.portal.assemble.designer.jaxrs.portal.ActionDelete",
"description": "删除指定的Portal,需要指定权限.",
"type": "DELETE",
"path": "jaxrs/portal/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "value",
"type": "Boolean",
"isCollection": false,
"description": "布尔值."
}
]
},
{
"name": "edit",
"className": "com.x.portal.assemble.designer.jaxrs.portal.ActionEdit",
"description": "更新指定的Portal,需要对此portal的管理权限",
"type": "PUT",
"path": "jaxrs/portal/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "availableIdentityList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的用户.",
"isBaseType": true
},
{
"name": "availableUnitList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的组织.",
"isBaseType": true
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类.",
"isBaseType": true
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本.",
"isBaseType": true
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页.",
"isBaseType": true
},
{
"name": "controllerList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "应用管理者。",
"isBaseType": true
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。",
"isBaseType": true
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。",
"isBaseType": true
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者",
"isBaseType": true
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示.",
"isBaseType": true
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示.",
"isBaseType": true
}
],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
},
{
"name": "get",
"className": "com.x.portal.assemble.designer.jaxrs.portal.ActionGet",
"description": "获取单个Portal配置信息,检查是否有editable权限.",
"type": "GET",
"path": "jaxrs/portal/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "availableIdentityList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的用户."
},
{
"name": "availableUnitList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "在指定启动时候,允许新建的组织."
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类."
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本."
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页."
},
{
"name": "controllerList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "应用管理者。"
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。"
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。"
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者"
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示."
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
},
{
"name": "list",
"className": "com.x.portal.assemble.designer.jaxrs.portal.ActionList",
"description": "列示当前用户可以管理的Portal.",
"type": "GET",
"path": "jaxrs/portal/list",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类."
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本."
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页."
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。"
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。"
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者"
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示."
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
},
{
"name": "listSummary",
"className": "com.x.portal.assemble.designer.jaxrs.portal.ActionListSummary",
"description": "列示当前用户可以管理的Portal的简要信息包含page.",
"type": "GET",
"path": "jaxrs/portal/list/summary",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "pageList",
"type": "List\u003cWoPage\u003e",
"isCollection": true,
"description": "页面"
},
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类."
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本."
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页."
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。"
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。"
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者"
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示."
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
},
{
"name": "listSummaryWithPortalCategory",
"className": "com.x.portal.assemble.designer.jaxrs.portal.ActionListSummaryWithPortalCategory",
"description": "列示当前用户在指定分类下可以管理的Portal的简要信息包含page.",
"type": "GET",
"path": "jaxrs/portal/list/summary/portalcategory/{portalCategory}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "portalCategory",
"type": "String",
"description": "门户分类"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类."
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页."
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。"
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。"
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者"
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示."
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
},
{
"name": "listWithPortalCategory",
"className": "com.x.portal.assemble.designer.jaxrs.portal.ActionListWithPortalCategory",
"description": "列示当前用户在指定分类下可以管理的Portal.",
"type": "GET",
"path": "jaxrs/portal/list/portalcategory/{portalCategory}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "portalCategory",
"type": "String",
"description": "门户分类"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "portalCategory",
"type": "String",
"isCollection": false,
"description": "应用分类."
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本."
},
{
"name": "firstPage",
"type": "String",
"isCollection": false,
"description": "默认首页."
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "应用的创建者。"
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "应用的最后修改时间。"
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "应用的最后修改者"
},
{
"name": "pcClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在pc终端显示."
},
{
"name": "mobileClient",
"type": "Boolean",
"isCollection": false,
"description": "是否在移动设备显示."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
},
{
"name": "setIcon",
"className": "com.x.portal.assemble.designer.jaxrs.portal.ActionSetIcon",
"description": "更新Portal图标.",
"type": "PUT",
"path": "jaxrs/portal/{id}/icon",
"contentType": "multipart/form-data",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": true,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [
{
"name": "file",
"type": "File",
"description": "图标文件"
}
],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
}
]
},
{
"name": "PortalCategoryAction",
"className": "com.x.portal.assemble.designer.jaxrs.portalcategory.PortalCategoryAction",
"description": "门户分类",
"methods": [
{
"name": "listWith",
"className": "com.x.portal.assemble.designer.jaxrs.portalcategory.ActionList",
"description": "查看用户可管理的portalcategory.",
"type": "GET",
"path": "jaxrs/portalcategory/list",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "protalCategory",
"type": "String",
"isCollection": false,
"description": "门户分类"
},
{
"name": "count",
"type": "Long",
"isCollection": false,
"description": "数量"
}
]
}
]
},
{
"name": "ScriptAction",
"className": "com.x.portal.assemble.designer.jaxrs.script.ScriptAction",
"description": "脚本操作",
"methods": [
{
"name": "create",
"className": "com.x.portal.assemble.designer.jaxrs.script.ActionCreate",
"description": "创建新的Script.",
"type": "POST",
"path": "jaxrs/script",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成.",
"isBaseType": true
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "validated",
"type": "Boolean",
"isCollection": false,
"description": "代码格式是否正确.",
"isBaseType": true
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "脚本所属应用.",
"isBaseType": true
},
{
"name": "text",
"type": "String",
"isCollection": false,
"description": "脚本内容.",
"isBaseType": true
},
{
"name": "dependScriptList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "依赖的函数列表.",
"isBaseType": true
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "流程创建者.",
"isBaseType": true
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "最后的编辑者.",
"isBaseType": true
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "最后的编辑时间.",
"isBaseType": true
}
],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
},
{
"name": "delete",
"className": "com.x.portal.assemble.designer.jaxrs.script.ActionDelete",
"description": "删除指定的Portal",
"type": "DELETE",
"path": "jaxrs/script/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "value",
"type": "Boolean",
"isCollection": false,
"description": "布尔值."
}
]
},
{
"name": "edit",
"className": "com.x.portal.assemble.designer.jaxrs.script.ActionEdit",
"description": "更新指定的Portal.",
"type": "PUT",
"path": "jaxrs/script/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "validated",
"type": "Boolean",
"isCollection": false,
"description": "代码格式是否正确.",
"isBaseType": true
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "脚本所属应用.",
"isBaseType": true
},
{
"name": "text",
"type": "String",
"isCollection": false,
"description": "脚本内容.",
"isBaseType": true
},
{
"name": "dependScriptList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "依赖的函数列表.",
"isBaseType": true
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "流程创建者.",
"isBaseType": true
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "最后的编辑者.",
"isBaseType": true
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "最后的编辑时间.",
"isBaseType": true
}
],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
},
{
"name": "get",
"className": "com.x.portal.assemble.designer.jaxrs.script.ActionGet",
"description": "获取Script.",
"type": "GET",
"path": "jaxrs/script/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "validated",
"type": "Boolean",
"isCollection": false,
"description": "代码格式是否正确."
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "脚本所属应用."
},
{
"name": "text",
"type": "String",
"isCollection": false,
"description": "脚本内容."
},
{
"name": "dependScriptList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "依赖的函数列表."
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "流程创建者."
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "最后的编辑者."
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "最后的编辑时间."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
},
{
"name": "listWithPortal",
"className": "com.x.portal.assemble.designer.jaxrs.script.ActionListWithPortal",
"description": "列示指定Portal下的Script.",
"type": "GET",
"path": "jaxrs/script/list/portal/{portalId}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "portalId",
"type": "String",
"description": "Portal标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "validated",
"type": "Boolean",
"isCollection": false,
"description": "代码格式是否正确."
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "脚本所属应用."
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "流程创建者."
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "最后的编辑者."
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "最后的编辑时间."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
}
]
},
{
"name": "SysResourceAction",
"className": "com.x.base.core.project.jaxrs.sysresource.SysResourceAction",
"description": "系统资源",
"methods": [
{
"name": "listResource",
"className": "com.x.base.core.project.jaxrs.sysresource.ActionListResource",
"description": "获取静态资源信息.",
"type": "GET",
"path": "jaxrs/sysresource/filePath/{filePath}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "filePath",
"type": "String",
"description": "查找路径(根路径:(0))"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": []
},
{
"name": "uploadResource",
"className": "com.x.base.core.project.jaxrs.sysresource.ActionUploadResource",
"description": "上传静态资源(仅上传到当前服务器)",
"type": "POST",
"path": "jaxrs/sysresource/upload/resource/as/new/{asNew}",
"contentType": "multipart/form-data",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": true,
"pathParameters": [
{
"name": "asNew",
"type": "Boolean",
"description": "覆盖类型:true删除原文件然后上传,false覆盖原文件"
}
],
"formParameters": [
{
"name": "file",
"type": "File",
"description": "上传文件"
},
{
"name": "fileName",
"type": "String",
"description": "附件名称"
},
{
"name": "filePath",
"type": "String",
"description": "附件存放目录(可以为空)"
}
],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "value",
"type": "Boolean",
"isCollection": false,
"description": "布尔值."
}
]
}
]
},
{
"name": "TemplatePageAction",
"className": "com.x.portal.assemble.designer.jaxrs.templatepage.TemplatePageAction",
"description": "页面模版",
"methods": [
{
"name": "create",
"className": "com.x.portal.assemble.designer.jaxrs.templatepage.ActionCreate",
"description": "创建新的模版.",
"type": "POST",
"path": "jaxrs/templatepage",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成.",
"isBaseType": true
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "表单别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "category",
"type": "String",
"isCollection": false,
"description": "模版分类.",
"isBaseType": true
},
{
"name": "availableIdentityList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "允许使用此模版的身份.",
"isBaseType": true
},
{
"name": "availableUnitList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "允许使用此模版的部门.",
"isBaseType": true
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本.",
"isBaseType": true
},
{
"name": "preview",
"type": "String",
"isCollection": false,
"description": "缩略图.",
"isBaseType": true
},
{
"name": "data",
"type": "String",
"isCollection": false,
"description": "文本内容.",
"isBaseType": true
},
{
"name": "mobileData",
"type": "String",
"isCollection": false,
"description": "移动端文本内容.",
"isBaseType": true
},
{
"name": "controllerList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "管理者.",
"isBaseType": true
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "创建者.",
"isBaseType": true
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "最后修改时间.",
"isBaseType": true
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "最后修改者.",
"isBaseType": true
}
],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
},
{
"name": "delete",
"className": "com.x.portal.assemble.designer.jaxrs.templatepage.ActionDelete",
"description": "删除指定的模版.",
"type": "DELETE",
"path": "jaxrs/templatepage/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "value",
"type": "Boolean",
"isCollection": false,
"description": "布尔值."
}
]
},
{
"name": "get",
"className": "com.x.portal.assemble.designer.jaxrs.templatepage.ActionGet",
"description": "获取单个模版.",
"type": "GET",
"path": "jaxrs/templatepage/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "表单别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "category",
"type": "String",
"isCollection": false,
"description": "模版分类."
},
{
"name": "availableIdentityList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "允许使用此模版的身份."
},
{
"name": "availableUnitList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "允许使用此模版的部门."
},
{
"name": "icon",
"type": "String",
"isCollection": false,
"description": "icon Base64编码后的文本."
},
{
"name": "preview",
"type": "String",
"isCollection": false,
"description": "缩略图."
},
{
"name": "data",
"type": "String",
"isCollection": false,
"description": "文本内容."
},
{
"name": "mobileData",
"type": "String",
"isCollection": false,
"description": "移动端文本内容."
},
{
"name": "controllerList",
"type": "List\u003cString\u003e",
"isCollection": true,
"description": "管理者."
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "创建者."
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "最后修改时间."
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "最后修改者."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
},
{
"name": "list",
"className": "com.x.portal.assemble.designer.jaxrs.templatepage.ActionList",
"description": "获取所有可见的模版,按category进行分类",
"type": "GET",
"path": "jaxrs/templatepage/list",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": []
},
{
"name": "listCategory",
"className": "com.x.portal.assemble.designer.jaxrs.templatepage.ActionListCategory",
"description": "统计分类数量.",
"type": "GET",
"path": "jaxrs/templatepage/list/category",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "类别"
},
{
"name": "count",
"type": "Long",
"isCollection": false,
"description": "数量"
}
]
},
{
"name": "listWithCategory",
"className": "com.x.portal.assemble.designer.jaxrs.templatepage.ActionListWithCategory",
"description": "列示指定分类下的模版.",
"type": "PUT",
"path": "jaxrs/templatepage/list/category",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": true,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "表单别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "category",
"type": "String",
"isCollection": false,
"description": "模版分类."
},
{
"name": "creatorPerson",
"type": "String",
"isCollection": false,
"description": "创建者."
},
{
"name": "lastUpdateTime",
"type": "Date",
"isCollection": false,
"description": "最后修改时间."
},
{
"name": "lastUpdatePerson",
"type": "String",
"isCollection": false,
"description": "最后修改者."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
}
]
},
{
"name": "WidgetAction",
"className": "com.x.portal.assemble.designer.jaxrs.widget.WidgetAction",
"description": "部件",
"methods": [
{
"name": "create",
"className": "com.x.portal.assemble.designer.jaxrs.widget.ActionCreate",
"description": "创建新的部件.",
"type": "POST",
"path": "jaxrs/widget",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成.",
"isBaseType": true
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "所属的Portal.",
"isBaseType": true
},
{
"name": "data",
"type": "String",
"isCollection": false,
"description": "文本内容.",
"isBaseType": true
},
{
"name": "mobileData",
"type": "String",
"isCollection": false,
"description": "移动端文本内容.",
"isBaseType": true
},
{
"name": "hasMobile",
"type": "Boolean",
"isCollection": false,
"description": "是否有移动端内容.",
"isBaseType": true
}
],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
},
{
"name": "delete",
"className": "com.x.portal.assemble.designer.jaxrs.widget.ActionDelete",
"description": "删除指定的部件",
"type": "DELETE",
"path": "jaxrs/widget/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "value",
"type": "Boolean",
"isCollection": false,
"description": "布尔值."
}
]
},
{
"name": "edit",
"className": "com.x.portal.assemble.designer.jaxrs.widget.ActionEdit",
"description": "更新指定的部件.",
"type": "PUT",
"path": "jaxrs/widget/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称.",
"isBaseType": true
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名.",
"isBaseType": true
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述.",
"isBaseType": true
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "所属的Portal.",
"isBaseType": true
},
{
"name": "data",
"type": "String",
"isCollection": false,
"description": "文本内容.",
"isBaseType": true
},
{
"name": "mobileData",
"type": "String",
"isCollection": false,
"description": "移动端文本内容.",
"isBaseType": true
},
{
"name": "hasMobile",
"type": "Boolean",
"isCollection": false,
"description": "是否有移动端内容.",
"isBaseType": true
}
],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "id"
}
]
},
{
"name": "get",
"className": "com.x.portal.assemble.designer.jaxrs.widget.ActionGet",
"description": "获取部件.",
"type": "GET",
"path": "jaxrs/widget/{id}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "id",
"type": "String",
"description": "标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "所属的Portal."
},
{
"name": "data",
"type": "String",
"isCollection": false,
"description": "文本内容."
},
{
"name": "mobileData",
"type": "String",
"isCollection": false,
"description": "移动端文本内容."
},
{
"name": "hasMobile",
"type": "Boolean",
"isCollection": false,
"description": "是否有移动端内容."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
},
{
"name": "listWithPortal",
"className": "com.x.portal.assemble.designer.jaxrs.widget.ActionListWithPortal",
"description": "列示指定Portal下的部件.",
"type": "GET",
"path": "jaxrs/widget/list/portal/{portalId}",
"contentType": "application/json",
"resultContentType": "application/json; charset\u003dUTF-8",
"useJsonElementParameter": false,
"useStringParameter": false,
"pathParameters": [
{
"name": "portalId",
"type": "String",
"description": "Portal标识"
}
],
"formParameters": [],
"queryParameters": [],
"ins": [],
"outs": [
{
"name": "id",
"type": "String",
"isCollection": false,
"description": "数据库主键,自动生成."
},
{
"name": "name",
"type": "String",
"isCollection": false,
"description": "名称."
},
{
"name": "alias",
"type": "String",
"isCollection": false,
"description": "别名."
},
{
"name": "description",
"type": "String",
"isCollection": false,
"description": "描述."
},
{
"name": "portal",
"type": "String",
"isCollection": false,
"description": "所属的Portal."
},
{
"name": "hasMobile",
"type": "Boolean",
"isCollection": false,
"description": "是否有移动端内容."
},
{
"name": "createTime",
"type": "Date",
"isCollection": false,
"description": "创建时间,自动生成,索引创建在约束中."
},
{
"name": "updateTime",
"type": "Date",
"isCollection": false,
"description": "修改时间,自动生成,索引创建在约束中."
}
]
}
]
}
]
}
\ No newline at end of file
package com.x.portal.assemble.designer;
import com.x.base.core.container.EntityManagerContainer;
public abstract class AbstractFactory {
private Business business;
public AbstractFactory(Business business) throws Exception {
try {
if (null == business) {
throw new Exception("business can not be null.");
}
this.business = business;
} catch (Exception e) {
throw new Exception("can not instantiating factory.");
}
}
public EntityManagerContainer entityManagerContainer() throws Exception {
return this.business.entityManagerContainer();
}
public Business business() throws Exception {
return this.business;
}
}
package com.x.portal.assemble.designer;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import com.x.base.core.project.Context;
@WebListener
public class ApplicationServletContextListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
try {
ThisApplication.context = Context.concrete(servletContextEvent);
ThisApplication.init();
ThisApplication.context().regist();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
try {
ThisApplication.destroy();
ThisApplication.context.destrory(servletContextEvent);
} catch (Exception e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
package com.x.portal.assemble.designer;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.organization.core.express.Organization;
import com.x.portal.assemble.designer.factory.FileFactory;
import com.x.portal.assemble.designer.factory.PageFactory;
import com.x.portal.assemble.designer.factory.PortalFactory;
import com.x.portal.assemble.designer.factory.ScriptFactory;
import com.x.portal.assemble.designer.factory.TemplatePageFactory;
import com.x.portal.assemble.designer.factory.WidgetFactory;
import com.x.portal.core.entity.Portal;
public class Business {
private EntityManagerContainer emc;
public Business(EntityManagerContainer emc) throws Exception {
this.emc = emc;
}
public EntityManagerContainer entityManagerContainer() {
return this.emc;
}
public boolean isPortalManager(EffectivePerson effectivePerson) throws Exception {
if (effectivePerson.isManager()
|| (this.organization().person().hasRole(effectivePerson, OrganizationDefinition.PortalManager))) {
return true;
}
return false;
}
private Organization organization;
public Organization organization() throws Exception {
if (null == this.organization) {
this.organization = new Organization(ThisApplication.context());
}
return organization;
}
private PortalFactory portal;
public PortalFactory portal() throws Exception {
if (null == this.portal) {
this.portal = new PortalFactory(this);
}
return portal;
}
private WidgetFactory widget;
public WidgetFactory widget() throws Exception {
if (null == this.widget) {
this.widget = new WidgetFactory(this);
}
return widget;
}
private PageFactory page;
public PageFactory page() throws Exception {
if (null == this.page) {
this.page = new PageFactory(this);
}
return page;
}
private ScriptFactory script;
public ScriptFactory script() throws Exception {
if (null == this.script) {
this.script = new ScriptFactory(this);
}
return script;
}
private FileFactory file;
public FileFactory file() throws Exception {
if (null == this.file) {
this.file = new FileFactory(this);
}
return file;
}
private TemplatePageFactory templatePage;
public TemplatePageFactory templatePage() throws Exception {
if (null == this.templatePage) {
this.templatePage = new TemplatePageFactory(this);
}
return templatePage;
}
public boolean editable(EffectivePerson effectivePerson, Portal o) throws Exception {
boolean result = false;
if (effectivePerson.isManager()
|| (this.organization().person().hasRole(effectivePerson, OrganizationDefinition.PortalManager))) {
result = true;
}
if (!result && (null != o)) {
if (effectivePerson.isPerson(o.getControllerList()) || effectivePerson.isPerson(o.getCreatorPerson())) {
result = true;
}
}
return result;
}
}
\ No newline at end of file
package com.x.portal.assemble.designer;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
public class ComparePortal extends GsonPropertyObject {
@FieldDescribe("导入名称")
private String name;
@FieldDescribe("导入id")
private String id;
@FieldDescribe("导入别名")
private String alias;
@FieldDescribe("是否已经存在")
private Boolean exist;
@FieldDescribe("已经存在名称")
private String existName;
@FieldDescribe("已经存在id")
private String existId;
@FieldDescribe("已经存在别名")
private String existAlias;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public Boolean getExist() {
return exist;
}
public void setExist(Boolean exist) {
this.exist = exist;
}
public String getExistName() {
return existName;
}
public void setExistName(String existName) {
this.existName = existName;
}
public String getExistId() {
return existId;
}
public void setExistId(String existId) {
this.existId = existId;
}
public String getExistAlias() {
return existAlias;
}
public void setExistAlias(String existAlias) {
this.existAlias = existAlias;
}
}
package com.x.portal.assemble.designer;
import com.x.base.core.project.Context;
public class ThisApplication {
protected static Context context;
public static Context context() {
return context;
}
public static void init() {
try {
} catch (Exception e) {
e.printStackTrace();
}
}
public static void destroy() {
try {
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.x.portal.assemble.designer.factory;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.portal.assemble.designer.AbstractFactory;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.File_;
public class FileFactory extends AbstractFactory {
public FileFactory(Business business) throws Exception {
super(business);
}
public List<String> listWithPortal(String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(File.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<File> root = cq.from(File.class);
Predicate p = cb.equal(root.get(File_.portal), portalId);
cq.select(root.get(File_.id)).where(p);
return em.createQuery(cq).getResultList();
}
public List<File> listWithPortalObject(String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(File.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<File> cq = cb.createQuery(File.class);
Root<File> root = cq.from(File.class);
Predicate p = cb.equal(root.get(File_.portal), portalId);
cq.select(root).where(p);
return em.createQuery(cq).getResultList();
}
public <T extends File> List<T> sort(List<T> list) {
list = list.stream().sorted(Comparator.comparing(File::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList());
return list;
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.factory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.portal.assemble.designer.AbstractFactory;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Page_;
public class PageFactory extends AbstractFactory {
private List<String> FIRSTPAGE_NAMES = new ArrayList<>(
Arrays.asList(new String[] { "index", "default", "首页", "起始页", "first", "homepage" }));
public PageFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public String getWithNameWithPortal(String name, String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Page.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Page> root = cq.from(Page.class);
Predicate p = cb.equal(root.get(Page_.name), name);
p = cb.and(p, cb.equal(root.get(Page_.portal), portalId));
List<String> list = em.createQuery(cq.select(root.get(Page_.id)).where(p)).setMaxResults(1).getResultList();
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
public String getWithAliasWithPortal(String alias, String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Page.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Page> root = cq.from(Page.class);
Predicate p = cb.equal(root.get(Page_.alias), alias);
p = cb.and(p, cb.equal(root.get(Page_.portal), portalId));
List<String> list = em.createQuery(cq.select(root.get(Page_.id)).where(p)).setMaxResults(1).getResultList();
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
public List<String> listWithPortal(String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Page.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Page> root = cq.from(Page.class);
Predicate p = cb.equal(root.get(Page_.portal), portalId);
List<String> list = em.createQuery(cq.select(root.get(Page_.id)).where(p)).getResultList();
return list;
}
public List<Page> listObjectWithPortal(String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Page.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Page> cq = cb.createQuery(Page.class);
Root<Page> root = cq.from(Page.class);
Predicate p = cb.equal(root.get(Page_.portal), portalId);
List<Page> list = em.createQuery(cq.select(root).where(p)).getResultList();
return list;
}
public boolean isFirstPage(Page page) {
return FIRSTPAGE_NAMES.contains(page.getName());
}
public String findFirstPage(String portalId) throws Exception {
List<String> ids = this.listWithPortal(portalId);
for (Page o : this.business().entityManagerContainer().list(Page.class, ids)) {
if (FIRSTPAGE_NAMES.contains(o.getName())) {
return o.getId();
}
}
return null;
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.factory;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.portal.assemble.designer.AbstractFactory;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Portal_;
public class PortalFactory extends AbstractFactory {
public PortalFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public String getWithName(String name) throws Exception {
EntityManager em = this.entityManagerContainer().get(Portal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Portal> root = cq.from(Portal.class);
Predicate p = cb.equal(root.get(Portal_.name), name);
List<String> list = em.createQuery(cq.select(root.get(Portal_.id)).where(p)).setMaxResults(1).getResultList();
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
public String getWithAlias(String alias) throws Exception {
EntityManager em = this.entityManagerContainer().get(Portal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Portal> root = cq.from(Portal.class);
Predicate p = cb.equal(root.get(Portal_.alias), alias);
List<String> list = em.createQuery(cq.select(root.get(Portal_.id)).where(p)).setMaxResults(1).getResultList();
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
public List<String> list() throws Exception {
EntityManager em = this.entityManagerContainer().get(Portal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Portal> root = cq.from(Portal.class);
List<String> list = em.createQuery(cq.select(root.get(Portal_.id))).getResultList();
return list;
}
public <T extends Portal> List<T> sort(List<T> list) {
list = list.stream()
.sorted(Comparator.comparing(Portal::getAlias, Comparator.nullsLast(String::compareTo))
.thenComparing(Portal::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList());
return list;
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.factory;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.portal.assemble.designer.AbstractFactory;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Script;
import com.x.portal.core.entity.Script_;
public class ScriptFactory extends AbstractFactory {
public ScriptFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public String getWithIdWithPortal(String id, String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.id), id);
p = cb.and(p, cb.equal(root.get(Script_.portal), portalId));
List<String> list = em.createQuery(cq.select(root.get(Script_.id)).where(p)).setMaxResults(1).getResultList();
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
public String getWithNameWithPortal(String name, String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.name), name);
p = cb.and(p, cb.equal(root.get(Script_.portal), portalId));
List<String> list = em.createQuery(cq.select(root.get(Script_.id)).where(p)).setMaxResults(1).getResultList();
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
public String getWithAliasWithPortal(String alias, String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.alias), alias);
p = cb.and(p, cb.equal(root.get(Script_.portal), portalId));
List<String> list = em.createQuery(cq.select(root.get(Script_.id)).where(p)).setMaxResults(1).getResultList();
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
public List<String> listWithPortal(String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.portal), portalId);
List<String> list = em.createQuery(cq.select(root.get(Script_.id)).where(p)).getResultList();
return list;
}
public List<Script> listObjectWithPortal(String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.portal), portalId);
List<Script> list = em.createQuery(cq.select(root).where(p)).getResultList();
return list;
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.factory;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.designer.AbstractFactory;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.TemplatePage;
import com.x.portal.core.entity.TemplatePage_;
public class TemplatePageFactory extends AbstractFactory {
public TemplatePageFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public String getWithName(String name) throws Exception {
EntityManager em = this.entityManagerContainer().get(TemplatePage.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<TemplatePage> root = cq.from(TemplatePage.class);
Predicate p = cb.equal(root.get(TemplatePage_.name), name);
List<String> list = em.createQuery(cq.select(root.get(TemplatePage_.id)).where(p)).setMaxResults(1)
.getResultList();
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
public String getWithAlias(String alias) throws Exception {
EntityManager em = this.entityManagerContainer().get(TemplatePage.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<TemplatePage> root = cq.from(TemplatePage.class);
Predicate p = cb.equal(root.get(TemplatePage_.alias), alias);
List<String> list = em.createQuery(cq.select(root.get(TemplatePage_.id)).where(p)).setMaxResults(1)
.getResultList();
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
public List<String> list() throws Exception {
EntityManager em = this.entityManagerContainer().get(TemplatePage.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<TemplatePage> root = cq.from(TemplatePage.class);
List<String> list = em.createQuery(cq.select(root.get(TemplatePage_.id))).getResultList();
return list;
}
public boolean checkPermission(EffectivePerson effectivePerson, TemplatePage o) throws Exception {
if (effectivePerson.isNotManager()
&& (!this.business().organization().person().hasRole(effectivePerson,
OrganizationDefinition.PortalManager))
&& (effectivePerson.isNotPerson(o.getControllerList()))
&& effectivePerson.isNotPerson(o.getCreatorPerson())) {
return false;
}
return true;
}
public List<String> listEditable(EffectivePerson effectivePerson) throws Exception {
EntityManager em = this.business().entityManagerContainer().get(TemplatePage.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<TemplatePage> root = cq.from(TemplatePage.class);
Predicate p = cb.conjunction();
if (effectivePerson.isNotManager()) {
p = cb.isMember(effectivePerson.getDistinguishedName(), root.get(TemplatePage_.controllerList));
p = cb.or(p, cb.equal(root.get(TemplatePage_.creatorPerson), effectivePerson.getDistinguishedName()));
}
cq.select(root.get(TemplatePage_.id)).where(p).distinct(true);
List<String> list = em.createQuery(cq.select(root.get(TemplatePage_.id)).where(p)).getResultList();
return list;
}
public List<String> listEditableWithCategory(EffectivePerson effectivePerson, String category) throws Exception {
EntityManager em = this.business().entityManagerContainer().get(TemplatePage.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<TemplatePage> root = cq.from(TemplatePage.class);
Predicate p = cb.equal(root.get(TemplatePage_.category), category);
if (effectivePerson.isNotManager()) {
p = cb.and(p,
cb.or(cb.isMember(effectivePerson.getDistinguishedName(), root.get(TemplatePage_.controllerList)),
cb.equal(root.get(TemplatePage_.creatorPerson), effectivePerson.getDistinguishedName())));
}
cq.select(root.get(TemplatePage_.id)).where(p).distinct(true);
List<String> list = em.createQuery(cq.select(root.get(TemplatePage_.id)).where(p)).getResultList();
return list;
}
public boolean editable(EffectivePerson effectivePerson, TemplatePage o) throws Exception {
if (ListTools.isEmpty(o.getAvailableUnitList(), o.getAvailableIdentityList())) {
return true;
}
if (effectivePerson.isManager() || (this.business().organization().person().hasRole(effectivePerson,
OrganizationDefinition.PortalManager))) {
return true;
}
if (effectivePerson.isPerson(o.getControllerList())) {
return true;
}
if (effectivePerson.isPerson(o.getCreatorPerson())) {
return true;
}
List<String> identities = this.business().organization().identity().listWithPerson(effectivePerson);
if (ListTools.containsAny(identities, o.getAvailableIdentityList())) {
return true;
}
List<String> units = this.business().organization().unit().listWithPerson(effectivePerson);
units = this.business().organization().unit().listWithUnitSupNested(units);
if (ListTools.containsAny(units, o.getAvailableUnitList())) {
return true;
}
return false;
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.factory;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.portal.assemble.designer.AbstractFactory;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Widget;
import com.x.portal.core.entity.Widget_;
public class WidgetFactory extends AbstractFactory {
public WidgetFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public String getWithNameWithPortal(String name, String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Widget.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Widget> root = cq.from(Widget.class);
Predicate p = cb.equal(root.get(Widget_.name), name);
p = cb.and(p, cb.equal(root.get(Widget_.portal), portalId));
List<String> list = em.createQuery(cq.select(root.get(Widget_.id)).where(p)).setMaxResults(1).getResultList();
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
public String getWithAliasWithPortal(String alias, String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Widget.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Widget> root = cq.from(Widget.class);
Predicate p = cb.equal(root.get(Widget_.alias), alias);
p = cb.and(p, cb.equal(root.get(Widget_.portal), portalId));
List<String> list = em.createQuery(cq.select(root.get(Widget_.id)).where(p)).setMaxResults(1).getResultList();
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
public List<String> listWithPortal(String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Widget.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Widget> root = cq.from(Widget.class);
Predicate p = cb.equal(root.get(Widget_.portal), portalId);
List<String> list = em.createQuery(cq.select(root.get(Widget_.id)).where(p)).getResultList();
return list;
}
public List<Widget> listObjectWithPortal(String portalId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Widget.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Widget> cq = cb.createQuery(Widget.class);
Root<Widget> root = cq.from(Widget.class);
Predicate p = cb.equal(root.get(Widget_.portal), portalId);
List<Widget> list = em.createQuery(cq.select(root).where(p)).getResultList();
return list;
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import com.x.base.core.project.jaxrs.AbstractActionApplication;
import com.x.portal.assemble.designer.jaxrs.file.FileAction;
import com.x.portal.assemble.designer.jaxrs.id.IdAction;
import com.x.portal.assemble.designer.jaxrs.input.InputAction;
import com.x.portal.assemble.designer.jaxrs.output.OutputAction;
import com.x.portal.assemble.designer.jaxrs.page.PageAction;
import com.x.portal.assemble.designer.jaxrs.portal.PortalAction;
import com.x.portal.assemble.designer.jaxrs.portalcategory.PortalCategoryAction;
import com.x.portal.assemble.designer.jaxrs.script.ScriptAction;
import com.x.portal.assemble.designer.jaxrs.templatepage.TemplatePageAction;
import com.x.portal.assemble.designer.jaxrs.widget.WidgetAction;
@ApplicationPath("jaxrs")
public class ActionApplication extends AbstractActionApplication {
public Set<Class<?>> getClasses() {
classes.add(PortalAction.class);
classes.add(PortalCategoryAction.class);
classes.add(WidgetAction.class);
classes.add(FileAction.class);
classes.add(PageAction.class);
classes.add(ScriptAction.class);
classes.add(TemplatePageAction.class);
classes.add(IdAction.class);
classes.add(OutputAction.class);
classes.add(InputAction.class);
return classes;
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/file/*", asyncSupported = true)
public class FileJaxrsFilter extends CipherManagerUserJaxrsFilter {
}
package com.x.portal.assemble.designer.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/id/*", asyncSupported = true)
public class IdJaxrsFilter extends CipherManagerUserJaxrsFilter {
}
package com.x.portal.assemble.designer.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.CipherManagerJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/input/*", asyncSupported = true)
public class InputJaxrsFilter extends CipherManagerJaxrsFilter {
}
package com.x.portal.assemble.designer.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.CipherManagerJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/output/*", asyncSupported = true)
public class OutputJaxrsFilter extends CipherManagerJaxrsFilter {
}
package com.x.portal.assemble.designer.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/page/*", asyncSupported = true)
public class PageJaxrsFilter extends CipherManagerUserJaxrsFilter {
}
package com.x.portal.assemble.designer.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/portalcategory/*", asyncSupported = true)
public class PortalCategoryJaxrsFilter extends CipherManagerUserJaxrsFilter {
}
package com.x.portal.assemble.designer.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/portal/*", asyncSupported = true)
public class PortalJaxrsFilter extends CipherManagerUserJaxrsFilter {
}
package com.x.portal.assemble.designer.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/servlet/portal/*", asyncSupported = true)
public class PortalServletFilter extends CipherManagerUserJaxrsFilter {
}
package com.x.portal.assemble.designer.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/script/*", asyncSupported = true)
public class ScriptJaxrsFilter extends CipherManagerUserJaxrsFilter {
}
package com.x.portal.assemble.designer.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/templatepage/*", asyncSupported = true)
public class TemplatePageJaxrsFilter extends CipherManagerUserJaxrsFilter {
}
package com.x.portal.assemble.designer.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/widget/*", asyncSupported = true)
public class WidgetJaxrsFilter extends CipherManagerUserJaxrsFilter {
}
package com.x.portal.assemble.designer.jaxrs.file;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionDuplicateFlag;
import com.x.base.core.project.exception.ExceptionDuplicateRestrictFlag;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Portal;
class ActionCreate extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
com.x.portal.assemble.designer.Business business = new Business(emc);
Portal portal = emc.flag(wi.getPortal(), Portal.class);
if (null == portal) {
throw new ExceptionEntityNotExist(wi.getPortal(), Portal.class);
}
if (!business.editable(effectivePerson, portal)) {
throw new ExceptionAccessDenied(effectivePerson);
}
File file = new File();
Wi.copier.copy(wi, file);
/** 设置file 的Id由前端生成提供 */
file.setId(wi.getId());
file.setPortal(portal.getId());
this.updateCreator(file, effectivePerson);
emc.beginTransaction(File.class);
if (StringUtils.isNotEmpty(file.getAlias())) {
if (emc.duplicateWithFlags(file.getId(), File.class, file.getAlias())) {
throw new ExceptionDuplicateFlag(File.class, file.getAlias());
}
}
if (StringUtils.isEmpty(file.getName())) {
throw new ExceptionEmptyName();
}
if (emc.duplicateWithRestrictFlags(File.class, File.portal_FIELDNAME, file.getPortal(), file.getId(),
ListTools.toList(file.getName()))) {
throw new ExceptionDuplicateRestrictFlag(File.class, file.getName());
}
emc.persist(file, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(File.class);
Wo wo = new Wo();
wo.setId(file.getId());
result.setData(wo);
return result;
}
}
public static class Wo extends WoId {
}
public static class Wi extends File {
private static final long serialVersionUID = 4289841165185269299L;
static WrapCopier<Wi, File> copier = WrapCopierFactory.wi(Wi.class, File.class, null,
ListTools.toList(JpaObject.FieldsUnmodifyExcludeId, com.x.portal.core.entity.File.data_FIELDNAME));
}
}
package com.x.portal.assemble.designer.jaxrs.file;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Portal;
class ActionDelete extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
File file = emc.find(flag, File.class);
if (null == file) {
throw new ExceptionEntityNotExist(flag, File.class);
}
Portal portal = emc.flag(file.getPortal(), Portal.class);
if (null == portal) {
throw new ExceptionEntityNotExist(file.getPortal(), Portal.class);
}
if (!business.editable(effectivePerson, portal)) {
throw new ExceptionAccessDenied(effectivePerson);
}
emc.beginTransaction(File.class);
emc.remove(file, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(File.class);
Wo wo = new Wo();
wo.setId(file.getId());
result.setData(wo);
return result;
}
}
public static class Wo extends WoId {
}
}
package com.x.portal.assemble.designer.jaxrs.file;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.jaxrs.WoFile;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
class ActionDownload extends StandardJaxrsAction {
private Ehcache cache = ApplicationCache.instance().getCache(File.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag);
Element element = cache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
} else {
File file = emc.flag(flag, File.class);
if (null == file) {
throw new ExceptionEntityNotExist(flag, File.class);
}
Portal portal = emc.find(file.getPortal(), Portal.class);
if (null == portal) {
throw new ExceptionEntityNotExist(file.getPortal(), Portal.class);
}
byte[] bs = new byte[] {};
if (StringUtils.isNotEmpty(file.getData())) {
bs = Base64.decodeBase64(file.getData());
}
wo = new Wo(bs, this.contentType(false, file.getFileName()),
this.contentDisposition(false, file.getFileName()));
/**
* 对10M以下的文件进行缓存
*/
if (bs.length < (1024 * 1024 * 10)) {
cache.put(new Element(cacheKey, wo));
}
}
result.setData(wo);
return result;
}
}
public static class Wo extends WoFile {
public Wo(byte[] bytes, String contentType, String contentDisposition) {
super(bytes, contentType, contentDisposition);
}
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.file;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionDuplicateFlag;
import com.x.base.core.project.exception.ExceptionDuplicateRestrictFlag;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Portal;
class ActionEdit extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
File file = emc.flag(id, File.class);
if (null == file) {
throw new ExceptionEntityNotExist(id, File.class);
}
Portal portal = emc.flag(file.getPortal(), Portal.class);
if (null == portal) {
throw new ExceptionEntityNotExist(wi.getPortal(), Portal.class);
}
if ((!business.editable(effectivePerson, portal))) {
throw new ExceptionAccessDenied(effectivePerson);
}
Wi.copier.copy(wi, file);
file.setPortal(portal.getId());
this.updateCreator(file, effectivePerson);
emc.beginTransaction(File.class);
if (StringUtils.isNotEmpty(file.getAlias())) {
if (emc.duplicateWithFlags(file.getId(), File.class, file.getAlias())) {
throw new ExceptionDuplicateFlag(File.class, file.getAlias());
}
}
if (StringUtils.isEmpty(file.getName())) {
throw new ExceptionEmptyName();
}
if (emc.duplicateWithRestrictFlags(File.class, File.portal_FIELDNAME, file.getPortal(), file.getId(),
ListTools.toList(file.getName()))) {
throw new ExceptionDuplicateRestrictFlag(File.class, file.getName());
}
emc.check(file, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(File.class);
Wo wo = new Wo();
wo.setId(file.getId());
result.setData(wo);
return result;
}
}
public static class Wo extends WoId {
}
public static class Wi extends File {
private static final long serialVersionUID = 4289841165185269299L;
static WrapCopier<Wi, File> copier = WrapCopierFactory.wi(Wi.class, File.class, null,
ListTools.toList(JpaObject.FieldsUnmodify));
}
}
package com.x.portal.assemble.designer.jaxrs.file;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Portal;
class ActionGet extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
File file = emc.flag(flag, File.class);
if (null == file) {
throw new ExceptionEntityNotExist(flag, File.class);
}
Portal portal = emc.find(file.getPortal(), Portal.class);
if (null == portal) {
throw new ExceptionEntityNotExist(file.getPortal(), Portal.class);
}
if (!business.editable(effectivePerson, portal)) {
throw new ExceptionAccessDenied(effectivePerson);
}
Wo wo = Wo.copier.copy(file);
result.setData(wo);
return result;
}
}
public static class Wo extends File {
private static final long serialVersionUID = 1541438199059150837L;
static WrapCopier<File, Wo> copier = WrapCopierFactory.wo(File.class, Wo.class, null,
ListTools.toList(JpaObject.FieldsInvisible, File.data_FIELDNAME));
}
}
package com.x.portal.assemble.designer.jaxrs.file;
import java.util.List;
import com.x.base.core.entity.JpaObject;
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.http.ActionResult;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.core.entity.File;
class ActionListNext extends BaseAction {
ActionResult<List<Wo>> execute(String id, Integer count) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
result = this.standardListNext(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null, null, null, null, null, null,
true, DESC);
return result;
}
public static class Wo extends File {
private static final long serialVersionUID = -7495725325510376323L;
public static WrapCopier<File, Wo> copier = WrapCopierFactory.wo(File.class, Wo.class, null,
ListTools.toList(JpaObject.FieldsInvisible, File.data_FIELDNAME));
@FieldDescribe("排序号")
private Long rank;
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
}
}
package com.x.portal.assemble.designer.jaxrs.file;
import java.util.List;
import com.x.base.core.entity.JpaObject;
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.http.ActionResult;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.core.entity.File;
class ActionListPrev extends BaseAction {
ActionResult<List<Wo>> execute(String id, Integer count) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
result = this.standardListPrev(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null, null, null, null, null, null,
true, DESC);
return result;
}
public static class Wo extends File {
private static final long serialVersionUID = -7495725325510376323L;
public static WrapCopier<File, Wo> copier = WrapCopierFactory.wo(File.class, Wo.class, null,
ListTools.toList(JpaObject.FieldsInvisible, File.data_FIELDNAME));
@FieldDescribe("排序号")
private Long rank;
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
}
}
package com.x.portal.assemble.designer.jaxrs.file;
import java.util.List;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Portal;
class ActionListWithPortal extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String portalFlag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
Portal portal = emc.flag(portalFlag, Portal.class);
if (null == portal) {
throw new ExceptionEntityNotExist(portalFlag, Portal.class);
}
if (!business.editable(effectivePerson, portal)) {
throw new ExceptionAccessDenied(effectivePerson);
}
List<Wo> wos = emc.fetchEqual(File.class, Wo.copier, File.portal_FIELDNAME, portal.getId());
wos = business.file().sort(wos);
result.setData(wos);
return result;
}
}
public static class Wo extends File {
private static final long serialVersionUID = -7495725325510376323L;
public static WrapCopier<File, Wo> copier = WrapCopierFactory.wo(File.class, Wo.class, null,
ListTools.toList(JpaObject.FieldsInvisible, File.data_FIELDNAME));
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.file;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Portal;
class ActionUpload extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, String fileName,byte[] bytes,
FormDataContentDisposition disposition) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
File file = emc.flag(id, File.class);
if (null == file) {
throw new ExceptionEntityNotExist(id, File.class);
}
Portal portal = emc.find(file.getPortal(), Portal.class);
if (null == portal) {
throw new ExceptionEntityNotExist(file.getPortal(), Portal.class);
}
if ((!business.editable(effectivePerson, portal))) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
emc.beginTransaction(File.class);
file.setLength((long) bytes.length);
file.setData(Base64.encodeBase64String(bytes));
if (StringUtils.isEmpty(fileName)) {
file.setFileName(this.fileName(disposition));
} else {
file.setFileName(fileName);
}
emc.commit();
ApplicationCache.notify(File.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
}
public static class Wo extends WrapBoolean {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.file;
import java.util.Date;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.core.entity.File;
abstract class BaseAction extends StandardJaxrsAction {
protected void updateCreator(File file,EffectivePerson effectivePerson){
file.setLastUpdatePerson(effectivePerson.getDistinguishedName());
file.setLastUpdateTime(new Date());
}
}
package com.x.portal.assemble.designer.jaxrs.file;
import com.x.base.core.project.exception.PromptException;
class ExceptionEmptyName extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionEmptyName() {
super("名称不能为空.");
}
}
package com.x.portal.assemble.designer.jaxrs.file;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("file")
@JaxrsDescribe("文件")
public class FileAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(FileAction.class);
@JaxrsMethodDescribe(value = "列示文件对象,下一页.", action = ActionListNext.class)
@GET
@Path("list/{id}/next/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listNext(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id,
@JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
ActionResult<List<ActionListNext.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListNext().execute(id, count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示文件对象,上一页.", action = ActionListPrev.class)
@GET
@Path("list/{id}/prev/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listPrev(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id,
@JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
ActionResult<List<ActionListPrev.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListPrev().execute(id, count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "获取文件内容.", action = ActionGet.class)
@GET
@Path("{flag}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("flag") String flag) {
ActionResult<ActionGet.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionGet().execute(effectivePerson, flag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "创建文件.", action = ActionCreate.class)
@POST
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void create(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<ActionCreate.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionCreate().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "更新文件.", action = ActionEdit.class)
@PUT
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void update(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id, JsonElement jsonElement) {
ActionResult<ActionEdit.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionEdit().execute(effectivePerson, id, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "删除文件.", action = ActionDelete.class)
@DELETE
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDelete().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "根据应用列示文件.", action = ActionListWithPortal.class)
@GET
@Path("list/application/{applicationFlag}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listWithApplication(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("应用标识") @PathParam("applicationFlag") String applicationFlag) {
ActionResult<List<ActionListWithPortal.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListWithPortal().execute(effectivePerson, applicationFlag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "上传文件内容.", action = ActionUpload.class)
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Path("{id}/upload")
public void upload(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id,
@JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("文件内容") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionUpload.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionUpload().execute(effectivePerson, id, fileName, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "获取文件内容.", action = ActionDownload.class)
@GET
@Path("{id}/download")
@Consumes(MediaType.APPLICATION_JSON)
public void download(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionDownload.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDownload().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.id;
import java.util.ArrayList;
import java.util.List;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.jaxrs.WoId;
class ActionGet extends BaseAction {
ActionResult<List<Wo>> execute(Integer count) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wos = new ArrayList<>();
if (count > 0 && count < 200) {
for (int i = 0; i < count; i++) {
Wo wo = new Wo();
wo.setId(JpaObject.createId());
wos.add(wo);
}
}
result.setData(wos);
return result;
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.id;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
abstract class BaseAction extends StandardJaxrsAction {
}
package com.x.portal.assemble.designer.jaxrs.id;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("id")
@JaxrsDescribe("标识")
public class IdAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(IdAction.class);
@JaxrsMethodDescribe(value = "创建用于ID值的UUID", action = ActionGet.class)
@GET
@Path("{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("创建数量") @PathParam("count") Integer count) {
ActionResult<List<ActionGet.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionGet().execute(count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.input;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
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.portal.assemble.designer.Business;
import com.x.portal.assemble.designer.ComparePortal;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.wrap.WrapPortal;
class ActionCompare extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionCompare.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
// logger.debug(effectivePerson, "receive:{}.", jsonElement);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Portal exist = this.getPortal(business, wi.getId(), wi.getName(), wi.getAlias());
Wo wo = new Wo();
wo.setId(wi.getId());
wo.setName(wi.getName());
wo.setAlias(wi.getAlias());
wo.setExist(false);
if (null != exist) {
wo.setExist(true);
wo.setExistName(exist.getName());
wo.setExistAlias(exist.getAlias());
wo.setExistId(exist.getId());
}
result.setData(wo);
return result;
}
}
public static class Wi extends WrapPortal {
private static final long serialVersionUID = -4612391443319365035L;
}
public static class Wo extends ComparePortal {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.input;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.ApplicationCache;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.StringTools;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import com.x.portal.core.entity.Widget;
import com.x.portal.core.entity.wrap.WrapFile;
import com.x.portal.core.entity.wrap.WrapPage;
import com.x.portal.core.entity.wrap.WrapPortal;
import com.x.portal.core.entity.wrap.WrapScript;
import com.x.portal.core.entity.wrap.WrapWidget;
class ActionCover extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionCover.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
// logger.debug(effectivePerson, "jsonElement:{}.", jsonElement);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
Portal portal = business.entityManagerContainer().find(wi.getId(), Portal.class);
if (null == portal) {
throw new ExceptionPortalNotExist(wi.getId());
}
if (!business.editable(effectivePerson, portal)) {
throw new ExceptionPortalAccessDenied(effectivePerson.getName(), portal.getName(), portal.getId());
}
this.cover(business, wi, portal);
wo.setId(portal.getId());
result.setData(wo);
return result;
}
}
private void cover(Business business, Wi wi, Portal portal) throws Exception {
List<JpaObject> persistObjects = new ArrayList<>();
for (WrapWidget _o : wi.getWidgetList()) {
Widget obj = business.entityManagerContainer().find(_o.getId(), Widget.class);
if (null != obj) {
WrapWidget.inCopier.copy(_o, obj);
} else {
obj = WrapWidget.inCopier.copy(_o);
persistObjects.add(obj);
}
if (StringUtils.isNotEmpty(obj.getAlias())) {
obj.setAlias(
this.idleAliasWithPortal(business, portal.getId(), obj.getAlias(), Widget.class, obj.getId()));
}
if (StringUtils.isNotEmpty(obj.getName())) {
obj.setName(
this.idleNameWithPortal(business, portal.getId(), obj.getName(), Widget.class, obj.getId()));
}
obj.setPortal(portal.getId());
}
for (WrapPage _o : wi.getPageList()) {
Page obj = business.entityManagerContainer().find(_o.getId(), Page.class);
if (null != obj) {
WrapPage.inCopier.copy(_o, obj);
} else {
obj = WrapPage.inCopier.copy(_o);
persistObjects.add(obj);
}
if (StringUtils.isNotEmpty(obj.getAlias())) {
obj.setAlias(
this.idleAliasWithPortal(business, portal.getId(), obj.getAlias(), Page.class, obj.getId()));
}
if (StringUtils.isNotEmpty(obj.getName())) {
obj.setName(this.idleNameWithPortal(business, portal.getId(), obj.getName(), Page.class, obj.getId()));
}
obj.setPortal(portal.getId());
}
for (WrapScript _o : wi.getScriptList()) {
Script obj = business.entityManagerContainer().find(_o.getId(), Script.class);
if (null != obj) {
WrapScript.inCopier.copy(_o, obj);
} else {
obj = WrapScript.inCopier.copy(_o);
persistObjects.add(obj);
}
if (StringUtils.isNotEmpty(obj.getAlias())) {
obj.setAlias(
this.idleAliasWithPortal(business, portal.getId(), obj.getAlias(), Script.class, obj.getId()));
}
if (StringUtils.isNotEmpty(obj.getName())) {
obj.setName(
this.idleNameWithPortal(business, portal.getId(), obj.getName(), Script.class, obj.getId()));
}
obj.setPortal(portal.getId());
}
for (WrapFile _o : wi.getFileList()) {
File obj = business.entityManagerContainer().find(_o.getId(), File.class);
if (null != obj) {
WrapFile.inCopier.copy(_o, obj);
} else {
obj = WrapFile.inCopier.copy(_o);
persistObjects.add(obj);
}
if (StringUtils.isNotEmpty(obj.getAlias())) {
obj.setAlias(
this.idleAliasWithPortal(business, portal.getId(), obj.getAlias(), File.class, obj.getId()));
}
if (StringUtils.isNotEmpty(obj.getName())) {
obj.setName(this.idleNameWithPortal(business, portal.getId(), obj.getName(), File.class, obj.getId()));
}
obj.setPortal(portal.getId());
}
business.entityManagerContainer().beginTransaction(Portal.class);
business.entityManagerContainer().beginTransaction(Widget.class);
business.entityManagerContainer().beginTransaction(Page.class);
business.entityManagerContainer().beginTransaction(Script.class);
business.entityManagerContainer().beginTransaction(File.class);
for (JpaObject o : persistObjects) {
business.entityManagerContainer().persist(o);
}
business.entityManagerContainer().commit();
ApplicationCache.notify(Script.class);
ApplicationCache.notify(Page.class);
ApplicationCache.notify(Widget.class);
ApplicationCache.notify(Portal.class);
}
private <T extends JpaObject> String idleNameWithPortal(Business business, String portalId, String name,
Class<T> cls, String excludeId) throws Exception {
if (StringUtils.isEmpty(name)) {
return "";
}
List<String> list = new ArrayList<>();
list.add(name);
for (int i = 1; i < 99; i++) {
list.add(name + String.format("%02d", i));
}
list.add(StringTools.uniqueToken());
EntityManager em = business.entityManagerContainer().get(cls);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<T> root = cq.from(cls);
Predicate p = root.get("name").in(list);
p = cb.and(p, cb.equal(root.get("portal"), portalId));
if (StringUtils.isNotEmpty(excludeId)) {
p = cb.and(p, cb.notEqual(root.get(JpaObject.id_FIELDNAME), excludeId));
}
cq.select(root.get("name")).where(p);
List<String> os = em.createQuery(cq).getResultList();
list = ListUtils.subtract(list, os);
return list.get(0);
}
private <T extends JpaObject> String idleAliasWithPortal(Business business, String portalId, String alias,
Class<T> cls, String excludeId) throws Exception {
if (StringUtils.isEmpty(alias)) {
return "";
}
List<String> list = new ArrayList<>();
list.add(alias);
for (int i = 1; i < 99; i++) {
list.add(alias + String.format("%02d", i));
}
list.add(StringTools.uniqueToken());
EntityManager em = business.entityManagerContainer().get(cls);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<T> root = cq.from(cls);
Predicate p = root.get("alias").in(list);
p = cb.and(p, cb.equal(root.get("portal"), portalId));
if (StringUtils.isNotEmpty(excludeId)) {
p = cb.and(p, cb.notEqual(root.get(JpaObject.id_FIELDNAME), excludeId));
}
cq.select(root.get("alias")).where(p);
List<String> os = em.createQuery(cq).getResultList();
list = ListUtils.subtract(list, os);
return list.get(0);
}
public static class Wi extends WrapPortal {
private static final long serialVersionUID = -4612391443319365035L;
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.input;
import java.util.ArrayList;
import java.util.List;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import com.x.portal.core.entity.Widget;
import com.x.portal.core.entity.wrap.WrapFile;
import com.x.portal.core.entity.wrap.WrapPage;
import com.x.portal.core.entity.wrap.WrapPortal;
import com.x.portal.core.entity.wrap.WrapScript;
import com.x.portal.core.entity.wrap.WrapWidget;
class ActionCreate extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionCreate.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
logger.debug(effectivePerson, "jsonElement:{}.", jsonElement);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
if (!business.editable(effectivePerson, null)) {
throw new ExceptionPortalAccessDenied(effectivePerson.getName(), wi.getName(), wi.getId());
}
Portal portal = this.create(business, wi);
wo.setId(portal.getId());
result.setData(wo);
return result;
}
}
private Portal create(Business business, Wi wi) throws Exception {
List<JpaObject> persistObjects = new ArrayList<>();
Portal portal = business.entityManagerContainer().find(wi.getId(), Portal.class);
if (null != portal) {
throw new ExceptionPortalExistForCreate(wi.getId());
}
portal = WrapPortal.inCopier.copy(wi);
portal.setName(this.idlePortalName(business, portal.getName(), portal.getId()));
portal.setAlias(this.idlePortalAlias(business, portal.getAlias(), portal.getId()));
persistObjects.add(portal);
for (WrapWidget _o : wi.getWidgetList()) {
Widget obj = business.entityManagerContainer().find(_o.getId(), Widget.class);
if (null != obj) {
throw new ExceptionMenuExistForCreate(_o.getId());
}
obj = WrapWidget.inCopier.copy(_o);
obj.setPortal(portal.getId());
persistObjects.add(obj);
}
for (WrapPage _o : wi.getPageList()) {
Page obj = business.entityManagerContainer().find(_o.getId(), Page.class);
if (null != obj) {
throw new ExceptionPageExistForCreate(_o.getId());
}
obj = WrapPage.inCopier.copy(_o);
obj.setPortal(portal.getId());
persistObjects.add(obj);
}
for (WrapScript _o : wi.getScriptList()) {
Script obj = business.entityManagerContainer().find(_o.getId(), Script.class);
if (null != obj) {
throw new ExceptionScriptExistForCreate(_o.getId());
}
obj = WrapScript.inCopier.copy(_o);
obj.setPortal(portal.getId());
persistObjects.add(obj);
}
for (WrapFile _o : wi.getFileList()) {
File obj = business.entityManagerContainer().find(_o.getId(),File.class);
if (null != obj) {
throw new ExceptionFileExistForCreate(_o.getId());
}
obj = WrapFile.inCopier.copy(_o);
obj.setPortal(portal.getId());
persistObjects.add(obj);
}
business.entityManagerContainer().beginTransaction(Portal.class);
business.entityManagerContainer().beginTransaction(Widget.class);
business.entityManagerContainer().beginTransaction(Page.class);
business.entityManagerContainer().beginTransaction(Script.class);
business.entityManagerContainer().beginTransaction(File.class);
for (JpaObject o : persistObjects) {
business.entityManagerContainer().persist(o);
}
business.entityManagerContainer().commit();
return portal;
}
public static class Wi extends WrapPortal {
private static final long serialVersionUID = -4612391443319365035L;
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.input;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapPair;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import com.x.portal.core.entity.Widget;
import com.x.portal.core.entity.wrap.WrapFile;
import com.x.portal.core.entity.wrap.WrapPage;
import com.x.portal.core.entity.wrap.WrapPortal;
import com.x.portal.core.entity.wrap.WrapScript;
import com.x.portal.core.entity.wrap.WrapWidget;
class ActionPrepareCover extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionPrepareCover.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
// logger.debug(effectivePerson, "jsonElement:{}.", jsonElement);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
List<Wo> wos = this.adjustForCover(business, wi);
result.setData(wos);
return result;
}
}
private List<Wo> adjustForCover(Business business, Wi wi) throws Exception {
List<Wo> wos = new ArrayList<>();
Portal exist = this.getPortal(business, wi.getId(), wi.getName(), wi.getAlias());
if (null == exist) {
throw new ExceptionPortalNotExistForCover(wi.getId(), wi.getName(), wi.getAlias());
}
if (!StringUtils.equals(wi.getId(), exist.getId())) {
wos.add(new Wo(wi.getId(), exist.getId()));
}
for (MatchElement<WrapWidget, Widget> m : this.match(business, wi.getWidgetList(),
ListUtils.union(this.listWithIds(business, wi.getWidgetList(), Widget.class),
business.widget().listObjectWithPortal(exist.getId())))) {
if ((null != m.getW()) && (null != m.getT())) {
if (!StringUtils.equals(m.getW().getId(), m.getT().getId())) {
if (StringUtils.equals(m.getW().getPortal(), m.getT().getPortal())) {
wos.add(new Wo(m.getW().getId(), m.getT().getId()));
} else {
wos.add(new Wo(m.getW().getId(), JpaObject.createId()));
}
}
}
}
for (MatchElement<WrapPage, Page> m : this.match(business, wi.getPageList(),
ListUtils.union(this.listWithIds(business, wi.getPageList(), Page.class),
business.page().listObjectWithPortal(exist.getId())))) {
if ((null != m.getW()) && (null != m.getT())) {
if (!StringUtils.equals(m.getW().getId(), m.getT().getId())) {
if (StringUtils.equals(m.getW().getPortal(), m.getT().getPortal())) {
wos.add(new Wo(m.getW().getId(), m.getT().getId()));
} else {
wos.add(new Wo(m.getW().getId(), JpaObject.createId()));
}
}
}
}
for (MatchElement<WrapScript, Script> m : this.match(business, wi.getScriptList(),
ListUtils.union(this.listWithIds(business, wi.getScriptList(), Script.class),
business.script().listObjectWithPortal(exist.getId())))) {
if ((null != m.getW()) && (null != m.getT())) {
if (!StringUtils.equals(m.getW().getId(), m.getT().getId())) {
if (StringUtils.equals(m.getW().getPortal(), m.getT().getPortal())) {
wos.add(new Wo(m.getW().getId(), m.getT().getId()));
} else {
wos.add(new Wo(m.getW().getId(), JpaObject.createId()));
}
}
}
}
for (MatchElement<WrapFile, File> m : this.match(business, wi.getFileList(),
ListUtils.union(this.listWithIds(business, wi.getFileList(), File.class),
business.file().listWithPortalObject(exist.getId())))) {
if ((null != m.getW()) && (null != m.getT())) {
if (!StringUtils.equals(m.getW().getId(), m.getT().getId())) {
if (StringUtils.equals(m.getW().getPortal(), m.getT().getPortal())) {
wos.add(new Wo(m.getW().getId(), m.getT().getId()));
} else {
wos.add(new Wo(m.getW().getId(), JpaObject.createId()));
}
}
}
}
return wos;
}
private <W extends JpaObject, T extends JpaObject> List<T> listWithIds(Business business, List<W> list,
Class<T> cls) throws Exception {
EntityManager em = business.entityManagerContainer().get(cls);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<T> cq = cb.createQuery(cls);
Root<T> root = cq.from(cls);
Predicate p = root.get(JpaObject.id_FIELDNAME)
.in(ListTools.extractField(list, JpaObject.id_FIELDNAME, String.class, true, true));
cq.select(root).where(p);
List<T> os = em.createQuery(cq).getResultList();
return os;
}
private <W extends JpaObject, T extends JpaObject> List<MatchElement<W, T>> match(Business business, List<W> ws,
List<T> ts) throws Exception {
List<MatchElement<W, T>> list = new ArrayList<>();
List<W> findWs = new ArrayList<>();
List<T> findTs = new ArrayList<>();
loop: for (W w : ListTools.nullToEmpty(ws)) {
if (!findWs.contains(w)) {
for (T t : ListTools.nullToEmpty(ts)) {
if (!findTs.contains(t)) {
if (StringUtils.equals(w.getId(), t.getId())) {
MatchElement<W, T> m = new MatchElement<>();
m.setW(w);
m.setT(t);
list.add(m);
findWs.add(w);
findTs.add(t);
continue loop;
}
}
}
}
}
loop: for (W w : ListTools.nullToEmpty(ws)) {
if (!findWs.contains(w)) {
for (T t : ListTools.nullToEmpty(ts)) {
if (!findTs.contains(t)) {
if (StringUtils.isNotEmpty(BeanUtils.getProperty(w, "name")) && StringUtils
.equals(BeanUtils.getProperty(w, "name"), BeanUtils.getProperty(t, "name"))) {
MatchElement<W, T> m = new MatchElement<>();
m.setW(w);
m.setT(t);
list.add(m);
findWs.add(w);
findTs.add(t);
continue loop;
}
}
}
}
}
loop: for (W w : ListTools.nullToEmpty(ws)) {
if (!findWs.contains(w)) {
for (T t : ListTools.nullToEmpty(ts)) {
if (!findTs.contains(t)) {
if (StringUtils.isNotEmpty(BeanUtils.getProperty(w, "alias")) && StringUtils
.equals(BeanUtils.getProperty(w, "alias"), BeanUtils.getProperty(t, "alias"))) {
MatchElement<W, T> m = new MatchElement<>();
m.setW(w);
m.setT(t);
list.add(m);
findWs.add(w);
findTs.add(t);
continue loop;
}
}
}
}
}
for (W w : ListTools.nullToEmpty(ws)) {
if (!findWs.contains(w)) {
MatchElement<W, T> m = new MatchElement<>();
m.setW(w);
m.setT(null);
list.add(m);
}
}
for (T t : ListTools.nullToEmpty(ts)) {
if (!findTs.contains(t)) {
MatchElement<W, T> m = new MatchElement<>();
m.setW(null);
m.setT(t);
list.add(m);
}
}
return list;
}
public static class MatchElement<W, T> {
private W w;
private T t;
public W getW() {
return w;
}
public void setW(W w) {
this.w = w;
}
public T getT() {
return t;
}
public void setT(T t) {
this.t = t;
}
}
public static class Wi extends WrapPortal {
private static final long serialVersionUID = -4612391443319365035L;
}
public static class Wo extends WrapPair {
public Wo(String value, String replaceValue) {
this.setFirst(value);
this.setSecond(replaceValue);
}
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.input;
import java.util.ArrayList;
import java.util.List;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapPair;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import com.x.portal.core.entity.Widget;
import com.x.portal.core.entity.wrap.WrapFile;
import com.x.portal.core.entity.wrap.WrapPage;
import com.x.portal.core.entity.wrap.WrapPortal;
import com.x.portal.core.entity.wrap.WrapScript;
import com.x.portal.core.entity.wrap.WrapWidget;
class ActionPrepareCreate extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionPrepareCreate.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
// logger.debug(effectivePerson, "jsonElement:{}.", jsonElement);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
List<Wo> wos = this.adjustForCreate(business, wi);
result.setData(wos);
return result;
}
}
private List<Wo> adjustForCreate(Business business, Wi wi) throws Exception {
List<Wo> wos = new ArrayList<>();
Portal exist_portal = business.entityManagerContainer().find(wi.getId(), Portal.class);
if (null != exist_portal) {
wos.add(new Wo(wi.getId(), JpaObject.createId()));
}
for (WrapWidget wrap : wi.getWidgetList()) {
Widget exist_widget = business.entityManagerContainer().find(wrap.getId(), Widget.class);
if (null != exist_widget) {
wos.add(new Wo(wrap.getId(), JpaObject.createId()));
}
}
for (WrapPage wrap : wi.getPageList()) {
Page exist_page = business.entityManagerContainer().find(wrap.getId(), Page.class);
if (null != exist_page) {
wos.add(new Wo(wrap.getId(), JpaObject.createId()));
}
}
for (WrapScript wrap : wi.getScriptList()) {
Script exist_script = business.entityManagerContainer().find(wrap.getId(), Script.class);
if (null != exist_script) {
wos.add(new Wo(wrap.getId(), JpaObject.createId()));
}
}
for (WrapFile wrap : wi.getFileList()) {
File exist_file = business.entityManagerContainer().find(wrap.getId(), File.class);
if (null != exist_file) {
wos.add(new Wo(wrap.getId(), JpaObject.createId()));
}
}
return wos;
}
public static class Wi extends WrapPortal {
private static final long serialVersionUID = -4612391443319365035L;
}
public static class Wo extends WrapPair {
public Wo(String value, String replaceValue) {
this.setFirst(value);
this.setSecond(replaceValue);
}
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.input;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.tools.StringTools;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Portal_;
import net.sf.ehcache.Ehcache;
abstract class BaseAction extends StandardJaxrsAction {
protected Ehcache inputCache = ApplicationCache.instance().getCache(BaseAction.class.getName(), 100,
ApplicationCache.MINUTES_20, ApplicationCache.MINUTES_20);
public enum Method {
cover, create, ignore;
}
protected Portal getPortal(Business business, String id, String name, String alias) throws Exception {
Portal o = business.entityManagerContainer().find(id, Portal.class);
if (null == o) {
o = this.getPortalWithName(business, name);
}
if (null == o) {
o = this.getPortalWithAlias(business, alias);
}
return o;
}
private Portal getPortalWithAlias(Business business, String alias) throws Exception {
if (StringUtils.isEmpty(alias)) {
return null;
}
EntityManager em = business.entityManagerContainer().get(Portal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Portal> cq = cb.createQuery(Portal.class);
Root<Portal> root = cq.from(Portal.class);
Predicate p = cb.equal(root.get(Portal_.alias), alias);
List<Portal> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList();
if (os.size() == 1) {
return os.get(0);
} else {
return null;
}
}
private Portal getPortalWithName(Business business, String name) throws Exception {
if (StringUtils.isEmpty(name)) {
return null;
}
EntityManager em = business.entityManagerContainer().get(Portal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Portal> cq = cb.createQuery(Portal.class);
Root<Portal> root = cq.from(Portal.class);
Predicate p = cb.equal(root.get(Portal_.name), name);
List<Portal> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList();
if (os.size() == 1) {
return os.get(0);
} else {
return null;
}
}
public static abstract class CompareWoPortal extends GsonPropertyObject {
@FieldDescribe("标记")
private String flag;
@FieldDescribe("导入名称")
private String name;
@FieldDescribe("导入id")
private String id;
@FieldDescribe("导入别名")
private String alias;
@FieldDescribe("是否已经存在")
private Boolean exist;
@FieldDescribe("已经存在名称")
private String existName;
@FieldDescribe("已经存在id")
private String existId;
@FieldDescribe("已经存在别名")
private String existAlias;
public String getFlag() {
return flag;
}
public void setFlag(String flag) {
this.flag = flag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public String getExistName() {
return existName;
}
public void setExistName(String existName) {
this.existName = existName;
}
public String getExistId() {
return existId;
}
public void setExistId(String existId) {
this.existId = existId;
}
public String getExistAlias() {
return existAlias;
}
public void setExistAlias(String existAlias) {
this.existAlias = existAlias;
}
public Boolean getExist() {
return exist;
}
public void setExist(Boolean exist) {
this.exist = exist;
}
}
protected <T extends JpaObject> String idlePortalName(Business business, String name, String excludeId)
throws Exception {
if (StringUtils.isEmpty(name)) {
return "";
}
List<String> list = new ArrayList<>();
list.add(name);
for (int i = 1; i < 99; i++) {
list.add(name + String.format("%02d", i));
}
list.add(StringTools.uniqueToken());
EntityManager em = business.entityManagerContainer().get(Portal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Portal> root = cq.from(Portal.class);
Predicate p = root.get(Portal_.name).in(list);
if (StringUtils.isNotEmpty(excludeId)) {
p = cb.and(p, cb.notEqual(root.get(JpaObject.id_FIELDNAME), excludeId));
}
cq.select(root.get(Portal_.name)).where(p);
List<String> os = em.createQuery(cq).getResultList();
list = ListUtils.subtract(list, os);
return list.get(0);
}
protected <T extends JpaObject> String idlePortalAlias(Business business, String alias, String excludeId)
throws Exception {
if (StringUtils.isEmpty(alias)) {
return "";
}
List<String> list = new ArrayList<>();
list.add(alias);
for (int i = 1; i < 99; i++) {
list.add(alias + String.format("%02d", i));
}
list.add(StringTools.uniqueToken());
EntityManager em = business.entityManagerContainer().get(Portal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Portal> root = cq.from(Portal.class);
Predicate p = root.get(Portal_.alias).in(list);
if (StringUtils.isNotEmpty(excludeId)) {
p = cb.and(p, cb.notEqual(root.get(JpaObject.id_FIELDNAME), excludeId));
}
cq.select(root.get(Portal_.alias)).where(p);
List<String> os = em.createQuery(cq).getResultList();
list = ListUtils.subtract(list, os);
return list.get(0);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.input;
import com.x.base.core.project.exception.PromptException;
class ExceptionFileExistForCreate extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionFileExistForCreate(String id) {
super("创建文件冲突, id:{}.");
}
}
package com.x.portal.assemble.designer.jaxrs.input;
import com.x.base.core.project.exception.PromptException;
class ExceptionMenuExistForCreate extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionMenuExistForCreate(String id) {
super("创建菜单冲突, id:{}.", id);
}
}
package com.x.portal.assemble.designer.jaxrs.input;
import com.x.base.core.project.exception.PromptException;
class ExceptionPageExistForCreate extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionPageExistForCreate(String id) {
super("创建页面冲突, id:{}.");
}
}
package com.x.portal.assemble.designer.jaxrs.input;
import com.x.base.core.project.exception.PromptException;
class ExceptionPortalAccessDenied extends PromptException {
private static final long serialVersionUID = -5515077418025884395L;
ExceptionPortalAccessDenied(String person, String name, String id) {
super("用户:{} 访问站点 name: {} id: {}, 被拒绝.", person, name, id);
}
}
package com.x.portal.assemble.designer.jaxrs.input;
import com.x.base.core.project.exception.PromptException;
class ExceptionPortalExistForCreate extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionPortalExistForCreate(String id) {
super("创建站点冲突, id:{}.");
}
}
package com.x.portal.assemble.designer.jaxrs.input;
import com.x.base.core.project.exception.PromptException;
class ExceptionPortalNotExist extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionPortalNotExist(String flag) {
super("站点:{}不存在.", flag);
}
ExceptionPortalNotExist(String id, String name, String alias) {
super("站点id:{},name:{},alias:{}不存在.", id, name, alias);
}
}
package com.x.portal.assemble.designer.jaxrs.input;
import com.x.base.core.project.exception.PromptException;
class ExceptionPortalNotExistForCover extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionPortalNotExistForCover(String id, String name, String alias) {
super("无法查找到用于覆盖的门户, id:{}, name:{}, alias:{}.", id, name, alias);
}
}
package com.x.portal.assemble.designer.jaxrs.input;
import com.x.base.core.project.exception.PromptException;
class ExceptionScriptExistForCreate extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionScriptExistForCreate(String id) {
super("创建脚本冲突, id:{}.");
}
}
package com.x.portal.assemble.designer.jaxrs.input;
import com.x.base.core.project.exception.PromptException;
class ExceptionSourceExistForCreate extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionSourceExistForCreate(String id) {
super("创建资源冲突, id:{}.");
}
}
package com.x.portal.assemble.designer.jaxrs.input;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("input")
@JaxrsDescribe("导入")
public class InputAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(InputAction.class);
@JaxrsMethodDescribe(value = "上传对比数据内容.", action = ActionCompare.class)
@PUT
@Path("compare")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void compare(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<ActionCompare.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionCompare().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "准备覆盖应用.", action = ActionPrepareCover.class)
@PUT
@Path("prepare/cover")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void prepareCover(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<List<ActionPrepareCover.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionPrepareCover().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "覆盖应用.", action = ActionCover.class)
@PUT
@Path("cover")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void cover(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<ActionCover.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionCover().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "准备创建应用.", action = ActionPrepareCreate.class)
@PUT
@Path("prepare/create")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void prepareCreate(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<List<ActionPrepareCreate.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionPrepareCreate().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "创建应用.", action = ActionCreate.class)
@PUT
@Path("create")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void create(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<ActionCreate.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionCreate().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.output;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import com.x.portal.core.entity.Widget;
import com.x.portal.core.entity.wrap.WrapFile;
import com.x.portal.core.entity.wrap.WrapPage;
import com.x.portal.core.entity.wrap.WrapPortal;
import com.x.portal.core.entity.wrap.WrapScript;
import com.x.portal.core.entity.wrap.WrapWidget;
class ActionList extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
List<Wo> wos = emc.fetchAll(Portal.class, Wo.copier);
List<WrapPage> pageList = emc.fetchAll(Page.class, pageCopier);
List<WrapScript> scriptList = emc.fetchAll(Script.class, scriptCopier);
List<WrapFile> fileList = emc.fetchAll(File.class, fileCopier);
List<WrapWidget> widgetList = emc.fetchAll(Widget.class, widgetCopier);
ListTools.groupStick(wos, pageList, "id", "portal", "pageList");
ListTools.groupStick(wos, scriptList, "id", "portal", "scriptList");
ListTools.groupStick(wos, fileList, "id", "portal", "fileList");
ListTools.groupStick(wos, widgetList, "id", "portal", "widgetList");
wos = wos.stream()
.sorted(Comparator.comparing(Wo::getAlias, Comparator.nullsLast(String::compareTo))
.thenComparing(Wo::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList());
result.setData(wos);
return result;
}
}
public static WrapCopier<Page, WrapPage> pageCopier = WrapCopierFactory.wo(Page.class, WrapPage.class,
JpaObject.singularAttributeField(Page.class, true, true), null);
public static WrapCopier<Script, WrapScript> scriptCopier = WrapCopierFactory.wo(Script.class, WrapScript.class,
JpaObject.singularAttributeField(Script.class, true, true), null);
public static WrapCopier<File, WrapFile> fileCopier = WrapCopierFactory.wo(File.class, WrapFile.class,
JpaObject.singularAttributeField(File.class, true, true), null);
public static WrapCopier<Widget, WrapWidget> widgetCopier = WrapCopierFactory.wo(Widget.class, WrapWidget.class,
JpaObject.singularAttributeField(Widget.class, true, true), null);
public static class Wo extends WrapPortal {
private static final long serialVersionUID = 474265667658465123L;
public static WrapCopier<Portal, Wo> copier = WrapCopierFactory.wo(Portal.class, Wo.class,
JpaObject.singularAttributeField(Portal.class, true, true), null);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.output;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.StringTools;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import com.x.portal.core.entity.Widget;
import com.x.portal.core.entity.wrap.WrapFile;
import com.x.portal.core.entity.wrap.WrapPage;
import com.x.portal.core.entity.wrap.WrapPortal;
import com.x.portal.core.entity.wrap.WrapScript;
import com.x.portal.core.entity.wrap.WrapWidget;
import net.sf.ehcache.Element;
class ActionSelect extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String portalFlag, JsonElement jsonElement)
throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
Portal portal = emc.flag(portalFlag, Portal.class);
if (null == portal) {
throw new ExceptionPortalNotExist(portalFlag);
}
if (!business.editable(effectivePerson, portal)) {
throw new ExceptionPortalAccessDenied(effectivePerson.getDistinguishedName(), portal.getName(),
portal.getId());
}
WrapPortal wrapPortal = this.get(business, portal, wi);
CacheObject cacheObject = new CacheObject();
cacheObject.setName(portal.getName());
cacheObject.setPortal(wrapPortal);
String flag = StringTools.uniqueToken();
this.cache.put(new Element(flag, cacheObject));
Wo wo = XGsonBuilder.convert(wrapPortal, Wo.class);
wo.setFlag(flag);
result.setData(wo);
return result;
}
}
private WrapPortal get(Business business, Portal portal, Wi wi) throws Exception {
WrapPortal wo = WrapPortal.outCopier.copy(portal);
wo.setWidgetList(
WrapWidget.outCopier.copy(business.entityManagerContainer().list(Widget.class, wi.listWidgetId())));
wo.setPageList(WrapPage.outCopier.copy(business.entityManagerContainer().list(Page.class, wi.listPageId())));
wo.setScriptList(
WrapScript.outCopier.copy(business.entityManagerContainer().list(Script.class, wi.listScriptId())));
wo.setFileList(WrapFile.outCopier.copy(business.entityManagerContainer().list(File.class, wi.listFileId())));
return wo;
}
public static class Wi extends WrapPortal {
private static final long serialVersionUID = 4926992449874268707L;
}
public static class Wo extends WrapPortal {
private static final long serialVersionUID = -1130848016754973977L;
@FieldDescribe("返回标识")
private String flag;
public String getFlag() {
return flag;
}
public void setFlag(String flag) {
this.flag = flag;
}
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.output;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoFile;
import com.x.base.core.project.tools.DefaultCharset;
import net.sf.ehcache.Element;
class ActionSelectFile extends BaseAction {
private static String extension = ".xapp";
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Element element = cache.get(flag);
if (null == element || null == element.getObjectValue()) {
throw new ExceptionFlagNotExist(flag);
}
CacheObject cacheObject = (CacheObject) element.getObjectValue();
Wo wo = new Wo(gson.toJson(cacheObject.getPortal()).getBytes(DefaultCharset.name),
this.contentType(true, cacheObject.getName() + extension),
this.contentDisposition(true, cacheObject.getName() + extension));
result.setData(wo);
return result;
}
}
public static class Wo extends WoFile {
public Wo(byte[] bytes, String contentType, String contentDisposition) {
super(bytes, contentType, contentDisposition);
}
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.output;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.wrap.WrapPortal;
import net.sf.ehcache.Ehcache;
abstract class BaseAction extends StandardJaxrsAction {
protected Ehcache cache = ApplicationCache.instance().getCache(CacheObject.class);
protected <T extends JpaObject> List<String> listWithPortal(Business business, Portal portal, Class<T> cls)
throws Exception {
EntityManager em = business.entityManagerContainer().get(cls);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<T> root = cq.from(cls);
Predicate p = cb.equal(root.get("portal"), portal.getId());
cq.select(root.get(JpaObject.id_FIELDNAME)).where(p);
return em.createQuery(cq).getResultList();
}
public static class CacheObject {
private String name;
private WrapPortal portal;
public WrapPortal getPortal() {
return portal;
}
public void setPortal(WrapPortal portal) {
this.portal = portal;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
package com.x.portal.assemble.designer.jaxrs.output;
import com.x.base.core.project.exception.PromptException;
class ExceptionFlagNotExist extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionFlagNotExist(String flag) {
super("下载标识: {} 不存在.", flag);
}
}
package com.x.portal.assemble.designer.jaxrs.output;
import com.x.base.core.project.exception.PromptException;
class ExceptionMenuNotExist extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionMenuNotExist(String flag) {
super("菜单: {} 不存在.", flag);
}
}
package com.x.portal.assemble.designer.jaxrs.output;
import com.x.base.core.project.exception.PromptException;
class ExceptionPageNotExist extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionPageNotExist(String flag) {
super("页面: {} 不存在.", flag);
}
}
package com.x.portal.assemble.designer.jaxrs.output;
import com.x.base.core.project.exception.PromptException;
class ExceptionPortalAccessDenied extends PromptException {
private static final long serialVersionUID = -5515077418025884395L;
ExceptionPortalAccessDenied(String person, String name, String id) {
super("用户:{} 访问站点 name: {} id: {}, 被拒绝.", person, name, id);
}
}
package com.x.portal.assemble.designer.jaxrs.output;
import com.x.base.core.project.exception.PromptException;
class ExceptionPortalNotExist extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionPortalNotExist(String flag) {
super("站点:{}不存在.", flag);
}
}
package com.x.portal.assemble.designer.jaxrs.output;
import com.x.base.core.project.exception.PromptException;
class ExceptionScriptNotExist extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionScriptNotExist(String flag) {
super("资源: {} 不存在.", flag);
}
}
package com.x.portal.assemble.designer.jaxrs.output;
import com.x.base.core.project.exception.PromptException;
class ExceptionSourceNotExist extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionSourceNotExist(String flag) {
super("页面: {} 不存在.", flag);
}
}
package com.x.portal.assemble.designer.jaxrs.output;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("output")
@JaxrsDescribe("导出")
public class OutputAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(OutputAction.class);
@JaxrsMethodDescribe(value = "选择门户结构.", action = ActionSelect.class)
@PUT
@Path("{portalFlag}/select")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void select(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("应用标识") @PathParam("portalFlag") String portalFlag, JsonElement jsonElement) {
ActionResult<ActionSelect.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionSelect().execute(effectivePerson, portalFlag, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "以文件方式导出应用.", action = ActionSelectFile.class)
@GET
@Path("{flag}/select/file")
@Consumes(MediaType.APPLICATION_JSON)
public void selectOutput(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("输出文件标识") @PathParam("flag") String flag) {
ActionResult<ActionSelectFile.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionSelectFile().execute(effectivePerson, flag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "查看所有应用.", action = ActionList.class)
@GET
@Path("list")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void list(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<List<ActionList.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionList().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.page;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
class ActionCreate extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Portal portal = emc.find(wi.getPortal(), Portal.class);
if (!business.editable(effectivePerson, portal)) {
throw new InsufficientPermissionException(effectivePerson.getDistinguishedName());
}
emc.beginTransaction(Page.class);
Page page = Wi.copier.copy(wi);
this.checkName(business, page);
this.checkAlias(business, page);
emc.persist(page, CheckPersistType.all);
/** 更新首页 */
if (this.isBecomeFirstPage(business, portal, page)) {
emc.beginTransaction(Portal.class);
portal.setFirstPage(page.getId());
} else if (StringUtils.isEmpty(portal.getFirstPage())
|| (null == emc.find(portal.getFirstPage(), Page.class))) {
/* 如果是第一个页面,设置这个页面为当前页面 */
emc.beginTransaction(Portal.class);
portal.setFirstPage(page.getId());
}
emc.commit();
ApplicationCache.notify(Page.class);
ApplicationCache.notify(Portal.class);
Wo wo = new Wo();
wo.setId(page.getId());
result.setData(wo);
return result;
}
}
public static class Wi extends Page {
private static final long serialVersionUID = 6624639107781167248L;
static WrapCopier<Wi, Page> copier = WrapCopierFactory.wi(Wi.class, Page.class, null,
JpaObject.FieldsUnmodifyExcludeId);
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.page;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
class ActionDelete extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Page page = emc.find(id, Page.class);
if (null == page) {
throw new PageNotExistedException(id);
}
Portal portal = emc.find(page.getPortal(), Portal.class);
if (null == portal) {
throw new PortalNotExistedException(page.getPortal());
}
if (!business.editable(effectivePerson, portal)) {
throw new InsufficientPermissionException(effectivePerson.getDistinguishedName());
}
emc.beginTransaction(Page.class);
emc.remove(page, CheckRemoveType.all);
/** 删除需要更新首页 */
if (StringUtils.equals(page.getId(), portal.getFirstPage())) {
emc.beginTransaction(Portal.class);
portal.setFirstPage("");
for (Page o : emc.list(Page.class, business.page().listWithPortal(portal.getId()))) {
portal.setFirstPage(o.getId());
if (business.page().isFirstPage(o)) {
break;
}
}
}
emc.commit();
ApplicationCache.notify(Page.class);
ApplicationCache.notify(Portal.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
}
public static class Wo extends WrapBoolean {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.page;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
class ActionEdit extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Page page = emc.find(id, Page.class);
if (null == page) {
throw new PageNotExistedException(id);
}
Portal portal = emc.find(page.getPortal(), Portal.class);
if (null == portal) {
throw new PortalNotExistedException(page.getPortal());
}
if (!business.editable(effectivePerson, portal)) {
throw new InsufficientPermissionException(effectivePerson.getDistinguishedName());
}
emc.beginTransaction(Page.class);
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Wi.copier.copy(wi, page);
this.checkName(business, page);
this.checkAlias(business, page);
emc.check(page, CheckPersistType.all);
/** 更新首页 */
if (this.isBecomeFirstPage(business, portal, page)) {
emc.beginTransaction(Portal.class);
portal.setFirstPage(page.getId());
} else if (StringUtils.isEmpty(portal.getFirstPage())
|| (null == emc.find(portal.getFirstPage(), Page.class))) {
/* 如果是第一个页面,设置这个页面为当前页面 */
emc.beginTransaction(Portal.class);
portal.setFirstPage(page.getId());
}
emc.commit();
ApplicationCache.notify(Page.class);
ApplicationCache.notify(Portal.class);
Wo wo = new Wo();
wo.setId(page.getId());
result.setData(wo);
return result;
}
}
public static class Wi extends Page {
private static final long serialVersionUID = 6624639107781167248L;
static WrapCopier<Wi, Page> copier = WrapCopierFactory.wi(Wi.class, Page.class, null, JpaObject.FieldsUnmodify);
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.page;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Element;
class ActionGet extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = cache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
} else {
Page page = emc.find(id, Page.class);
if (null == page) {
throw new PageNotExistedException(id);
}
wo = Wo.copier.copy(page);
cache.put(new Element(cacheKey, wo));
}
Portal portal = emc.find(wo.getPortal(), Portal.class);
if (null == portal) {
throw new PortalNotExistedException(id);
}
if (!business.editable(effectivePerson, portal)) {
throw new PortalInvisibleException(effectivePerson.getDistinguishedName(), portal.getName(),
portal.getId());
}
result.setData(wo);
return result;
}
}
public static class Wo extends Page {
private static final long serialVersionUID = 6147694053942736622L;
static WrapCopier<Page, Wo> copier = WrapCopierFactory.wo(Page.class, Wo.class, null,
JpaObject.FieldsInvisible);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.page;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
class ActionListWithPortal extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
Portal portal = emc.find(id, Portal.class);
if (null == portal) {
throw new PortalNotExistedException(id);
}
if (!business.editable(effectivePerson, portal)) {
throw new PortalInvisibleException(effectivePerson.getDistinguishedName(), portal.getName(),
portal.getId());
}
List<String> ids = business.page().listWithPortal(portal.getId());
List<Wo> wos = Wo.copier.copy(emc.list(Page.class, ids));
wos = wos.stream().sorted(Comparator.comparing(Wo::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList());
result.setData(wos);
return result;
}
}
public static class Wo extends Page {
private static final long serialVersionUID = -7592184343034018992L;
static WrapCopier<Page, Wo> copier = WrapCopierFactory.wo(Page.class, Wo.class,
JpaObject.singularAttributeField(Page.class, true, true), null);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.page;
import com.x.base.core.project.exception.PromptException;
class AliasDuplicateException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
AliasDuplicateException(String alias) {
super("别名重复: {} .", alias);
}
}
package com.x.portal.assemble.designer.jaxrs.page;
import com.x.base.core.project.exception.PromptException;
class AliasDuplicateWithNameException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
AliasDuplicateWithNameException(String name) {
super("别名与名称重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.page;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Ehcache;
abstract class BaseAction extends StandardJaxrsAction {
static Ehcache cache = ApplicationCache.instance().getCache(Page.class);
void checkName(Business business, Page page) throws Exception {
if (StringUtils.isEmpty(page.getName())) {
throw new NameEmptyException();
}
String id = business.page().getWithNameWithPortal(page.getName(), page.getPortal());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(page.getId(), id))) {
throw new NameDuplicateException(page.getName());
}
id = business.page().getWithAliasWithPortal(page.getName(), page.getPortal());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(page.getId(), id))) {
throw new NameDuplicateWithAliasException(page.getName());
}
}
void checkAlias(Business business, Page page) throws Exception {
if (StringUtils.isEmpty(page.getAlias())) {
return;
}
String id = business.page().getWithAliasWithPortal(page.getAlias(), page.getPortal());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(page.getId(), id))) {
throw new AliasDuplicateException(page.getAlias());
}
id = business.page().getWithNameWithPortal(page.getAlias(), page.getPortal());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(page.getId(), id))) {
throw new AliasDuplicateWithNameException(page.getAlias());
}
}
boolean isBecomeFirstPage(Business business, Portal portal, Page page) throws Exception {
if (business.page().isFirstPage(page)) {
Page o = business.entityManagerContainer().find(portal.getFirstPage(), Page.class);
if (null == o) {
return true;
}
}
return false;
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.page;
import com.x.base.core.project.exception.PromptException;
class InsufficientPermissionException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
InsufficientPermissionException(String person) {
super("person: {} has insufficient permission.", person);
}
}
package com.x.portal.assemble.designer.jaxrs.page;
import com.x.base.core.project.exception.PromptException;
class NameDuplicateException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
NameDuplicateException(String name) {
super("名称重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.page;
import com.x.base.core.project.exception.PromptException;
class NameDuplicateWithAliasException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
NameDuplicateWithAliasException(String name) {
super("页面名称与别名重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.page;
import com.x.base.core.project.exception.PromptException;
class NameEmptyException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
NameEmptyException() {
super("名称不能为空");
}
}
package com.x.portal.assemble.designer.jaxrs.page;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("page")
@JaxrsDescribe("页面")
public class PageAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(PageAction.class);
@JaxrsMethodDescribe(value = "获取Page.", action = ActionGet.class)
@GET
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionGet.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionGet().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "创建新的Page.", action = ActionCreate.class)
@POST
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void create(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<ActionCreate.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionCreate().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "更新指定的Page.", action = ActionEdit.class)
@PUT
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void edit(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id, JsonElement jsonElement) {
ActionResult<ActionEdit.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionEdit().execute(effectivePerson, id, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "删除指定的Page", action = ActionDelete.class)
@DELETE
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDelete().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示指定Portal下的Page.", action = ActionListWithPortal.class)
@GET
@Path("list/portal/{portalId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listWithPortal(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("Portal标识") @PathParam("portalId") String portalId) {
ActionResult<List<ActionListWithPortal.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListWithPortal().execute(effectivePerson, portalId);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.page;
import com.x.base.core.project.exception.PromptException;
class PageNotExistedException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
PageNotExistedException(String id) {
super("page: {} not existed.", id);
}
}
package com.x.portal.assemble.designer.jaxrs.page;
import com.x.base.core.project.exception.PromptException;
class PortalInvisibleException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
PortalInvisibleException(String person, String name, String id) {
super("person: {} can not visible portal name: {} id: {}.", person, name, id);
}
}
package com.x.portal.assemble.designer.jaxrs.page;
import com.x.base.core.project.exception.PromptException;
class PortalNotExistedException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
PortalNotExistedException(String id) {
super("portal: {} not existed.", id);
}
}
package com.x.portal.assemble.designer.jaxrs.portal;
import java.util.Date;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
class ActionCreate extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
if (!business.isPortalManager(effectivePerson)) {
throw new InsufficientPermissionException(effectivePerson.getDistinguishedName());
}
emc.beginTransaction(Portal.class);
Portal portal = Wi.copier.copy(wi);
portal.setCreatorPerson(effectivePerson.getDistinguishedName());
portal.setLastUpdatePerson(effectivePerson.getDistinguishedName());
portal.setLastUpdateTime(new Date());
this.checkName(business, portal);
this.checkAlias(business, portal);
emc.persist(portal, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Portal.class);
Wo wo = new Wo();
wo.setId(portal.getId());
result.setData(wo);
return result;
}
}
public static class Wi extends Portal {
private static final long serialVersionUID = 6624639107781167248L;
static WrapCopier<Wi, Portal> copier = WrapCopierFactory.wi(Wi.class, Portal.class, null,
JpaObject.FieldsUnmodifyExcludeId);
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.portal;
import java.util.List;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import com.x.portal.core.entity.Widget;
class ActionDelete extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Portal portal = emc.find(id, Portal.class);
if (null == portal) {
throw new PortalNotExistedException(id);
}
if (!business.editable(effectivePerson, portal)) {
throw new PortalInsufficientPermissionException(effectivePerson.getDistinguishedName(),
portal.getName(), portal.getId());
}
emc.beginTransaction(Portal.class);
emc.beginTransaction(Widget.class);
emc.beginTransaction(Page.class);
emc.beginTransaction(Script.class);
emc.beginTransaction(File.class);
this.removeWidget(business, portal.getId());
this.removePage(business, portal.getId());
this.removeScript(business, portal.getId());
this.removeFile(business, portal.getId());
emc.remove(portal, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(Portal.class);
ApplicationCache.notify(Widget.class);
ApplicationCache.notify(Page.class);
ApplicationCache.notify(Script.class);
ApplicationCache.notify(File.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
}
private void removeWidget(Business business, String portalId) throws Exception {
List<String> ids = business.widget().listWithPortal(portalId);
for (Widget o : business.entityManagerContainer().list(Widget.class, ids)) {
business.entityManagerContainer().remove(o, CheckRemoveType.all);
}
}
private void removePage(Business business, String portalId) throws Exception {
List<String> ids = business.page().listWithPortal(portalId);
for (Page o : business.entityManagerContainer().list(Page.class, ids)) {
business.entityManagerContainer().remove(o, CheckRemoveType.all);
}
}
private void removeScript(Business business, String portalId) throws Exception {
List<String> ids = business.script().listWithPortal(portalId);
for (Script o : business.entityManagerContainer().list(Script.class, ids)) {
business.entityManagerContainer().remove(o, CheckRemoveType.all);
}
}
private void removeFile(Business business, String portalId) throws Exception {
for (File o : business.entityManagerContainer().listEqual(File.class, File.portal_FIELDNAME, portalId)) {
business.entityManagerContainer().remove(o, CheckRemoveType.all);
}
}
public static class Wo extends WrapBoolean {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.portal;
import java.util.Date;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import com.x.portal.core.entity.Widget;
class ActionEdit extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Portal o = emc.find(id, Portal.class);
if (null == o) {
throw new PortalNotExistedException(id);
}
if (!business.editable(effectivePerson, o)) {
throw new PortalInsufficientPermissionException(effectivePerson.getDistinguishedName(), o.getName(),
o.getId());
}
emc.beginTransaction(Portal.class);
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Wi.copier.copy(wi, o);
o.setLastUpdatePerson(effectivePerson.getDistinguishedName());
o.setLastUpdateTime(new Date());
this.checkName(business, o);
this.checkAlias(business, o);
emc.check(o, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Portal.class);
ApplicationCache.notify(Widget.class);
ApplicationCache.notify(Page.class);
ApplicationCache.notify(Script.class);
Wo wo = new Wo();
wo.setId(o.getId());
result.setData(wo);
return result;
}
}
public static class Wi extends Portal {
private static final long serialVersionUID = 8552082924745177797L;
static WrapCopier<Wi, Portal> copier = WrapCopierFactory.wi(Wi.class, Portal.class, null,
JpaObject.FieldsUnmodify);
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.portal;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Element;
class ActionGet extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = cache.get(cacheKey);
if (null != element && null != element.getObjectValue()) {
wo = (Wo) element.getObjectValue();
} else {
Portal o = emc.find(id, Portal.class);
if (null == o) {
throw new PortalNotExistedException(id);
}
if (!business.editable(effectivePerson, o)) {
throw new InvisibleException(effectivePerson.getDistinguishedName(), o.getName(), o.getId());
}
wo = Wo.copier.copy(o);
cache.put(new Element(cacheKey, wo));
}
result.setData(wo);
return result;
}
}
public static class Wo extends Portal {
private static final long serialVersionUID = 6993675643268828658L;
static WrapCopier<Portal, Wo> copier = WrapCopierFactory.wo(Portal.class, Wo.class, null,
JpaObject.FieldsInvisible);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.portal;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
class ActionList extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
List<String> ids = this.listEditable(business, effectivePerson);
List<Wo> wos = Wo.copier.copy(emc.list(Portal.class, ids));
wos = wos.stream().sorted(Comparator.comparing(Wo::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList());
result.setData(wos);
return result;
}
}
public static class Wo extends Portal {
private static final long serialVersionUID = -1369499996236744766L;
static WrapCopier<Portal, Wo> copier = WrapCopierFactory.wo(Portal.class, Wo.class,
JpaObject.singularAttributeField(Portal.class, true, false), null);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.portal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
class ActionListSummary extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
List<String> ids = this.listEditable(business, effectivePerson);
List<Wo> wos = Wo.copier.copy(emc.list(Portal.class, ids));
/* 由于有多值字段所以需要全部取出 */
for (Wo wo : wos) {
List<String> os = business.page().listWithPortal(wo.getId());
// wo.setPageList(WoPage.copier.copy(emc.list(Page.class, os)));
wo.setPageList(emc.fetch(os, WoPage.copier));
}
wos = wos.stream().sorted(Comparator.comparing(Wo::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList());
result.setData(wos);
return result;
}
}
public static class Wo extends Portal {
private static final long serialVersionUID = -4436126455534548272L;
static WrapCopier<Portal, Wo> copier = WrapCopierFactory.wo(Portal.class, Wo.class,
JpaObject.singularAttributeField(Portal.class, true, false), null);
@FieldDescribe("页面")
private List<WoPage> pageList = new ArrayList<>();
public List<WoPage> getPageList() {
return pageList;
}
public void setPageList(List<WoPage> pageList) {
this.pageList = pageList;
}
}
public static class WoPage extends Page {
private static final long serialVersionUID = -9051259904153066895L;
static WrapCopier<Page, WoPage> copier = WrapCopierFactory.wo(Page.class, WoPage.class,
JpaObject.singularAttributeField(Page.class, true, true), null);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.portal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Portal_;
class ActionListSummaryWithPortalCategory extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String portalCategory) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
List<String> ids = this.listEditableWithPortalCategory(business, effectivePerson, portalCategory);
/* 由于有多值字段所以需要全部取出 */
List<Wo> wos = Wo.copier.copy(emc.list(Portal.class, ids));
for (Wo wo : wos) {
List<String> os = business.page().listWithPortal(wo.getId());
wo.setPageList(emc.fetch(os, WoPage.copier));
}
wos = wos.stream().sorted(Comparator.comparing(Wo::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList());
result.setData(wos);
return result;
}
}
List<String> listEditableWithPortalCategory(Business business, EffectivePerson effectivePerson,
String portalCategory) throws Exception {
EntityManager em = business.entityManagerContainer().get(Portal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Portal> root = cq.from(Portal.class);
Predicate p = cb.conjunction();
if (!business.isPortalManager(effectivePerson)) {
p = cb.isMember(effectivePerson.getDistinguishedName(), root.get(Portal_.controllerList));
p = cb.or(p, cb.equal(root.get(Portal_.creatorPerson), effectivePerson.getDistinguishedName()));
}
p = cb.and(p, cb.equal(root.get(Portal_.portalCategory), Objects.toString(portalCategory, "")));
cq.select(root.get(Portal_.id)).where(p).distinct(true);
List<String> list = em.createQuery(cq.select(root.get(Portal_.id)).where(p)).getResultList();
return list;
}
public static class Wo extends Portal {
private static final long serialVersionUID = 4546727999450453639L;
static WrapCopier<Portal, Wo> copier = WrapCopierFactory.wo(Portal.class, Wo.class,
JpaObject.singularAttributeField(Portal.class, true, true), null);
private List<WoPage> pageList = new ArrayList<>();
public List<WoPage> getPageList() {
return pageList;
}
public void setPageList(List<WoPage> pageList) {
this.pageList = pageList;
}
}
public static class WoPage extends Page {
private static final long serialVersionUID = -8790557719118069443L;
static WrapCopier<Page, WoPage> copier = WrapCopierFactory.wo(Page.class, WoPage.class,
JpaObject.singularAttributeField(Page.class, true, false), null);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.portal;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
class ActionListWithPortalCategory extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String portalCategory) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
List<String> ids = this.listEditableWithPortalCategory(business, effectivePerson, portalCategory);
List<Wo> wos = Wo.copier.copy(emc.list(Portal.class, ids));
wos = wos.stream().sorted(Comparator.comparing(Wo::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList());
result.setData(wos);
return result;
}
}
public static class Wo extends Portal {
private static final long serialVersionUID = 4546727999450453639L;
static WrapCopier<Portal, Wo> copier = WrapCopierFactory.wo(Portal.class, Wo.class,
JpaObject.singularAttributeField(Portal.class, true, false), null);
}
}
package com.x.portal.assemble.designer.jaxrs.portal;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import javax.imageio.ImageIO;
import org.apache.commons.codec.binary.Base64;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.imgscalr.Scalr;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
class ActionSetIcon extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String protalId, byte[] bytes,
FormDataContentDisposition disposition) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create();
InputStream input = new ByteArrayInputStream(bytes);
ByteArrayOutputStream output = new ByteArrayOutputStream()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
Portal portal = emc.find(protalId, Portal.class);
if (null == portal) {
throw new PortalNotExistedException(protalId);
}
if (!business.editable(effectivePerson, portal)) {
throw new PortalInsufficientPermissionException(effectivePerson.getDistinguishedName(),
portal.getName(), portal.getId());
}
BufferedImage image = ImageIO.read(input);
BufferedImage scalrImage = Scalr.resize(image, 72, 72);
ImageIO.write(scalrImage, "png", output);
String icon = Base64.encodeBase64String(output.toByteArray());
emc.beginTransaction(Portal.class);
portal.setIcon(icon);
emc.commit();
Wo wo = new Wo();
ApplicationCache.notify(Portal.class);
wo.setId(portal.getId());
result.setData(wo);
return result;
}
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.portal;
import com.x.base.core.project.exception.PromptException;
class AliasDuplicateException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
AliasDuplicateException(String alias) {
super("别名重复: {} .", alias);
}
}
package com.x.portal.assemble.designer.jaxrs.portal;
import com.x.base.core.project.exception.PromptException;
class AliasDuplicateWithNameException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
AliasDuplicateWithNameException(String name) {
super("别名与名称重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.portal;
import java.util.List;
import java.util.Objects;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Portal_;
import net.sf.ehcache.Ehcache;
abstract class BaseAction extends StandardJaxrsAction {
static Ehcache cache = ApplicationCache.instance().getCache(Portal.class);
void checkName(Business business, Portal portal) throws Exception {
if (StringUtils.isEmpty(portal.getName())) {
throw new NameEmptyException();
}
String id = business.portal().getWithName(portal.getName());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(portal.getId(), id))) {
throw new NameDuplicateException(portal.getName());
}
id = business.portal().getWithAlias(portal.getName());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(portal.getId(), id))) {
throw new NameDuplicateWithAliasException(portal.getName());
}
}
void checkAlias(Business business, Portal portal) throws Exception {
if (StringUtils.isEmpty(portal.getAlias())) {
return;
}
String id = business.portal().getWithAlias(portal.getAlias());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(portal.getId(), id))) {
throw new AliasDuplicateException(portal.getAlias());
}
id = business.portal().getWithName(portal.getAlias());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(portal.getId(), id))) {
throw new AliasDuplicateWithNameException(portal.getAlias());
}
}
List<String> listEditable(Business business, EffectivePerson effectivePerson) throws Exception {
EntityManager em = business.entityManagerContainer().get(Portal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Portal> root = cq.from(Portal.class);
Predicate p = cb.conjunction();
if (!business.isPortalManager(effectivePerson)) {
p = cb.isMember(effectivePerson.getDistinguishedName(), root.get(Portal_.controllerList));
p = cb.or(p, cb.equal(root.get(Portal_.creatorPerson), effectivePerson.getDistinguishedName()));
}
cq.select(root.get(Portal_.id)).where(p).distinct(true);
List<String> list = em.createQuery(cq.select(root.get(Portal_.id)).where(p)).getResultList();
return list;
}
List<String> listEditableWithPortalCategory(Business business, EffectivePerson effectivePerson,
String portalCategory) throws Exception {
EntityManager em = business.entityManagerContainer().get(Portal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Portal> root = cq.from(Portal.class);
Predicate p = cb.conjunction();
if (!business.isPortalManager(effectivePerson)) {
p = cb.isMember(effectivePerson.getDistinguishedName(), root.get(Portal_.controllerList));
p = cb.or(p, cb.equal(root.get(Portal_.creatorPerson), effectivePerson.getDistinguishedName()));
}
p = cb.and(p, cb.equal(root.get(Portal_.portalCategory), Objects.toString(portalCategory, "")));
cq.select(root.get(Portal_.id)).where(p).distinct(true);
List<String> list = em.createQuery(cq.select(root.get(Portal_.id)).where(p)).getResultList();
return list;
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.portal;
import com.x.base.core.project.exception.PromptException;
class InsufficientPermissionException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
InsufficientPermissionException(String person) {
super("用户: {} 没有足够的权限.", person);
}
}
package com.x.portal.assemble.designer.jaxrs.portal;
import com.x.base.core.project.exception.PromptException;
class InvisibleException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
InvisibleException(String person, String name, String id) {
super("用户: {} 不可见站点: {} id: {}.", person, name, id);
}
}
package com.x.portal.assemble.designer.jaxrs.portal;
import com.x.base.core.project.exception.PromptException;
class NameDuplicateException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
NameDuplicateException(String name) {
super("名称重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.portal;
import com.x.base.core.project.exception.PromptException;
class NameDuplicateWithAliasException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
NameDuplicateWithAliasException(String name) {
super("名称与别名重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.portal;
import com.x.base.core.project.exception.PromptException;
class NameEmptyException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
NameEmptyException() {
super("名称不能为空");
}
}
package com.x.portal.assemble.designer.jaxrs.portal;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("portal")
@JaxrsDescribe("门户操作")
public class PortalAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(PortalAction.class);
@JaxrsMethodDescribe(value = "获取单个Portal配置信息,检查是否有editable权限.", action = ActionGet.class)
@GET
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionGet.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionGet().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "创建新的Portal.需要对Portal模块的管理权限", action = ActionCreate.class)
@POST
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void create(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<ActionCreate.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionCreate().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "更新指定的Portal,需要对此portal的管理权限", action = ActionEdit.class)
@PUT
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void edit(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id, JsonElement jsonElement) {
ActionResult<ActionEdit.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionEdit().execute(effectivePerson, id, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "删除指定的Portal,需要指定权限.", action = ActionDelete.class)
@DELETE
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDelete().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示当前用户可以管理的Portal.", action = ActionList.class)
@GET
@Path("list")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void list(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<List<ActionList.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionList().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示当前用户在指定分类下可以管理的Portal.", action = ActionListWithPortalCategory.class)
@GET
@Path("list/portalcategory/{portalCategory}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listWithPortalCategory(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("门户分类") @PathParam("portalCategory") String portalCategory) {
ActionResult<List<ActionListWithPortalCategory.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListWithPortalCategory().execute(effectivePerson, portalCategory);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示当前用户可以管理的Portal的简要信息包含page.", action = ActionListSummary.class)
@GET
@Path("list/summary")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listSummary(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<List<ActionListSummary.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListSummary().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示当前用户在指定分类下可以管理的Portal的简要信息包含page.", action = ActionListSummaryWithPortalCategory.class)
@GET
@Path("list/summary/portalcategory/{portalCategory}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listSummaryWithPortalCategory(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("门户分类") @PathParam("portalCategory") String portalCategory) {
ActionResult<List<ActionListSummaryWithPortalCategory.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListSummaryWithPortalCategory().execute(effectivePerson, portalCategory);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "更新Portal图标.", action = ActionSetIcon.class)
@PUT
@Path("{id}/icon")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
public void setIcon(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id, @FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("图标文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionSetIcon.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionSetIcon().execute(effectivePerson, id, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.portal;
import com.x.base.core.project.exception.PromptException;
class PortalInsufficientPermissionException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
PortalInsufficientPermissionException(String person, String name, String id) {
super("用户: {} 没有足够的权限操作站点: {}, id:{}.", person, name, id);
}
}
package com.x.portal.assemble.designer.jaxrs.portal;
import com.x.base.core.project.exception.PromptException;
class PortalNotExistedException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
PortalNotExistedException(String id) {
super("portal: {} not existed.", id);
}
}
package com.x.portal.assemble.designer.jaxrs.portalcategory;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Portal_;
class ActionList extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wos = new ArrayList<>();
Business business = new Business(emc);
List<String> list = new ArrayList<>(this.listPortalCategory(business, effectivePerson));
Map<String, Long> counted = list.stream()
.collect(Collectors.groupingBy(o -> Objects.toString(o), Collectors.counting()));
LinkedHashMap<String, Long> sorted = counted.entrySet().stream()
.sorted(Map.Entry.<String, Long>comparingByKey()).collect(Collectors.toMap(Map.Entry::getKey,
Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
for (Entry<String, Long> en : sorted.entrySet()) {
Wo wo = new Wo();
wo.setProtalCategory(en.getKey());
wo.setCount(en.getValue());
wos.add(wo);
}
result.setData(wos);
return result;
}
}
private List<String> listPortalCategory(Business business, EffectivePerson effectivePerson) throws Exception {
EntityManager em = business.entityManagerContainer().get(Portal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Portal> root = cq.from(Portal.class);
return em.createQuery(cq.select(root.get(Portal_.portalCategory))).getResultList();
}
public class Wo extends GsonPropertyObject {
@FieldDescribe("门户分类")
private String protalCategory;
@FieldDescribe("数量")
private Long count;
public Long getCount() {
return count;
}
public void setCount(Long count) {
this.count = count;
}
public String getProtalCategory() {
return protalCategory;
}
public void setProtalCategory(String protalCategory) {
this.protalCategory = protalCategory;
}
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.portalcategory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
abstract class BaseAction extends StandardJaxrsAction {
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.portalcategory;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("portalcategory")
@JaxrsDescribe("门户分类")
public class PortalCategoryAction extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(PortalCategoryAction.class);
@JaxrsMethodDescribe(value = "查看用户可管理的portalcategory.", action = ActionList.class)
@GET
@Path("list")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listWith(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<List<ActionList.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionList().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.script;
import java.util.Date;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
class ActionCreate extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Portal portal = emc.find(wi.getPortal(), Portal.class);
if (!business.editable(effectivePerson, portal)) {
throw new InsufficientPermissionException(effectivePerson.getDistinguishedName());
}
emc.beginTransaction(Script.class);
Script script = Wi.copier.copy(wi);
script.setCreatorPerson(effectivePerson.getDistinguishedName());
script.setLastUpdatePerson(effectivePerson.getDistinguishedName());
script.setLastUpdateTime(new Date());
this.checkName(business, script);
this.checkAlias(business, script);
this.checkDepend(business, script);
emc.persist(script, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Script.class);
Wo wo = new Wo();
wo.setId(script.getId());
result.setData(wo);
return result;
}
}
public static class Wo extends WoId {
}
public static class Wi extends Script {
private static final long serialVersionUID = 6624639107781167248L;
static WrapCopier<Wi, Script> copier = WrapCopierFactory.wi(Wi.class, Script.class, null,
JpaObject.FieldsUnmodifyExcludeId);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.script;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import com.x.portal.core.entity.Script_;
class ActionDelete extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Script script = emc.find(id, Script.class);
if (null == script) {
throw new ScriptNotExistedException(id);
}
Portal portal = emc.find(script.getPortal(), Portal.class);
if (null == portal) {
throw new PortalNotExistedException(script.getPortal());
}
if (!business.editable(effectivePerson, portal)) {
throw new InsufficientPermissionException(effectivePerson.getDistinguishedName());
}
emc.beginTransaction(Script.class);
this.checkDepended(business, script);
emc.remove(script, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(Script.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
}
private void checkDepended(Business business, Script script) throws Exception {
EntityManager em = business.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.isMember(script.getId(), root.get(Script_.dependScriptList));
p = cb.and(p, cb.equal(root.get(Script_.portal), script.getPortal()));
List<Script> list = em.createQuery(cq.select(root).where(p)).getResultList();
if (!list.isEmpty()) {
List<String> names = ListTools.extractProperty(list, "name", String.class, true, false);
throw new DependedException(script.getName(), script.getId(), StringUtils.join(names, ","));
}
}
public static class Wo extends WrapBoolean {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.script;
import java.util.Date;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
class ActionEdit extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Script script = emc.find(id, Script.class);
if (null == script) {
throw new ScriptNotExistedException(id);
}
Portal portal = emc.find(script.getPortal(), Portal.class);
if (null == portal) {
throw new PortalNotExistedException(script.getPortal());
}
if (!business.editable(effectivePerson, portal)) {
throw new InsufficientPermissionException(effectivePerson.getDistinguishedName());
}
emc.beginTransaction(Script.class);
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Wi.copier.copy(wi, script);
script.setLastUpdatePerson(effectivePerson.getDistinguishedName());
script.setLastUpdateTime(new Date());
this.checkName(business, script);
this.checkAlias(business, script);
this.checkDepend(business, script);
emc.check(script, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Script.class);
Wo wo = new Wo();
wo.setId(script.getId());
result.setData(wo);
return result;
}
}
public static class Wi extends Script {
private static final long serialVersionUID = 6624639107781167248L;
static WrapCopier<Wi, Script> copier = WrapCopierFactory.wi(Wi.class, Script.class, null,
JpaObject.FieldsUnmodify);
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.script;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import net.sf.ehcache.Element;
class ActionGet extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = cache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
} else {
Script script = emc.find(id, Script.class);
if (null == script) {
throw new ScriptNotExistedException(id);
}
wo = Wo.copier.copy(script);
cache.put(new Element(cacheKey, wo));
}
Portal portal = emc.find(wo.getPortal(), Portal.class);
if (null == portal) {
throw new PortalNotExistedException(id);
}
if (!business.editable(effectivePerson, portal)) {
throw new PortalInvisibleException(effectivePerson.getDistinguishedName(), portal.getName(),
portal.getId());
}
result.setData(wo);
return result;
}
}
public static class Wo extends Script {
private static final long serialVersionUID = -7592184343034018992L;
static WrapCopier<Script, Wo> copier = WrapCopierFactory.wo(Script.class, Wo.class, null,
JpaObject.FieldsInvisible);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.script;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
class ActionListWithPortal extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
Portal portal = emc.find(id, Portal.class);
if (null == portal) {
throw new PortalNotExistedException(id);
}
if (!business.editable(effectivePerson, portal)) {
throw new PortalInvisibleException(effectivePerson.getDistinguishedName(), portal.getName(),
portal.getId());
}
List<String> ids = business.script().listWithPortal(portal.getId());
List<Wo> wos = Wo.copier.copy(emc.list(Script.class, ids));
wos = wos.stream().sorted(Comparator.comparing(Wo::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList());
result.setData(wos);
return result;
}
}
public static class Wo extends Script {
private static final long serialVersionUID = -7592184343034018992L;
static WrapCopier<Script, Wo> copier = WrapCopierFactory.wo(Script.class, Wo.class,
JpaObject.singularAttributeField(Script.class, true, true), null);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.script;
import com.x.base.core.project.exception.PromptException;
class AliasDuplicateException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
AliasDuplicateException(String alias) {
super("别名重复: {} .", alias);
}
}
package com.x.portal.assemble.designer.jaxrs.script;
import com.x.base.core.project.exception.PromptException;
class AliasDuplicateWithNameException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
AliasDuplicateWithNameException(String name) {
super("别名与名称重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.script;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Script;
import net.sf.ehcache.Ehcache;
abstract class BaseAction extends StandardJaxrsAction {
static Ehcache cache = ApplicationCache.instance().getCache(Script.class);
void checkName(Business business, Script script) throws Exception {
if (StringUtils.isEmpty(script.getName())) {
throw new NameEmptyException();
}
String id = business.script().getWithNameWithPortal(script.getName(), script.getPortal());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(script.getId(), id))) {
throw new NameDuplicateException(script.getName());
}
id = business.script().getWithAliasWithPortal(script.getName(), script.getPortal());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(script.getId(), id))) {
throw new NameDuplicateWithAliasException(script.getName());
}
}
void checkAlias(Business business, Script script) throws Exception {
if (StringUtils.isEmpty(script.getAlias())) {
return;
}
String id = business.script().getWithAliasWithPortal(script.getAlias(), script.getPortal());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(script.getId(), id))) {
throw new AliasDuplicateException(script.getAlias());
}
id = business.script().getWithNameWithPortal(script.getAlias(), script.getPortal());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(script.getId(), id))) {
throw new AliasDuplicateWithNameException(script.getAlias());
}
}
void checkDepend(Business business, Script script) throws Exception {
for (String str : ListTools.trim(script.getDependScriptList(), true, true)) {
if (StringUtils.isNotEmpty(str)) {
if (StringUtils.equals(str, script.getId()) || StringUtils.equals(str, script.getName())
|| StringUtils.equals(str, script.getAlias())) {
throw new DependSelfException(script.getName(), script.getId());
} else {
String id = business.script().getWithNameWithPortal(str, script.getPortal());
if (StringUtils.isEmpty(id)) {
id = business.script().getWithAliasWithPortal(str, script.getPortal());
}
if (StringUtils.isEmpty(id)) {
id = business.script().getWithIdWithPortal(str, script.getPortal());
}
if (StringUtils.isEmpty(id)) {
throw new DependNotExistedException(script.getName(), script.getId(), str);
}
}
}
}
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.script;
import com.x.base.core.project.exception.PromptException;
class DependNotExistedException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
DependNotExistedException(String name, String id, String depend) {
super("脚本: {}, id:{}, 依赖的脚本: {}, 不存在.", name, id, depend);
}
}
package com.x.portal.assemble.designer.jaxrs.script;
import com.x.base.core.project.exception.PromptException;
class DependSelfException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
DependSelfException(String name, String id) {
super("脚本: {}, id:{}, 依赖其本身.", name, id);
}
}
package com.x.portal.assemble.designer.jaxrs.script;
import com.x.base.core.project.exception.PromptException;
class DependedException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
DependedException(String name, String id, String names) {
super("脚本: {}, id:{}, 被其他脚本引用: {}.", name, id, names);
}
}
package com.x.portal.assemble.designer.jaxrs.script;
import com.x.base.core.project.exception.PromptException;
class InsufficientPermissionException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
InsufficientPermissionException(String person) {
super("person: {} has insufficient permission.", person);
}
}
package com.x.portal.assemble.designer.jaxrs.script;
import com.x.base.core.project.exception.PromptException;
class ScriptNotExistedException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ScriptNotExistedException(String id) {
super("script: {} not existed.", id);
}
}
package com.x.portal.assemble.designer.jaxrs.script;
import com.x.base.core.project.exception.PromptException;
class NameDuplicateException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
NameDuplicateException(String name) {
super("名称重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.script;
import com.x.base.core.project.exception.PromptException;
class NameDuplicateWithAliasException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
NameDuplicateWithAliasException(String name) {
super("名称与别名重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.script;
import com.x.base.core.project.exception.PromptException;
class NameEmptyException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
NameEmptyException() {
super("名称不能为空");
}
}
package com.x.portal.assemble.designer.jaxrs.script;
import com.x.base.core.project.exception.PromptException;
class PortalInvisibleException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
PortalInvisibleException(String person, String name, String id) {
super("person: {} can not visible portal name: {} id: {}.", person, name, id);
}
}
package com.x.portal.assemble.designer.jaxrs.script;
import com.x.base.core.project.exception.PromptException;
class PortalNotExistedException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
PortalNotExistedException(String id) {
super("portal: {} not existed.", id);
}
}
package com.x.portal.assemble.designer.jaxrs.script;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("script")
@JaxrsDescribe("脚本操作")
public class ScriptAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(ScriptAction.class);
@JaxrsMethodDescribe(value = "获取Script.", action = ActionGet.class)
@GET
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionGet.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionGet().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "创建新的Script.", action = ActionCreate.class)
@POST
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void create(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<ActionCreate.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionCreate().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "更新指定的Portal.", action = ActionEdit.class)
@PUT
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void edit(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id, JsonElement jsonElement) {
ActionResult<ActionEdit.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionEdit().execute(effectivePerson, id, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "删除指定的Portal", action = ActionDelete.class)
@DELETE
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDelete().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示指定Portal下的Script.", action = ActionListWithPortal.class)
@GET
@Path("list/portal/{portalId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listWithPortal(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("Portal标识") @PathParam("portalId") String portalId) {
ActionResult<List<ActionListWithPortal.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListWithPortal().execute(effectivePerson, portalId);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.templatepage;
import java.util.Date;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.TemplatePage;
class ActionCreate extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
if (!business.isPortalManager(effectivePerson)) {
throw new InsufficientPermissionException(effectivePerson.getDistinguishedName());
}
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
TemplatePage o = Wi.copier.copy(wi);
o.setCreatorPerson(effectivePerson.getDistinguishedName());
o.setLastUpdatePerson(effectivePerson.getDistinguishedName());
o.setLastUpdateTime(new Date());
this.checkName(business, o);
this.checkAlias(business, o);
emc.beginTransaction(TemplatePage.class);
emc.persist(o, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(TemplatePage.class);
Wo wo = new Wo();
wo.setId(o.getId());
result.setData(wo);
return result;
}
}
public static class Wi extends TemplatePage {
private static final long serialVersionUID = 6337516993246513262L;
static WrapCopier<Wi, TemplatePage> copier = WrapCopierFactory.wi(Wi.class, TemplatePage.class, null,
JpaObject.FieldsUnmodifyExcludeId);
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.templatepage;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.TemplatePage;
class ActionDelete extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
TemplatePage o = emc.find(id, TemplatePage.class);
if (null == o) {
throw new TemplatePageNotExistedException(id);
}
if (!business.templatePage().checkPermission(effectivePerson, o)) {
throw new InsufficientPermissionException(effectivePerson.getDistinguishedName());
}
emc.beginTransaction(TemplatePage.class);
emc.remove(o, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(TemplatePage.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
}
public static class Wo extends WrapBoolean {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.templatepage;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.TemplatePage;
class ActionGet extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
TemplatePage templatePage = emc.find(id, TemplatePage.class);
if (null == templatePage) {
throw new TemplatePageNotExistedException(id);
}
if (!business.templatePage().editable(effectivePerson, templatePage)) {
throw new TemplatePageInvisibleException(effectivePerson.getDistinguishedName(), templatePage.getName(),
templatePage.getId());
}
Wo wo = Wo.copier.copy(templatePage);
result.setData(wo);
return result;
}
}
public static class Wo extends TemplatePage {
private static final long serialVersionUID = -7592184343034018992L;
static WrapCopier<TemplatePage, Wo> copier = WrapCopierFactory.wo(TemplatePage.class, Wo.class, null,
JpaObject.FieldsInvisible);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.templatepage;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ObjectUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.TemplatePage;
class ActionList extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
List<String> ids = new ArrayList<>();
if (business.isPortalManager(effectivePerson)) {
ids = business.templatePage().list();
} else {
ids = business.templatePage().listEditable(effectivePerson);
}
List<WoTemplatePage> list = WoTemplatePage.copier.copy(emc.list(TemplatePage.class, ids));
Map<String, List<WoTemplatePage>> group = list.stream()
.collect(Collectors.groupingBy(o -> Objects.toString(o.getCategory(), "")));
Map<String, List<WoTemplatePage>> sort = group.entrySet().stream()
.sorted((e1, e2) -> ObjectUtils.compare(e1.getKey(), e2.getKey())).collect(Collectors
.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
Wo wo = new Wo();
for (Entry<String, List<WoTemplatePage>> en : sort.entrySet()) {
wo.put(en.getKey(),
en.getValue().stream().sorted(
Comparator.comparing(WoTemplatePage::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList()));
}
result.setData(wo);
return result;
}
}
public static class Wo extends LinkedHashMap<String, List<WoTemplatePage>> {
private static final long serialVersionUID = 6662363584476991536L;
}
public static class WoTemplatePage extends TemplatePage {
private static final long serialVersionUID = -7592184343034018992L;
static WrapCopier<TemplatePage, WoTemplatePage> copier = WrapCopierFactory.wo(TemplatePage.class,
WoTemplatePage.class, JpaObject.singularAttributeField(TemplatePage.class, true, true), null);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.templatepage;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.TemplatePage;
class ActionListCategory extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wos = new ArrayList<>();
Business business = new Business(emc);
List<String> ids = business.templatePage().listEditable(effectivePerson);
List<TemplatePage> os = emc.fetch(ids, TemplatePage.class,
ListTools.toList(TemplatePage.category_FIELDNAME));
List<String> categories = ListTools.extractProperty(os, TemplatePage.category_FIELDNAME, String.class,
false, false);
Map<String, Long> group = categories.stream().collect(Collectors.groupingBy(e -> e, Collectors.counting()));
LinkedHashMap<String, Long> sort = group.entrySet().stream()
.sorted(Map.Entry.<String, Long>comparingByKey()).collect(Collectors.toMap(Map.Entry::getKey,
Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
for (Entry<String, Long> en : sort.entrySet()) {
Wo wo = new Wo();
wo.setName(en.getKey());
wo.setCount(en.getValue());
wos.add(wo);
}
result.setData(wos);
return result;
}
}
public static class Wo extends GsonPropertyObject {
@FieldDescribe("类别")
private String name;
@FieldDescribe("数量")
private Long count;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getCount() {
return count;
}
public void setCount(Long count) {
this.count = count;
}
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.templatepage;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.TemplatePage;
class ActionListWithCategory extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
String category = XGsonBuilder.extractString(jsonElement, TemplatePage.category_FIELDNAME);
List<String> ids = business.templatePage().listEditableWithCategory(effectivePerson, category);
List<Wo> wos = Wo.copier.copy(emc.list(TemplatePage.class, ids));
wos = wos.stream().sorted(Comparator.comparing(Wo::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList());
result.setData(wos);
return result;
}
}
public static class Wo extends TemplatePage {
private static final long serialVersionUID = 4610930870555814195L;
static WrapCopier<TemplatePage, Wo> copier = WrapCopierFactory.wo(TemplatePage.class, Wo.class,
JpaObject.singularAttributeField(TemplatePage.class, true, true), null);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.templatepage;
import com.x.base.core.project.exception.PromptException;
class AliasDuplicateException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
AliasDuplicateException(String alias) {
super("别名重复: {} .", alias);
}
}
package com.x.portal.assemble.designer.jaxrs.templatepage;
import com.x.base.core.project.exception.PromptException;
class AliasDuplicateWithNameException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
AliasDuplicateWithNameException(String name) {
super("别名与名称重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.templatepage;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.TemplatePage;
abstract class BaseAction extends StandardJaxrsAction {
void checkName(Business business, TemplatePage o) throws Exception {
if (StringUtils.isEmpty(o.getName())) {
throw new NameEmptyException();
}
String id = business.templatePage().getWithName(o.getName());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(o.getId(), id))) {
throw new NameDuplicateException(o.getName());
}
id = business.templatePage().getWithAlias(o.getName());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(o.getId(), id))) {
throw new NameDuplicateWithAliasException(o.getName());
}
}
void checkAlias(Business business, TemplatePage o) throws Exception {
if (StringUtils.isEmpty(o.getAlias())) {
return;
}
String id = business.templatePage().getWithAlias(o.getAlias());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(o.getId(), id))) {
throw new AliasDuplicateException(o.getAlias());
}
id = business.templatePage().getWithName(o.getAlias());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(o.getId(), id))) {
throw new AliasDuplicateWithNameException(o.getAlias());
}
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.templatepage;
import com.x.base.core.project.exception.PromptException;
class InsufficientPermissionException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
InsufficientPermissionException(String person) {
super("person: {} has insufficient permission.", person);
}
}
package com.x.portal.assemble.designer.jaxrs.templatepage;
import com.x.base.core.project.exception.PromptException;
class NameDuplicateException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
NameDuplicateException(String name) {
super("名称重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.templatepage;
import com.x.base.core.project.exception.PromptException;
class NameDuplicateWithAliasException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
NameDuplicateWithAliasException(String name) {
super("名称与别名重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.templatepage;
import com.x.base.core.project.exception.PromptException;
class NameEmptyException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
NameEmptyException() {
super("名称不能为空");
}
}
package com.x.portal.assemble.designer.jaxrs.templatepage;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("templatepage")
@JaxrsDescribe("页面模版")
public class TemplatePageAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(TemplatePageAction.class);
@JaxrsMethodDescribe(value = "获取所有可见的模版,按category进行分类", action = ActionList.class)
@GET
@Path("list")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void list(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<ActionList.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionList().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "获取单个模版.", action = ActionGet.class)
@GET
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionGet.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionGet().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "创建新的模版.", action = ActionCreate.class)
@POST
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void create(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<ActionCreate.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionCreate().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "删除指定的模版.", action = ActionDelete.class)
@DELETE
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDelete().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "统计分类数量.", action = ActionListCategory.class)
@GET
@Path("list/category")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listCategory(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<List<ActionListCategory.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListCategory().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示指定分类下的模版.", action = ActionListWithCategory.class)
@PUT
@Path("list/category")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listWithCategory(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<List<ActionListWithCategory.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListWithCategory().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.templatepage;
import com.x.base.core.project.exception.PromptException;
class TemplatePageInvisibleException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
TemplatePageInvisibleException(String person, String name, String id) {
super("person: {} can not visible templatePage name: {} id: {}.", person, name, id);
}
}
package com.x.portal.assemble.designer.jaxrs.templatepage;
import com.x.base.core.project.exception.PromptException;
class TemplatePageNotExistedException extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
TemplatePageNotExistedException(String id) {
super("page: {} not existed.", id);
}
}
package com.x.portal.assemble.designer.jaxrs.widget;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Widget;
import com.x.portal.core.entity.Portal;
class ActionCreate extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Portal portal = emc.find(wi.getPortal(), Portal.class);
if (!business.editable(effectivePerson, portal)) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
emc.beginTransaction(Widget.class);
Widget widget = Wi.copier.copy(wi);
this.checkName(business, widget);
this.checkAlias(business, widget);
emc.persist(widget, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Widget.class);
ApplicationCache.notify(Portal.class);
Wo wo = new Wo();
wo.setId(widget.getId());
result.setData(wo);
return result;
}
}
public static class Wi extends Widget {
private static final long serialVersionUID = 6624639107781167248L;
static WrapCopier<Wi, Widget> copier = WrapCopierFactory.wi(Wi.class, Widget.class, null,
JpaObject.FieldsUnmodifyExcludeId);
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.widget;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Widget;
class ActionDelete extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Widget widget = emc.find(id, Widget.class);
if (null == widget) {
throw new ExceptionEntityNotExist(id, Widget.class);
}
Portal portal = emc.find(widget.getPortal(), Portal.class);
if (null == portal) {
throw new ExceptionEntityNotExist(widget.getPortal(), Portal.class);
}
if (!business.editable(effectivePerson, portal)) {
throw new ExceptionAccessDenied(effectivePerson);
}
emc.beginTransaction(Widget.class);
emc.remove(widget, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(Widget.class);
ApplicationCache.notify(Portal.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
}
public static class Wo extends WrapBoolean {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.widget;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Widget;
class ActionEdit extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Widget widget = emc.find(id, Widget.class);
if (null == widget) {
throw new ExceptionEntityNotExist(id, Widget.class);
}
Portal portal = emc.find(widget.getPortal(), Portal.class);
if (null == portal) {
throw new ExceptionEntityNotExist(widget.getPortal(), Portal.class);
}
if (!business.editable(effectivePerson, portal)) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
emc.beginTransaction(Widget.class);
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Wi.copier.copy(wi, widget);
this.checkName(business, widget);
this.checkAlias(business, widget);
emc.check(widget, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Widget.class);
ApplicationCache.notify(Portal.class);
Wo wo = new Wo();
wo.setId(widget.getId());
result.setData(wo);
return result;
}
}
public static class Wi extends Widget {
private static final long serialVersionUID = 6624639107781167248L;
static WrapCopier<Wi, Widget> copier = WrapCopierFactory.wi(Wi.class, Widget.class, null,
JpaObject.FieldsUnmodify);
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.widget;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Widget;
import net.sf.ehcache.Element;
class ActionGet extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = cache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
} else {
Widget widget = emc.find(id, Widget.class);
if (null == widget) {
throw new ExceptionEntityNotExist(id, Widget.class);
}
wo = Wo.copier.copy(widget);
cache.put(new Element(cacheKey, wo));
}
Portal portal = emc.find(wo.getPortal(), Portal.class);
if (null == portal) {
throw new ExceptionEntityNotExist(id, Portal.class);
}
if (!business.editable(effectivePerson, portal)) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
result.setData(wo);
return result;
}
}
public static class Wo extends Widget {
private static final long serialVersionUID = 6147694053942736622L;
static WrapCopier<Widget, Wo> copier = WrapCopierFactory.wo(Widget.class, Wo.class, null,
JpaObject.FieldsInvisible);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.widget;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Widget;
class ActionListWithPortal extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
Portal portal = emc.find(id, Portal.class);
if (null == portal) {
throw new ExceptionEntityNotExist(id, Portal.class);
}
if (!business.editable(effectivePerson, portal)) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
List<Widget> os = emc.listEqual(Widget.class, Widget.portal_FIELDNAME, portal.getId());
List<Wo> wos = Wo.copier.copy(os);
wos = wos.stream().sorted(Comparator.comparing(Wo::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList());
result.setData(wos);
return result;
}
}
public static class Wo extends Widget {
private static final long serialVersionUID = -7592184343034018992L;
static WrapCopier<Widget, Wo> copier = WrapCopierFactory.wo(Widget.class, Wo.class,
JpaObject.singularAttributeField(Widget.class, true, true), null);
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.widget;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Widget;
import net.sf.ehcache.Ehcache;
abstract class BaseAction extends StandardJaxrsAction {
static Ehcache cache = ApplicationCache.instance().getCache(Widget.class);
void checkName(Business business, Widget widget) throws Exception {
if (StringUtils.isEmpty(widget.getName())) {
throw new ExceptionNameEmpty();
}
String id = business.widget().getWithNameWithPortal(widget.getName(), widget.getPortal());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(widget.getId(), id))) {
throw new ExceptionNameDuplicate(widget.getName());
}
id = business.page().getWithAliasWithPortal(widget.getName(), widget.getPortal());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(widget.getId(), id))) {
throw new ExceptionNameDuplicateWithAlias(widget.getName());
}
}
void checkAlias(Business business, Widget widget) throws Exception {
if (StringUtils.isEmpty(widget.getAlias())) {
return;
}
String id = business.page().getWithAliasWithPortal(widget.getAlias(), widget.getPortal());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(widget.getId(), id))) {
throw new ExceptionAliasDuplicate(widget.getAlias());
}
id = business.page().getWithNameWithPortal(widget.getAlias(), widget.getPortal());
if (StringUtils.isNotEmpty(id) && (!StringUtils.equals(widget.getId(), id))) {
throw new ExceptionAliasDuplicateWithName(widget.getAlias());
}
}
}
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.widget;
import com.x.base.core.project.exception.PromptException;
class ExceptionAliasDuplicate extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionAliasDuplicate(String alias) {
super("别名重复: {} .", alias);
}
}
package com.x.portal.assemble.designer.jaxrs.widget;
import com.x.base.core.project.exception.PromptException;
class ExceptionAliasDuplicateWithName extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionAliasDuplicateWithName(String name) {
super("别名与名称重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.widget;
import com.x.base.core.project.exception.PromptException;
class ExceptionNameDuplicate extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionNameDuplicate(String name) {
super("名称重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.widget;
import com.x.base.core.project.exception.PromptException;
class ExceptionNameDuplicateWithAlias extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionNameDuplicateWithAlias(String name) {
super("页面名称与别名重复: {} .", name);
}
}
package com.x.portal.assemble.designer.jaxrs.widget;
import com.x.base.core.project.exception.PromptException;
class ExceptionNameEmpty extends PromptException {
private static final long serialVersionUID = -9089355008820123519L;
ExceptionNameEmpty() {
super("名称不能为空");
}
}
package com.x.portal.assemble.designer.jaxrs.widget;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("widget")
@JaxrsDescribe("部件")
public class WidgetAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(WidgetAction.class);
@JaxrsMethodDescribe(value = "获取部件.", action = ActionGet.class)
@GET
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionGet.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionGet().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "创建新的部件.", action = ActionCreate.class)
@POST
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void create(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<ActionCreate.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionCreate().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "更新指定的部件.", action = ActionEdit.class)
@PUT
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void edit(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id, JsonElement jsonElement) {
ActionResult<ActionEdit.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionEdit().execute(effectivePerson, id, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "删除指定的部件", action = ActionDelete.class)
@DELETE
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDelete().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示指定Portal下的部件.", action = ActionListWithPortal.class)
@GET
@Path("list/portal/{portalId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listWithPortal(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("Portal标识") @PathParam("portalId") String portalId) {
ActionResult<List<ActionListWithPortal.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListWithPortal().execute(effectivePerson, portalId);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册