提交 fb52adee 编写于 作者: 蔡祥熠

Merge branch 'wrdp' into 'fix/Process.form_tablet'

# Conflicts:
#   o2web/source/x_component_process_FormDesigner/lp/en.js
......@@ -109,7 +109,7 @@ O2OA自带的H2数据库是一个内嵌式的内存数据库,适合用于开
Linux环境:https://www.o2oa.net/course/yto8af.html
# 最新版本 v6.0.x\:
# 最新版本 v6.2.x\:
功能新增
......
......@@ -45,7 +45,7 @@ var supportedLanguage = ["zh-cn", "en"];
var downloadHost = "git.o2oa.net";
var protocol = "https";
var commonUrl = "/o2oa/evn-o2server-commons/-/archive/master/evn-o2server-commons-master.tar.gz?path=commons";
var commonUrl = "/o2oa/evn-o2server-commons/-/archive/6.4/evn-o2server-commons-6.4.tar.gz?path=commons";
var jvmUrls = {
"all": "/o2oa/evn-o2server-jvm/-/archive/master/evn-o2server-jvm-master.tar.gz?path=jvm",
"linux_java11": "/o2oa/evn-o2server-jvm/-/archive/master/evn-o2server-jvm-master.tar.gz?path=jvm/linux_java11",
......@@ -331,7 +331,7 @@ function move_commons(){
console.log(`---------------------------------------------------------------------
. move commons files to o2server/commons ...
---------------------------------------------------------------------`);
return gulp.src("o2server/evn-o2server-commons-master-commons/commons/**/*")
return gulp.src("o2server/evn-o2server-commons-6.4-commons/commons/**/*")
.pipe(gulp.dest("o2server/commons/"));
}
function move_jvm(){
......@@ -348,7 +348,7 @@ function move_jvm(){
.pipe(gulp.dest("o2server/jvm/"));
}
function clear_commons_git(cb){
var dest = ['o2server/evn-o2server-commons-master-commons/', 'o2server/commons_git.tar.gz'];
var dest = ['o2server/evn-o2server-commons-6.4-commons/', 'o2server/commons_git.tar.gz'];
del(dest, { force: true });
cb();
}
......
{
"enable": false,
"enable": true,
"appKey": "9aca7cc20fe0cc987cd913ca",
"masterSecret": "96ee7e2e0daffd51bac57815",
"huaweiPushEnable": false,
"huaweiPushConfig": {
"appId": "100016851",
"appSecret": "b3ad9287e8d1d16d0aad8fde66e59118",
"###appId": "华为推送应用的appId###",
"###appSecret": "华为推送应用的appSecret###"
},
"###enable": "是否启用.###",
"###appKey": "极光推送应用的AppKey###",
"###masterSecret": "极光推送应用的Master Secret###"
"###masterSecret": "极光推送应用的Master Secret###",
"###huaweiPushEnable": "是否开启华为推送###",
"###huaweiPushConfig": "华为推送的配置###"
}
\ No newline at end of file
{
"enable": false,
"systemManager": "systemManager",
"systemManagerDistinguishedName": "系统管理员@systemManager@P",
"systemManagerPassword": "",
"securityManager": "securityManager",
"securityManagerDistinguishedName": "安全管理员@securityManager@P",
"securityManagerPassword": "",
"auditManager": "auditManager",
"auditManagerDistinguishedName": "安全审计员@auditManager@P",
"auditManagerPassword": ""
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.3</version>
<version>6.4</version>
<packaging>pom</packaging>
<properties>
<maven.compiler.source>11</maven.compiler.source>
......@@ -371,8 +371,19 @@
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
......@@ -415,8 +426,6 @@
</compilerArgs>
</configuration>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
......@@ -484,13 +493,6 @@
</excludes>
</configuration>
</plugin>
<!-- plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId>
<version>3.13.0</version> <configuration> <linkXRef>true</linkXRef> <sourceEncoding>utf-8</sourceEncoding>
<minimumTokens>100</minimumTokens> <targetJdk>1.8</targetJdk> <failOnViolation>false</failOnViolation>
<outputDirectory>${basedir}</outputDirectory> </configuration> <executions>
<execution> <id>pmd-check</id> <phase>verify</phase> <goals> <goal>check</goal>
</goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId> <version>2.3</version> </plugin -->
</plugins>
</build>
<dependencyManagement>
......@@ -840,8 +842,6 @@
<artifactId>javapoet</artifactId>
<version>1.11.1</version>
</dependency>
<!--dependency> <groupId>javax.visrec</groupId> <artifactId>visrec-api</artifactId>
<version>20200316</version> </dependency -->
<dependency>
<groupId>com.github.neuroph</groupId>
<artifactId>neuroph-core</artifactId>
......@@ -862,18 +862,7 @@
<artifactId>neuroph-contrib</artifactId>
<version>2.98</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<!-- dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId>
<version>3.2.0</version> </dependency -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
......@@ -924,145 +913,155 @@
<artifactId>html2image</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.32</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_base_core_project</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_attendance_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_bbs_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_calendar_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_cms_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_cms_core_express</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_component_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_file_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_general_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_hotpic_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_meeting_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_message_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_mind_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_organization_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_jpush_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_organization_core_express</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_portal_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_processplatform_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_processplatform_core_express</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_query_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_query_core_express</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_report_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_strategydeploy_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_strategydeploy_assemble_control</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_program_center</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_program_center_core_entity</artifactId>
<version>6.3</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_teamwork_core_entity</artifactId>
<version>6.3</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_workschedu_core_entity</artifactId>
<version>6.3</version>
<version>6.4</version>
</dependency>
<dependency>
<groupId>net.lingala.zip4j</groupId>
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.3</version>
<version>6.4</version>
</parent>
<artifactId>x_attendance_assemble_control</artifactId>
<packaging>war</packaging>
......
......@@ -18,7 +18,7 @@ import com.x.base.core.project.logger.LoggerFactory;
public class ThisApplication {
private ThisApplication() {
//nothing
// nothing
}
protected static Context context;
......@@ -41,7 +41,6 @@ public class ThisApplication {
public static void init() throws Exception {
try {
CacheManager.init(context.clazz().getSimpleName());
LoggerFactory.setLevel(Config.logLevel().x_attendance_assemble_control());
new AttendanceSettingService().initAllSystemConfig();
context.startQueue(detailAnalyseQueue);
context.startQueue(detailStatisticQueue);
......@@ -59,7 +58,7 @@ public class ThisApplication {
context.schedule(QywxAttendanceSyncScheduleTask.class, "0 0 1 * * ?");
}
context.schedule(AttendanceStatisticTask.class, "0 0 0/4 * * ?");
//context.schedule(MobileRecordAnalyseTask.class, "0 0 * * * ?");
// context.schedule(MobileRecordAnalyseTask.class, "0 0 * * * ?");
// 每天凌晨1点,计算前一天所有的未签退和未分析的打卡数据
context.schedule(DetailLastDayRecordAnalyseTask.class, "0 0 1 * * ?");
......
......@@ -2,18 +2,19 @@ package com.x.attendance.assemble.control.factory;
import com.x.attendance.assemble.control.AbstractFactory;
import com.x.attendance.assemble.control.Business;
import com.x.attendance.assemble.control.CriteriaQueryTools;
import com.x.attendance.assemble.control.jaxrs.selfholiday.ActionListNextWithFilter;
import com.x.attendance.assemble.control.jaxrs.selfholiday.WrapInFilter;
import com.x.attendance.entity.AttendanceSelfHoliday;
import com.x.attendance.entity.AttendanceSelfHoliday_;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.base.core.project.tools.ListTools;
import org.apache.commons.lang3.StringUtils;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.criteria.*;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -89,6 +90,17 @@ public class AttendanceSelfHolidayFactory extends AbstractFactory {
cq.select(root.get(AttendanceSelfHoliday_.id));
return em.createQuery(cq.where(p)).getResultList();
}
//@MethodDescribe("根据流程的文档ID列示员工的AttendanceSelfHoliday信息列表")
// public List<String> getByWorkFlowDocId(String docId) throws Exception {
// EntityManager em = this.entityManagerContainer().get(AttendanceSelfHoliday.class);
// CriteriaBuilder cb = em.getCriteriaBuilder();
// CriteriaQuery<String> cq = cb.createQuery(String.class);
// Root<AttendanceSelfHoliday> root = cq.from( AttendanceSelfHoliday.class);
// Predicate p = cb.equal(root.get(AttendanceSelfHoliday_.docId), docId);
// cq.select(root.get(AttendanceSelfHoliday_.id));
// return em.createQuery(cq.where(p)).getResultList();
// }
public List<String> listByStartDateAndEndDate(Date startDate, Date endDate) throws Exception {
EntityManager em = this.entityManagerContainer().get(AttendanceSelfHoliday.class);
......@@ -100,7 +112,7 @@ public class AttendanceSelfHolidayFactory extends AbstractFactory {
cq.select(root.get(AttendanceSelfHoliday_.id));
return em.createQuery(cq.where(p)).getResultList();
}
/**
* 查询下一页的信息数据
* @param id
......@@ -114,46 +126,62 @@ public class AttendanceSelfHolidayFactory extends AbstractFactory {
public List<AttendanceSelfHoliday> listIdsNextWithFilter( String id, Integer count, Object sequence, ActionListNextWithFilter.WrapIn wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( AttendanceSelfHoliday.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<AttendanceSelfHoliday> cq = cb.createQuery(AttendanceSelfHoliday.class);
Root<AttendanceSelfHoliday> root = cq.from(AttendanceSelfHoliday.class);
String order = wrapIn.getOrder();//排序方式
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
if( order == null || order.isEmpty() ){
order = "DESC";
}
String orderFieldName = "";
if(StringUtils.isNotEmpty( wrapIn.getKey())){
orderFieldName = wrapIn.getKey();
}else{
orderFieldName = "sequence";
}
Order _order = CriteriaQueryTools.setOrder(cb, root, AttendanceSelfHoliday_.class, orderFieldName,order);
Predicate p = cb.isNotNull(root.get(AttendanceSelfHoliday_.employeeName));
Integer index = 1;
sql_stringBuffer.append( "SELECT o FROM "+AttendanceSelfHoliday.class.getCanonicalName()+" o where 1=1" );
if ((null != sequence) ) {
if(StringUtils.equalsIgnoreCase(order, "DESC")){
p = cb.and(p,cb.lessThan(root.get(AttendanceSelfHoliday_.sequence),sequence.toString()));
}else{
p = cb.and(p,cb.greaterThan(root.get(AttendanceSelfHoliday_.sequence),sequence.toString()));
}
sql_stringBuffer.append(" and o.sequence " + (StringUtils.equalsIgnoreCase(order, "DESC") ? "<" : ">") + (" ?" + (index)));
vs.add(sequence);
index++;
}
if(StringUtils.isNotEmpty(wrapIn.getQ_empName())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.employeeName),wrapIn.getQ_empName()));
if ((null != wrapIn.getQ_empName()) && (!wrapIn.getQ_empName().isEmpty())) {
sql_stringBuffer.append(" and o.employeeName = ?" + (index));
vs.add( wrapIn.getQ_empName() );
index++;
}
if(ListTools.isNotEmpty(wrapIn.getUnitNames())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.unitOu),wrapIn.getUnitNames().get(0)));
if (null != wrapIn.getUnitNames() && wrapIn.getUnitNames().size()>0) {
sql_stringBuffer.append(" and o.unitOu in ( ?" + (index) + ")");
vs.add( wrapIn.getUnitNames() );
index++;
}
if(ListTools.isNotEmpty(wrapIn.getTopUnitNames())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.topUnitOu),wrapIn.getTopUnitNames().get(0)));
if (null != wrapIn.getTopUnitNames() && wrapIn.getTopUnitNames().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitOu in ( ?" + (index) + ")");
vs.add( wrapIn.getTopUnitNames() );
index++;
}
if (null != wrapIn.getStartdate() && null != wrapIn.getEnddate()) {
p = cb.and(p,cb.greaterThanOrEqualTo(root.get(AttendanceSelfHoliday_.startTime),wrapIn.getStartdate()));
p = cb.and(p,cb.lessThanOrEqualTo(root.get(AttendanceSelfHoliday_.endTime),wrapIn.getEnddate()));
sql_stringBuffer.append(" and o.startTime >= ?" + (index) );
vs.add( wrapIn.getStartdate());
index++;
sql_stringBuffer.append(" and o.endTime <= ?" + (index));
vs.add( wrapIn.getEnddate());
index++;
}
if( StringUtils.isNotEmpty( wrapIn.getKey() )){
sql_stringBuffer.append(" order by o."+wrapIn.getKey()+" " + order );
}else{
sql_stringBuffer.append(" order by o.sequence " + order );
}
Query query = em.createQuery( sql_stringBuffer.toString(), AttendanceSelfHoliday.class );
//System.out.println("query=" +query.toString());
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
}
Query query = em.createQuery(cq.select(root).where(p).orderBy(_order) );
return query.setMaxResults(count).getResultList();
}
}
/**
* 查询上一页的文档信息数据
* @param id
......@@ -167,39 +195,49 @@ public class AttendanceSelfHolidayFactory extends AbstractFactory {
public List<AttendanceSelfHoliday> listIdsPrevWithFilter( String id, Integer count, Object sequence, WrapInFilter wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( AttendanceSelfHoliday.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<AttendanceSelfHoliday> cq = cb.createQuery(AttendanceSelfHoliday.class);
Root<AttendanceSelfHoliday> root = cq.from(AttendanceSelfHoliday.class);
String order = wrapIn.getOrder();//排序方式
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
Integer index = 1;
if( order == null || order.isEmpty() ){
order = "DESC";
}
String orderFieldName = "";
if(StringUtils.isNotEmpty( wrapIn.getKey())){
orderFieldName = wrapIn.getKey();
}else{
orderFieldName = "sequence";
}
Order _order = CriteriaQueryTools.setOrder(cb, root, AttendanceSelfHoliday_.class, orderFieldName,order);
Predicate p = cb.isNotNull(root.get(AttendanceSelfHoliday_.employeeName));
sql_stringBuffer.append( "SELECT o FROM "+AttendanceSelfHoliday.class.getCanonicalName()+" o where 1=1" );
if ((null != sequence) ) {
if(StringUtils.equalsIgnoreCase(order, "DESC")){
p = cb.and(p,cb.greaterThan(root.get(AttendanceSelfHoliday_.sequence),sequence.toString()));
}else{
p = cb.and(p,cb.lessThan(root.get(AttendanceSelfHoliday_.sequence),sequence.toString()));
}
sql_stringBuffer.append(" and o.sequence " + (StringUtils.equalsIgnoreCase(order, "DESC") ? ">" : "<") + (" ?" + (index)));
vs.add(sequence);
index++;
}
if(StringUtils.isNotEmpty(wrapIn.getQ_empName())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.employeeName),wrapIn.getQ_empName()));
if ((null != wrapIn.getQ_empName()) && (!wrapIn.getQ_empName().isEmpty())) {
sql_stringBuffer.append(" and o.employeeName = ?" + (index));
vs.add( wrapIn.getQ_empName() );
index++;
}
if(ListTools.isNotEmpty(wrapIn.getUnitNames())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.unitOu),wrapIn.getUnitNames().get(0)));
if (null != wrapIn.getUnitNames() && wrapIn.getUnitNames().size()>0) {
sql_stringBuffer.append(" and o.unitName in ( ?" + (index) + ")");
vs.add( wrapIn.getUnitNames() );
index++;
}
if(ListTools.isNotEmpty(wrapIn.getTopUnitNames())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.topUnitOu),wrapIn.getTopUnitNames().get(0)));
if (null != wrapIn.getTopUnitNames() && wrapIn.getTopUnitNames().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ( ?" + (index) + ")");
vs.add( wrapIn.getTopUnitNames() );
index++;
}
if( StringUtils.isNotEmpty( wrapIn.getKey() )){
sql_stringBuffer.append(" order by o."+wrapIn.getKey()+" " + order );
}else{
sql_stringBuffer.append(" order by o.sequence " + order );
}
Query query = em.createQuery(cq.select(root).where(p).orderBy(_order) );
Query query = em.createQuery( sql_stringBuffer.toString(), AttendanceSelfHoliday.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
}
return query.setMaxResults(20).getResultList();
}
......@@ -212,21 +250,34 @@ public class AttendanceSelfHolidayFactory extends AbstractFactory {
public long getCountWithFilter( WrapInFilter wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( AttendanceSelfHoliday.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<AttendanceSelfHoliday> root = cq.from(AttendanceSelfHoliday.class);
Predicate p = cb.isNotNull(root.get(AttendanceSelfHoliday_.employeeName));
if(StringUtils.isNotEmpty(wrapIn.getQ_empName())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.employeeName),wrapIn.getQ_empName()));
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
Integer index = 1;
sql_stringBuffer.append( "SELECT count(o.id) FROM "+AttendanceSelfHoliday.class.getCanonicalName()+" o where 1=1" );
if ((null != wrapIn.getQ_empName()) && (!wrapIn.getQ_empName().isEmpty())) {
sql_stringBuffer.append(" and o.employeeName = ?" + (index));
vs.add( wrapIn.getQ_empName() );
index++;
}
if(ListTools.isNotEmpty(wrapIn.getUnitNames())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.unitOu),wrapIn.getUnitNames().get(0)));
if (null != wrapIn.getUnitNames() && wrapIn.getUnitNames().size()>0) {
sql_stringBuffer.append(" and o.unitName in ( ?" + (index) + ")");
vs.add( wrapIn.getUnitNames() );
index++;
}
if(ListTools.isNotEmpty(wrapIn.getTopUnitNames())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.topUnitOu),wrapIn.getTopUnitNames().get(0)));
if (null != wrapIn.getTopUnitNames() && wrapIn.getTopUnitNames().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ( ?" + (index) + ")");
vs.add( wrapIn.getTopUnitNames() );
index++;
}
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
Query query = em.createQuery( sql_stringBuffer.toString(), AttendanceSelfHoliday.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
}
return (Long) query.getSingleResult();
}
public List<String> getByPersonName(String personName) throws Exception {
......
......@@ -33,6 +33,7 @@ public class ActionAppealCreate extends BaseAction {
String appeal_auditor_value = null;
String appeal_checker_type = null;
String appeal_checker_value = null;
String appeal_flowType_value = null;
String personName = null;
Wi wrapIn = null;
Boolean check = true;
......@@ -69,6 +70,7 @@ public class ActionAppealCreate extends BaseAction {
appeal_auditor_value = attendanceSettingServiceAdv.getValueByCode( "APPEAL_AUDITOR_VALUE" );
appeal_checker_type = attendanceSettingServiceAdv.getValueByCode( "APPEAL_CHECKER_TYPE" );
appeal_checker_value = attendanceSettingServiceAdv.getValueByCode( "APPEAL_CHECKER_VALUE" );
appeal_flowType_value = attendanceSettingServiceAdv.getValueByCode( "APPEAL_AUDIFLOWTYPE" );
}catch( Exception e ) {
check = false;
Exception exception = new ExceptionAttendanceAppealProcess( e, "系统在获取申诉审核配置时发生异常!" );
......@@ -103,6 +105,7 @@ public class ActionAppealCreate extends BaseAction {
attendanceAppealInfo.setCurrentProcessor( appealAuditPersonName );// 将第一个处理人设置为当前处理人
attendanceAppealAuditInfo.setAuditFlowType( AppealConfig.APPEAL_AUDIFLOWTYPE_BUILTIN );
}
}catch( Exception e ) {
check = false;
Exception exception = new ExceptionAttendanceAppealProcess(e, "系统在根据根据考勤人员查询申诉审核人信息时发生异常!personName:"+personName );
......@@ -111,9 +114,22 @@ public class ActionAppealCreate extends BaseAction {
logger.error(e, effectivePerson, request, null);
}
}
if(StringUtils.equals(appeal_flowType_value,AppealConfig.APPEAL_AUDIFLOWTYPE_WORKFLOW)){
attendanceAppealAuditInfo.setAuditFlowType( AppealConfig.APPEAL_AUDIFLOWTYPE_WORKFLOW );
attendanceAppealAuditInfo.setCurrentProcessor( "" );
attendanceAppealInfo.setCurrentProcessor( "" );
if(StringUtils.isNotEmpty(wrapIn.getUnitName())){
attendanceAppealInfo.setUnitName(wrapIn.getUnitName());
attendanceAppealAuditInfo.setProcessPersonUnit1(wrapIn.getUnitName());
attendanceAppealAuditInfo.setProcessPersonUnit2(wrapIn.getUnitName());
}
if(StringUtils.isNotEmpty(wrapIn.getWorkId())){
attendanceAppealAuditInfo.setWorkId(wrapIn.getWorkId());
}
}
}
if (check) {
if (check && !StringUtils.equals(appeal_flowType_value,AppealConfig.APPEAL_AUDIFLOWTYPE_WORKFLOW)) {
if( StringUtils.isEmpty(appealAuditPersonName) ) {
//申诉审核人不存在
check = false;
......@@ -143,8 +159,8 @@ public class ActionAppealCreate extends BaseAction {
}
//查询申诉复核人
if (check) {
if( StringUtils.isNotEmpty( appeal_checker_type ) && !"无".equals( appeal_checker_type ) ) {
if (check && (!StringUtils.equals(appeal_flowType_value,AppealConfig.APPEAL_AUDIFLOWTYPE_WORKFLOW))) {
if( StringUtils.isNotEmpty( appeal_checker_type ) && !"无".equals( appeal_checker_type ) ) {
try {
appealCheckPersonName = attendanceAppealInfoServiceAdv.getAppealCheckPerson( personName, attendanceAppealInfo.getUnitName(), wrapIn.getIdentity() );
attendanceAppealAuditInfo.setProcessPerson2( appealCheckPersonName );
......@@ -157,8 +173,8 @@ public class ActionAppealCreate extends BaseAction {
}
}
}
if (check) {
if( StringUtils.isNotEmpty( appeal_checker_type ) && !StringUtils.equals( appeal_checker_type, "无" ) ) {
if (check && (!StringUtils.equals(appeal_flowType_value,AppealConfig.APPEAL_AUDIFLOWTYPE_WORKFLOW))) {
if( StringUtils.isNotEmpty( appeal_checker_type ) && !StringUtils.equals( appeal_checker_type, "无" ) ) {
if( StringUtils.isEmpty(appealCheckPersonName) ) {
//申诉复核人不存在
check = false;
......@@ -186,7 +202,7 @@ public class ActionAppealCreate extends BaseAction {
}
//查询申诉审核人所属组织
if (check) {
if (check && (!StringUtils.equals(appeal_flowType_value,AppealConfig.APPEAL_AUDIFLOWTYPE_WORKFLOW))) {
if( AppealConfig.APPEAL_AUDITTYPE_UNITDUTY.equalsIgnoreCase( appeal_auditor_type ) ) {
attendanceAppealAuditInfo.setProcessPersonUnit1(
attendanceAppealInfoServiceAdv.getPersonUnitName( appealAuditPersonName, attendanceDetail.getUnitName(), wrapIn.getIdentity() ) );
......@@ -206,7 +222,7 @@ public class ActionAppealCreate extends BaseAction {
}
}
//根据所属组织名称查询申诉审核人所属顶层组织
if (check) {
if (check && !StringUtils.equals(appeal_flowType_value,AppealConfig.APPEAL_AUDIFLOWTYPE_WORKFLOW)) {
if( StringUtils.isNotEmpty( attendanceAppealAuditInfo.getProcessPersonUnit1() )) {
try {
attendanceAppealAuditInfo.setProcessPersonTopUnit1( userManagerService.getTopUnitNameWithUnitName( attendanceAppealAuditInfo.getProcessPersonUnit1() ) );
......@@ -221,7 +237,7 @@ public class ActionAppealCreate extends BaseAction {
}
//查询申诉复核人所属组织
if (check) {
if (check && !StringUtils.equals(appeal_flowType_value,AppealConfig.APPEAL_AUDIFLOWTYPE_WORKFLOW)) {
if( AppealConfig.APPEAL_AUDITTYPE_UNITDUTY.equalsIgnoreCase( appeal_auditor_type ) ) {
attendanceAppealAuditInfo.setProcessPersonUnit2( attendanceAppealInfoServiceAdv.getPersonUnitName( appealCheckPersonName, attendanceDetail.getUnitName(), wrapIn.getIdentity() ) );
}else {
......@@ -240,7 +256,7 @@ public class ActionAppealCreate extends BaseAction {
}
}
//根据所属组织名称查询申诉复核人所属顶层组织
if (check) {
if (check && !StringUtils.equals(appeal_flowType_value,AppealConfig.APPEAL_AUDIFLOWTYPE_WORKFLOW)) {
if( StringUtils.isNotEmpty(attendanceAppealAuditInfo.getProcessPersonUnit2())) {
try {//获取复核人顶层组织信息
attendanceAppealAuditInfo.setProcessPersonTopUnit2( userManagerService.getTopUnitNameWithUnitName( attendanceAppealAuditInfo.getProcessPersonUnit2()) );
......@@ -295,6 +311,17 @@ public class ActionAppealCreate extends BaseAction {
public void setIdentity(String identity) {
this.identity = identity;
}
@FieldDescribe("自定义流程workId")
private String workId = null;
public String getWorkId() {
return workId;
}
public void setWorkId(String workId) {
this.workId = workId;
}
}
public static class Wo extends WoId {
......
......@@ -23,20 +23,14 @@ public class ActionWorkFlowSync extends BaseAction {
private static Logger logger = LoggerFactory.getLogger( ActionWorkFlowSync.class );
protected ActionResult<Wo> execute( HttpServletRequest request, EffectivePerson effectivePerson, String id, JsonElement jsonElement ) throws Exception {
protected ActionResult<Wo> execute( HttpServletRequest request, EffectivePerson effectivePerson, JsonElement jsonElement ) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
AttendanceAppealInfo attendanceAppealInfo = null;
AttendanceAppealAuditInfo attendanceAppealAuditInfo = null;
WorkFlowSyncService.WoWorkOrCompletedComplex woWorkComplex = null;
ActionAppealCreate.Wi wrapIn = null;
Boolean check = true;
if (check) {
if ( StringUtils.isEmpty( id )) {
check = false;
result.error(new Exception("传入的id为空,或者不合法,无法同步流程数据。"));
}
}
String id = "";
if (check) {
try {
......@@ -49,6 +43,14 @@ public class ActionWorkFlowSync extends BaseAction {
}
}
if (check) {
id = wrapIn.getId();
if ( StringUtils.isEmpty( id )) {
check = false;
result.error(new Exception("传入的id为空,或者不合法,无法同步流程数据。"));
}
}
if (check) {
if( wrapIn.getStatus() != 0 & wrapIn.getStatus() != 1 &wrapIn.getStatus() != -1 &wrapIn.getStatus() != 9 ){
check = false;
......@@ -147,9 +149,11 @@ public class ActionWorkFlowSync extends BaseAction {
}
public static class Wi {
@FieldDescribe("考勤申诉id")
private String id = "";
@FieldDescribe("申诉状态:0-未申诉,1-申诉中,-1-申诉未通过,9-申诉通过.")
private Integer status = 1;
@FieldDescribe("1-审批通过,-1-审批不能过")
private Integer status = 0;
public Integer getStatus() {
return status;
......@@ -158,6 +162,14 @@ public class ActionWorkFlowSync extends BaseAction {
public void setStatus(Integer status) {
this.status = status;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
public static class Wo extends WoId {
......
......@@ -284,17 +284,16 @@ public class AttendanceAppealInfoAction extends StandardJaxrsAction {
@JaxrsMethodDescribe(value = "根据考勤申诉ID,更新申诉审核流程的审批信息以及最终审核状态", action = ActionWorkFlowSync.class)
@PUT
@Path("workflow/sync/{id}")
@Path("workflow/sync")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void syncWithWork(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("考勤申诉信息ID") @PathParam("id") String id, JsonElement jsonElement) {
public void syncWithWork(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, JsonElement jsonElement) {
ActionResult<ActionWorkFlowSync.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
Boolean check = true;
if (check) {
try {
result = new ActionWorkFlowSync().execute(request, effectivePerson, id, jsonElement);
result = new ActionWorkFlowSync().execute(request, effectivePerson, jsonElement);
} catch (Exception e) {
result = new ActionResult<>();
Exception exception = new ExceptionAttendanceAppealProcess(e, "根据ID对打卡结果进行归档时发生异常!");
......
......@@ -401,6 +401,7 @@ public class AttendanceAppealInfoServiceAdv {
emc.beginTransaction( AttendanceAppealInfo.class );
emc.beginTransaction( AttendanceAppealAuditInfo.class );
emc.beginTransaction( AttendanceDetail.class );
attendanceAppealInfo.setStatus(status);
if( StringUtils.equalsAnyIgnoreCase( "end", activityType )){//审核结束了
......@@ -410,6 +411,11 @@ public class AttendanceAppealInfoServiceAdv {
attendanceAppealInfo.setCurrentProcessor( currentProcessor );
attendanceAppealAuditInfo.setCurrentProcessor( currentProcessor );
}
if ( status == 1 ) {
attendanceDetailService.updateAppealProcessStatus( emc, attendanceAppealInfo.getId(), 9, false );
}else{
attendanceDetailService.updateAppealProcessStatus( emc, attendanceAppealInfo.getId(), -1, false );
}
emc.commit();
} catch ( Exception e ) {
throw e;
......
......@@ -17,7 +17,7 @@ import java.util.List;
public class WorkFlowSyncService {
public static WoWorkOrCompletedComplex getWorkComplex( String workId ) throws Exception {
String serviceUri = "work/" + workId;
String serviceUri = "work/v2/workorworkcompleted/" + workId;
ActionResponse resp = ThisApplication.context().applications().getQuery(
x_processplatform_assemble_surface.class, serviceUri
);
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.3</version>
<version>6.4</version>
</parent>
<artifactId>x_attendance_core_entity</artifactId>
<packaging>jar</packaging>
......
......@@ -6,7 +6,7 @@
<parent>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.3</version>
<version>6.4</version>
</parent>
<artifactId>x_base_core_project</artifactId>
<packaging>jar</packaging>
......
......@@ -23,7 +23,6 @@ import org.quartz.impl.StdSchedulerFactory;
import org.quartz.impl.matchers.EverythingMatcher;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.Module;
......@@ -283,7 +282,7 @@ public class Context extends AbstractContext {
private void initDatas() throws Exception {
if (ArrayUtils.isNotEmpty(this.module.containerEntities())) {
logger.print("{} loading datas, entity size:{}.", this.clazz.getName(),
logger.info("{} loading datas, entity size:{}.", this.clazz.getName(),
this.module.containerEntities().length);
EntityManagerContainerFactory.init(path, ListTools.toList(this.module.containerEntities()));
}
......
......@@ -100,6 +100,7 @@ public class Config {
public static final String PATH_CONFIG_EMAIL = "config/email.json";
public static final String PATH_CONFIG_WEB = "config/web.json";
public static final String PATH_CONFIG_MOCK = "config/mock.json";
public static final String PATH_CONFIG_TERNARY_MANAGEMENT = "config/ternaryManagement.json";
public static final String DIR_COMMONS = "commons";
public static final String DIR_COMMONS_TESS4J_TESSDATA = "commons/tess4j/tessdata";
......@@ -600,6 +601,19 @@ public class Config {
return instance().token;
}
private TernaryManagement ternaryManagement;
public static synchronized TernaryManagement ternaryManagement() throws Exception {
if (null == instance().ternaryManagement) {
TernaryManagement o = BaseTools.readConfigObject(PATH_CONFIG_TERNARY_MANAGEMENT, TernaryManagement.class);
if (null == o) {
o = TernaryManagement.defaultInstance();
}
instance().ternaryManagement = o;
}
return instance().ternaryManagement;
}
private ExternalDataSources externalDataSources;
public static synchronized ExternalDataSources externalDataSources() throws Exception {
......
package com.x.base.core.project.config;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.NameValuePair;
import com.x.base.core.project.connection.HttpConnection;
import com.x.base.core.project.gson.GsonPropertyObject;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class HuaweiPushConfig extends ConfigObject {
private static final String O2_app_id_default = "100016851";
private static final String O2_app_secret_default = "b3ad9287e8d1d16d0aad8fde66e59118";
// 获取accesssToken的url
private static final String huawei_get_token_url = "https://oauth-login.cloud.huawei.com/oauth2/v3/token";
// 华为推送消息接口url
private static final String huawei_push_message_url = "https://push-api.cloud.huawei.com/v1/{0}/messages:send";
public static HuaweiPushConfig defaultInstance() {
return new HuaweiPushConfig();
}
public HuaweiPushConfig() {
this.appId = O2_app_id_default;
this.appSecret = O2_app_secret_default;
}
@FieldDescribe("华为推送应用的appId")
private String appId;
@FieldDescribe("华为推送应用的appSecret")
private String appSecret;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getAppSecret() {
return appSecret;
}
public void setAppSecret(String appSecret) {
this.appSecret = appSecret;
}
// accessToken 有一段时间可以通用,缓存下来
private static String cacheAccessToken;
private static Date cacheAccessTokenDate;
/**
* 推送消息的url
* @return
*/
public String getPushUrl() {
return MessageFormat.format(huawei_push_message_url, this.getAppId());
}
/**
* 华为accessToken 获取
* @return
* @throws Exception
*/
public String accessToken() throws Exception {
if ((StringUtils.isNotEmpty(cacheAccessToken) && (null != cacheAccessTokenDate))
&& (cacheAccessTokenDate.after(new Date()))) {
return cacheAccessToken;
} else {
List<NameValuePair> heads = new ArrayList<>();
heads.add(new NameValuePair("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"));
HuaweiAccessTokenResp resp = HttpConnection.postAsObject(huawei_get_token_url, heads, this.createRequestBody(), HuaweiAccessTokenResp.class);
cacheAccessToken = resp.getAccess_token();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MINUTE, 90);
cacheAccessTokenDate = cal.getTime();
return cacheAccessToken;
}
}
private String createRequestBody() {
return MessageFormat.format("grant_type=client_credentials&client_secret={0}&client_id={1}", this.getAppSecret(), this.getAppId());
}
public static class HuaweiAccessTokenResp extends GsonPropertyObject {
private String access_token;
private Integer expires_in;
private String token_type;
public String getAccess_token() {
return access_token;
}
public void setAccess_token(String access_token) {
this.access_token = access_token;
}
public Integer getExpires_in() {
return expires_in;
}
public void setExpires_in(Integer expires_in) {
this.expires_in = expires_in;
}
public String getToken_type() {
return token_type;
}
public void setToken_type(String token_type) {
this.token_type = token_type;
}
}
}
......@@ -13,9 +13,11 @@ public class JpushConfig extends ConfigObject {
return new JpushConfig();
}
public JpushConfig() {
this.enable = false;
this.enable = true;
this.appKey = O2_app_key_default;
this.masterSecret = O2_master_secret_default;
this.huaweiPushEnable = false;
this.huaweiPushConfig = HuaweiPushConfig.defaultInstance();
}
......@@ -25,6 +27,12 @@ public class JpushConfig extends ConfigObject {
private String appKey;
@FieldDescribe("极光推送应用的Master Secret")
private String masterSecret;
@FieldDescribe("是否开启华为推送")
private Boolean huaweiPushEnable;
@FieldDescribe("华为推送的配置")
private HuaweiPushConfig huaweiPushConfig;
public Boolean getEnable() {
return BooleanUtils.isTrue(this.enable);
......@@ -49,4 +57,20 @@ public class JpushConfig extends ConfigObject {
public void setMasterSecret(String masterSecret) {
this.masterSecret = masterSecret;
}
public Boolean getHuaweiPushEnable() {
return huaweiPushEnable;
}
public void setHuaweiPushEnable(Boolean huaweiPushEnable) {
this.huaweiPushEnable = huaweiPushEnable;
}
public HuaweiPushConfig getHuaweiPushConfig() {
return huaweiPushConfig;
}
public void setHuaweiPushConfig(HuaweiPushConfig huaweiPushConfig) {
this.huaweiPushConfig = huaweiPushConfig;
}
}
package com.x.base.core.project.config;
import java.util.Objects;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.event.Level;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.logger.Logger;
public class LogLevel extends ConfigObject {
......@@ -241,22 +243,22 @@ public class LogLevel extends ConfigObject {
}
private String getLevel(String str) {
if (StringUtils.equalsIgnoreCase(str, Logger.ERROR)) {
return Logger.ERROR;
if (StringUtils.equalsIgnoreCase(str, Objects.toString(Level.ERROR))) {
return Objects.toString(Level.ERROR);
}
if (StringUtils.equalsIgnoreCase(str, Logger.WARN)) {
return Logger.WARN;
if (StringUtils.equalsIgnoreCase(str, Objects.toString(Level.WARN))) {
return Objects.toString(Level.WARN);
}
if (StringUtils.equalsIgnoreCase(str, Logger.INFO)) {
return Logger.INFO;
if (StringUtils.equalsIgnoreCase(str, Objects.toString(Level.INFO))) {
return Objects.toString(Level.INFO);
}
if (StringUtils.equalsIgnoreCase(str, Logger.DEBUG)) {
return Logger.DEBUG;
if (StringUtils.equalsIgnoreCase(str, Objects.toString(Level.DEBUG))) {
return Objects.toString(Level.DEBUG);
}
if (StringUtils.equalsIgnoreCase(str, Logger.TRACE)) {
return Logger.TRACE;
if (StringUtils.equalsIgnoreCase(str, Objects.toString(Level.TRACE))) {
return Objects.toString(Level.TRACE);
}
return Logger.INFO;
return Objects.toString(Level.INFO);
}
public static class Audit extends ConfigObject {
......
......@@ -17,7 +17,8 @@ public class Organization extends ConfigObject {
public static final Integer DEFAULT_UNITLEVELORDERNUMBERDIGITS = 10;
public static final Boolean DEFAULT_PICKPERSONWITHNAME = true;
public static final Boolean DEFAULT_PICKIDENTITYWITHNAME = true;
/* 默认改为false,避免自动补发待办 */
public static final Boolean DEFAULT_PICKIDENTITYWITHNAME = false;
public static Organization defaultInstance() {
return new Organization();
......
package com.x.base.core.project.config;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.TokenType;
import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.base.core.project.tools.BaseTools;
import com.x.base.core.project.tools.Crypto;
import com.x.base.core.project.tools.DefaultCharset;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* 三元管理配置
*/
public class TernaryManagement extends ConfigObject {
public static final String initPassword = "o2";
public static final String INIT_SYSTEM_MANAGER = "systemManager";
public static final String INIT_SYSTEM_MANAGER_DISTINGUISHED_NAME = "系统管理员@systemManager@P";
public static final String INIT_SECURITY_MANAGER = "securityManager";
public static final String INIT_SECURITY_MANAGER_DISTINGUISHED_NAME = "安全管理员@securityManager@P";
public static final String INIT_AUDIT_MANAGER = "auditManager";
public static final String INIT_AUDIT_MANAGER_DISTINGUISHED_NAME = "安全审计员@auditManager@P";
private transient String _systemManagerPassword;
private transient String _securityManagerPassword;
private transient String _auditManagerPassword;
public static TernaryManagement defaultInstance() {
TernaryManagement o = new TernaryManagement();
return o;
}
public TernaryManagement(){
this.enable = false;
this.systemManager = INIT_SYSTEM_MANAGER;
this.systemManagerDistinguishedName = INIT_SYSTEM_MANAGER_DISTINGUISHED_NAME;
this.securityManager = INIT_SECURITY_MANAGER;
this.securityManagerDistinguishedName = INIT_SECURITY_MANAGER_DISTINGUISHED_NAME;
this.auditManager = INIT_AUDIT_MANAGER;
this.auditManagerDistinguishedName = INIT_AUDIT_MANAGER_DISTINGUISHED_NAME;
}
public boolean isTernaryManagement(String name) {
return StringUtils.equals(this.getSystemManager(), name)
|| StringUtils.equals(this.getSystemManagerDistinguishedName(), name)
|| StringUtils.equals(this.getSystemManagerName(), name)
|| StringUtils.equals(this.getSecurityManager(), name)
|| StringUtils.equals(this.getSecurityManagerDistinguishedName(), name)
|| StringUtils.equals(this.getSecurityManagerName(), name)
|| StringUtils.equals(this.getAuditManager(), name)
|| StringUtils.equals(this.getAuditManagerDistinguishedName(), name)
|| StringUtils.equals(this.getAuditManagerName(), name);
}
public boolean isSystemManager(String name) {
return StringUtils.equals(this.getSystemManager(), name)
|| StringUtils.equals(this.getSystemManagerDistinguishedName(), name)
|| StringUtils.equals(this.getSystemManagerName(), name);
}
public boolean isSecurityManager(String name) {
return StringUtils.equals(this.getSecurityManager(), name)
|| StringUtils.equals(this.getSecurityManagerDistinguishedName(), name)
|| StringUtils.equals(this.getSecurityManagerName(), name);
}
public boolean isAuditManager(String name) {
return StringUtils.equals(this.getAuditManager(), name)
|| StringUtils.equals(this.getAuditManagerDistinguishedName(), name)
|| StringUtils.equals(this.getAuditManagerName(), name);
}
public boolean verifyPassword(String name, String password) {
if(this.isSystemManager(name)){
return StringUtils.equals(this.getSystemManagerPassword(), password);
} else if(this.isSecurityManager(name)){
return StringUtils.equals(this.getSecurityManagerPassword(), password);
} else if(this.isAuditManager(name)){
return StringUtils.equals(this.getAuditManagerPassword(), password);
} else{
return false;
}
}
public TokenType getTokenType(String name){
if(this.isSystemManager(name)){
return TokenType.systemManager;
} else if(this.isSecurityManager(name)){
return TokenType.securityManager;
} else if(this.isAuditManager(name)){
return TokenType.auditManager;
}else{
return null;
}
}
public void save() throws Exception {
File file = new File(Config.base(), Config.PATH_CONFIG_TERNARY_MANAGEMENT);
FileUtils.write(file, XGsonBuilder.toJson(this), DefaultCharset.charset);
BaseTools.executeSyncFile(Config.PATH_CONFIG_TERNARY_MANAGEMENT);
}
public InitialManager initialManagerInstance(String name) {
InitialManager o = new InitialManager();
String distinguishedName = "";
if(isSystemManager(name)){
name = this.getSystemManager();
distinguishedName = this.getSystemManagerDistinguishedName();
}else if(isSecurityManager(name)){
name = this.getSystemManager();
distinguishedName = this.getSystemManagerDistinguishedName();
}else if(isAuditManager(name)){
name = this.getSystemManager();
distinguishedName = this.getSystemManagerDistinguishedName();
}
o.name = name;
o.id = name;
o.employee = name;
o.display = name;
o.mail = name + "@o2oa.net";
o.setDistinguishedName(distinguishedName);
o.weixin = "";
o.qq = "";
o.weibo = "";
o.mobile = "";
o.roleList = new ArrayList<>();
if(isSystemManager(name)){
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.SystemManager));
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.ProcessPlatformManager));
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.MeetingManager));
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.QueryManager));
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.CMSManager));
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.ServiceManager));
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.FileManager));
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.PortalManager));
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.AttendanceManager));
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.BBSManager));
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.TeamWorkManager));
}else if(isSecurityManager(name)){
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.SecurityManager));
}else if(isAuditManager(name)){
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.AuditManager));
}
return o;
}
public class InitialManager extends GsonPropertyObject {
private String name;
private String unique;
private String id;
private String distinguishedName;
private String employee;
private String display;
private String mail;
private String weixin;
private String qq;
private String weibo;
private String mobile;
private String pinyin;
private String pinyinInitial;
// private String icon;
private List<String> roleList;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmployee() {
return employee;
}
public void setEmployee(String employee) {
this.employee = employee;
}
public String getDisplay() {
return display;
}
public void setDisplay(String display) {
this.display = display;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public String getWeixin() {
return weixin;
}
public void setWeixin(String weixin) {
this.weixin = weixin;
}
public String getQq() {
return qq;
}
public void setQq(String qq) {
this.qq = qq;
}
public String getWeibo() {
return weibo;
}
public void setWeibo(String weibo) {
this.weibo = weibo;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public List<String> getRoleList() {
return roleList;
}
public void setRoleList(List<String> roleList) {
this.roleList = roleList;
}
public String getUnique() {
return unique;
}
public void setUnique(String unique) {
this.unique = unique;
}
public String getDistinguishedName() {
return distinguishedName;
}
public void setDistinguishedName(String distinguishedName) {
this.distinguishedName = distinguishedName;
}
public String getPinyin() {
return pinyin;
}
public void setPinyin(String pinyin) {
this.pinyin = pinyin;
}
public String getPinyinInitial() {
return pinyinInitial;
}
public void setPinyinInitial(String pinyinInitial) {
this.pinyinInitial = pinyinInitial;
}
}
@FieldDescribe("是否启用三元管理.")
private Boolean enable;
@FieldDescribe("系统管理员账号,不可更改.")
private String systemManager;
@FieldDescribe("系统管理员账号全称,不可更改.")
private String systemManagerDistinguishedName;
@FieldDescribe("系统管理员账号密码.")
private String systemManagerPassword;
@FieldDescribe("安全管理员账号,不可更改.")
private String securityManager;
@FieldDescribe("安全管理员账号全称,不可更改.")
private String securityManagerDistinguishedName;
@FieldDescribe("安全管理员账号密码.")
private String securityManagerPassword;
@FieldDescribe("安全审计员账号,不可更改.")
private String auditManager;
@FieldDescribe("安全审计员账号全称,不可更改.")
private String auditManagerDistinguishedName;
@FieldDescribe("安全审计员账号密码.")
private String auditManagerPassword;
public Boolean getEnable() {
return enable;
}
public void setEnable(Boolean enable) {
this.enable = enable;
}
public String getSystemManager() {
return systemManager;
}
public void setSystemManager(String systemManager) {
this.systemManager = systemManager;
}
public String getSystemManagerDistinguishedName() {
return systemManagerDistinguishedName;
}
public void setSystemManagerDistinguishedName(String systemManagerDistinguishedName) {
this.systemManagerDistinguishedName = systemManagerDistinguishedName;
}
public String getSystemManagerName() {
return systemManagerDistinguishedName.split("@")[0];
}
public String getSystemManagerPassword() {
if (StringUtils.isEmpty(this._systemManagerPassword)) {
String password = StringUtils.isBlank(this.systemManagerPassword) ? initPassword : this.systemManagerPassword;
this._systemManagerPassword = Crypto.plainText(password);
}
return this._systemManagerPassword;
}
public void setSystemManagerPassword(String systemManagerPassword) {
this.systemManagerPassword = systemManagerPassword;
}
public String getSecurityManager() {
return securityManager;
}
public void setSecurityManager(String securityManager) {
this.securityManager = securityManager;
}
public String getSecurityManagerDistinguishedName() {
return securityManagerDistinguishedName;
}
public String getSecurityManagerName() {
return securityManagerDistinguishedName.split("@")[0];
}
public void setSecurityManagerDistinguishedName(String securityManagerDistinguishedName) {
this.securityManagerDistinguishedName = securityManagerDistinguishedName;
}
public String getSecurityManagerPassword() {
if (StringUtils.isEmpty(this._securityManagerPassword)) {
String password = StringUtils.isBlank(this.securityManagerPassword) ? initPassword : this.securityManagerPassword;
this._securityManagerPassword = Crypto.plainText(password);
}
return this._securityManagerPassword;
}
public void setSecurityManagerPassword(String securityManagerPassword) {
this.securityManagerPassword = securityManagerPassword;
}
public String getAuditManager() {
return auditManager;
}
public void setAuditManager(String auditManager) {
this.auditManager = auditManager;
}
public String getAuditManagerDistinguishedName() {
return auditManagerDistinguishedName;
}
public void setAuditManagerDistinguishedName(String auditManagerDistinguishedName) {
this.auditManagerDistinguishedName = auditManagerDistinguishedName;
}
public String getAuditManagerName() {
return auditManagerDistinguishedName.split("@")[0];
}
public String getAuditManagerPassword() {
if (StringUtils.isEmpty(this._auditManagerPassword)) {
String password = StringUtils.isBlank(this.auditManagerPassword) ? initPassword : this.auditManagerPassword;
this._auditManagerPassword = Crypto.plainText(password);
}
return this._auditManagerPassword;
}
public void setAuditManagerPassword(String auditManagerPassword) {
this.auditManagerPassword = auditManagerPassword;
}
}
......@@ -13,6 +13,7 @@ import com.x.base.core.project.tools.Crypto;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.annotation.FieldDescribe;
......@@ -196,9 +197,21 @@ public class Token extends ConfigObject {
BaseTools.executeSyncFile(Config.PATH_CONFIG_TOKEN);
}
public boolean isInitialManager(String name) {
return StringUtils.equals(this.getInitialManager(), name)
|| StringUtils.equals(this.getInitialManagerDistinguishedName(), name);
public boolean isInitialManager(String name) throws Exception {
if(BooleanUtils.isTrue(Config.ternaryManagement().getEnable())){
return Config.ternaryManagement().isTernaryManagement(name);
}else {
return StringUtils.equals(this.getInitialManager(), name)
|| StringUtils.equals(this.getInitialManagerDistinguishedName(), name);
}
}
public boolean verifyPassword(String name, String password) throws Exception {
if(BooleanUtils.isTrue(Config.ternaryManagement().getEnable())){
return Config.ternaryManagement().verifyPassword(name, password);
}else{
return StringUtils.equals(this.getPassword(), password);
}
}
public InitialManager initialManagerInstance() {
......@@ -218,12 +231,12 @@ public class Token extends ConfigObject {
o.roleList = new ArrayList<String>();
// o.roleList.add(RoleDefinition.UnitManager);
// o.roleList.add(RoleDefinition.GroupCreator);
o.roleList.add(OrganizationDefinition.Manager);
o.roleList.add(OrganizationDefinition.OrganizationManager);
o.roleList.add(OrganizationDefinition.MeetingManager);
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.Manager));
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.OrganizationManager));
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.MeetingManager));
// o.roleList.add(RoleDefinition.PersonManager);
// o.roleList.add(RoleDefinition.ProcessPlatformCreator);
o.roleList.add(OrganizationDefinition.ProcessPlatformManager);
o.roleList.add(OrganizationDefinition.toDistinguishedName(OrganizationDefinition.ProcessPlatformManager));
return o;
}
......
package com.x.base.core.project.exception;
public class ExceptionUnauthorized extends LanguagePromptException {
private static final long serialVersionUID = 8121998765154409958L;
public ExceptionUnauthorized() {
super("会话已过期或未登录.");
}
}
package com.x.base.core.project.exception;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.logger.MessageFormatter;
import com.x.base.core.project.tools.LanguageTools;
import org.apache.commons.lang3.StringUtils;
public abstract class LanguagePromptException extends PromptException {
......
package com.x.base.core.project.exception;
import com.x.base.core.project.logger.MessageFormatter;
import org.slf4j.helpers.MessageFormatter;
public abstract class PromptException extends Exception {
......@@ -10,27 +10,27 @@ public abstract class PromptException extends Exception {
private static final long serialVersionUID = -6306372564902986731L;
public PromptException() {
protected PromptException() {
super();
}
public PromptException(String message) {
protected PromptException(String message) {
super(message);
}
public PromptException(String message, Object... os) {
protected PromptException(String message, Object... os) {
super(format(message, os));
}
public PromptException(Throwable cause) {
protected PromptException(Throwable cause) {
super(cause);
}
public PromptException(Throwable cause, String message) {
protected PromptException(Throwable cause, String message) {
super(message, cause);
}
public PromptException(Throwable cause, String message, Object... os) {
protected PromptException(Throwable cause, String message, Object... os) {
super(format(message, os), cause);
}
......
......@@ -76,10 +76,18 @@ public class EffectivePerson extends GsonPropertyObject {
case manager:
this.token = this.concreteToken(key);
break;
case systemManager:
this.token = this.concreteToken(key);
break;
case securityManager:
this.token = this.concreteToken(key);
break;
case auditManager:
this.token = this.concreteToken(key);
break;
case cipher:
this.token = this.concreteToken(key);
break;
}
}
......@@ -118,6 +126,8 @@ public class EffectivePerson extends GsonPropertyObject {
switch (this.tokenType) {
case manager:
return true;
case systemManager:
return true;
case cipher:
return true;
default:
......@@ -125,6 +135,19 @@ public class EffectivePerson extends GsonPropertyObject {
}
}
public boolean isSecurityManager() {
switch (this.tokenType) {
case manager:
return true;
case securityManager:
return true;
case cipher:
return true;
default:
return false;
}
}
public boolean isAnonymous() {
switch (this.tokenType) {
case anonymous:
......@@ -147,7 +170,10 @@ public class EffectivePerson extends GsonPropertyObject {
public boolean isPerson(Collection<String> names) {
if (Objects.equals(TokenType.user, this.getTokenType())
|| Objects.equals(TokenType.manager, this.getTokenType())) {
|| Objects.equals(TokenType.manager, this.getTokenType())
|| Objects.equals(TokenType.systemManager, this.getTokenType())
|| Objects.equals(TokenType.auditManager, this.getTokenType())
|| Objects.equals(TokenType.securityManager, this.getTokenType())) {
if (null != names) {
List<String> list = new ArrayList<>(names);
if (list.contains(this.distinguishedName)) {
......
......@@ -38,7 +38,7 @@ public class HttpToken {
public static final String SET_COOKIE = "Set-Cookie";
private static final String RegularExpression_IP = "([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}";
private static final String RegularExpression_Token = "^(anonymous|user|manager|cipher)([2][0][1-9][0-9][0-1][0-9][0-3][0-9][0-5][0-9][0-5][0-9][0-5][0-9])(\\S{1,})$";
private static final String RegularExpression_Token = "^(anonymous|user|manager|cipher|systemManager|securityManager|auditManager)([2][0][1-9][0-9][0-1][0-9][0-3][0-9][0-5][0-9][0-5][0-9][0-5][0-9])(\\S{1,})$";
public EffectivePerson who(HttpServletRequest request, HttpServletResponse response, String key) throws Exception {
EffectivePerson effectivePerson = this.who(this.getToken(request), key, remoteAddress(request));
......@@ -77,7 +77,9 @@ public class HttpToken {
TokenType tokenType = TokenType.valueOf(matcher.group(1));
long diff = (System.currentTimeMillis() - date.getTime());
diff = Math.abs(diff);
if (TokenType.user.equals(tokenType) || TokenType.manager.equals(tokenType)) {
if (TokenType.user.equals(tokenType) || TokenType.manager.equals(tokenType)
|| TokenType.systemManager.equals(tokenType) || TokenType.auditManager.equals(tokenType)
|| TokenType.securityManager.equals(tokenType)) {
if (diff > (60000L * Config.person().getTokenExpiredMinutes())) {
// 不报错,跳过错误,将用户设置为anonymous
logger.warn("token expired, user:{}, token:{}, remote address:{}.",
......@@ -122,6 +124,15 @@ public class HttpToken {
case manager:
this.setResponseToken(request, response, effectivePerson);
break;
case systemManager:
this.setResponseToken(request, response, effectivePerson);
break;
case securityManager:
this.setResponseToken(request, response, effectivePerson);
break;
case auditManager:
this.setResponseToken(request, response, effectivePerson);
break;
case cipher:
this.deleteToken(request, response);
break;
......
package com.x.base.core.project.http;
public enum TokenType {
anonymous, user, manager, cipher;
anonymous, user, manager, cipher, systemManager, securityManager, auditManager;
}
......@@ -10,7 +10,6 @@ import org.glassfish.jersey.media.multipart.MultiPartFeature;
import com.x.base.core.project.jaxrs.cache.CacheAction;
import com.x.base.core.project.jaxrs.echo.EchoAction;
import com.x.base.core.project.jaxrs.fireschedule.FireScheduleAction;
import com.x.base.core.project.jaxrs.logger.LoggerAction;
import com.x.base.core.project.jaxrs.sysresource.SysResourceAction;
public abstract class AbstractActionApplication extends Application {
......@@ -20,7 +19,6 @@ public abstract class AbstractActionApplication extends Application {
public AbstractActionApplication() {
classes.add(EchoAction.class);
classes.add(CacheAction.class);
classes.add(LoggerAction.class);
classes.add(FireScheduleAction.class);
classes.add(SysResourceAction.class);
// providers
......
......@@ -11,10 +11,10 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.FilterTools;
import com.x.base.core.project.http.HttpToken;
import com.x.base.core.project.http.TokenType;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionUnauthorized;
import com.x.base.core.project.http.*;
import org.apache.commons.lang3.StringUtils;
/**
* 必须由前台已经登陆的用户访问
......@@ -30,11 +30,30 @@ public abstract class CipherJaxrsFilter extends TokenFilter {
if (!request.getMethod().equalsIgnoreCase("options")) {
HttpToken httpToken = new HttpToken();
EffectivePerson effectivePerson = httpToken.who(request, response, Config.token().getCipher());
if (!TokenType.cipher.equals(effectivePerson.getTokenType())) {
if (TokenType.anonymous.equals(effectivePerson.getTokenType())) {
/** 401 Unauthorized 未登录访问被拒绝 */
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.setHeader("Content-Type", "application/json;charset=UTF-8");
ActionResult result = new ActionResult();
ExceptionUnauthorized e = new ExceptionUnauthorized();
result.error(e);
String message = e.getFormatMessage(result.getPrompt(), request.getHeader(ResponseFactory.Accept_Language));
if(StringUtils.isNotBlank(message)) {
result.setMessage(message);
}
response.getWriter().write(result.toJson());
} else if (!TokenType.cipher.equals(effectivePerson.getTokenType())) {
/** 需要自己标志500 */
response.setStatus(500);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.setHeader("Content-Type", "application/json;charset=UTF-8");
response.getWriter().write(FilterTools.Application_Not_Cipher_Json);
ActionResult result = new ActionResult();
ExceptionAccessDenied e = new ExceptionAccessDenied(effectivePerson);
result.error(e);
String message = e.getFormatMessage(result.getPrompt(), request.getHeader(ResponseFactory.Accept_Language));
if(StringUtils.isNotBlank(message)) {
result.setMessage(message);
}
response.getWriter().write(result.toJson());
} else {
chain.doFilter(request, response);
}
......
......@@ -11,10 +11,10 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.FilterTools;
import com.x.base.core.project.http.HttpToken;
import com.x.base.core.project.http.TokenType;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionUnauthorized;
import com.x.base.core.project.http.*;
import org.apache.commons.lang3.StringUtils;
/**
* 必须由前台已经登陆的用户访问
......@@ -30,12 +30,32 @@ public abstract class CipherManagerJaxrsFilter extends TokenFilter {
if (!request.getMethod().equalsIgnoreCase("options")) {
HttpToken httpToken = new HttpToken();
EffectivePerson effectivePerson = httpToken.who(request, response, Config.token().getCipher());
if ((!TokenType.cipher.equals(effectivePerson.getTokenType()))
&& (!TokenType.manager.equals(effectivePerson.getTokenType()))) {
if (TokenType.anonymous.equals(effectivePerson.getTokenType())) {
/** 401 Unauthorized 未登录访问被拒绝 */
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.setHeader("Content-Type", "application/json;charset=UTF-8");
ActionResult result = new ActionResult();
ExceptionUnauthorized e = new ExceptionUnauthorized();
result.error(e);
String message = e.getFormatMessage(result.getPrompt(), request.getHeader(ResponseFactory.Accept_Language));
if(StringUtils.isNotBlank(message)) {
result.setMessage(message);
}
response.getWriter().write(result.toJson());
} else if ((!TokenType.cipher.equals(effectivePerson.getTokenType()))
&& (!TokenType.manager.equals(effectivePerson.getTokenType()))
&& (!TokenType.systemManager.equals(effectivePerson.getTokenType()))) {
/** 需要自己标志500 */
response.setStatus(500);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.setHeader("Content-Type", "application/json;charset=UTF-8");
response.getWriter().write(FilterTools.Application_Not_CipherManager_Json);
ActionResult result = new ActionResult();
ExceptionAccessDenied e = new ExceptionAccessDenied(effectivePerson);
result.error(e);
String message = e.getFormatMessage(result.getPrompt(), request.getHeader(ResponseFactory.Accept_Language));
if(StringUtils.isNotBlank(message)) {
result.setMessage(message);
}
response.getWriter().write(result.toJson());
} else {
chain.doFilter(request, response);
}
......
......@@ -11,10 +11,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.FilterTools;
import com.x.base.core.project.http.HttpToken;
import com.x.base.core.project.http.TokenType;
import com.x.base.core.project.exception.ExceptionUnauthorized;
import com.x.base.core.project.http.*;
import org.apache.commons.lang3.StringUtils;
/**
* 必须由前台已经登陆的用户访问
......@@ -31,10 +30,17 @@ public abstract class CipherManagerUserJaxrsFilter extends TokenFilter {
HttpToken httpToken = new HttpToken();
EffectivePerson effectivePerson = httpToken.who(request, response, Config.token().getCipher());
if (TokenType.anonymous.equals(effectivePerson.getTokenType())) {
/** 需要自己标志500 */
response.setStatus(500);
/** 401 Unauthorized 未登录访问被拒绝 */
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.setHeader("Content-Type", "application/json;charset=UTF-8");
response.getWriter().write(FilterTools.Application_Not_CipherManagerUser_Json);
ActionResult result = new ActionResult();
ExceptionUnauthorized e = new ExceptionUnauthorized();
result.error(e);
String message = e.getFormatMessage(result.getPrompt(), request.getHeader(ResponseFactory.Accept_Language));
if(StringUtils.isNotBlank(message)) {
result.setMessage(message);
}
response.getWriter().write(result.toJson());
} else {
chain.doFilter(request, response);
}
......
package com.x.base.core.project.jaxrs;
import javax.servlet.annotation.WebFilter;
@WebFilter(urlPatterns = { "/jaxrs/logger/*" }, asyncSupported = true)
public class LoggerJaxrsFilter extends CipherManagerJaxrsFilter {
}
......@@ -11,10 +11,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.FilterTools;
import com.x.base.core.project.http.HttpToken;
import com.x.base.core.project.http.TokenType;
import com.x.base.core.project.exception.ExceptionUnauthorized;
import com.x.base.core.project.http.*;
import org.apache.commons.lang3.StringUtils;
/**
* 必须由前台已经登陆的用户访问
......@@ -31,11 +30,18 @@ public abstract class ManagerUserJaxrsFilter extends TokenFilter {
HttpToken httpToken = new HttpToken();
EffectivePerson effectivePerson = httpToken.who(request, response, Config.token().getCipher());
if (TokenType.anonymous.equals(effectivePerson.getTokenType())) {
/** 需要自己标志500 */
response.setStatus(500);
/** 401 Unauthorized 未登录访问被拒绝 */
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.setHeader("Content-Type", "application/json;charset=UTF-8");
response.getWriter().write(FilterTools.Application_Not_ManagerUser_Json);
} else {
ActionResult result = new ActionResult();
ExceptionUnauthorized e = new ExceptionUnauthorized();
result.error(e);
String message = e.getFormatMessage(result.getPrompt(), request.getHeader(ResponseFactory.Accept_Language));
if(StringUtils.isNotBlank(message)) {
result.setMessage(message);
}
response.getWriter().write(result.toJson());
} else {
chain.doFilter(request, response);
}
} else {
......
......@@ -11,10 +11,10 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.FilterTools;
import com.x.base.core.project.http.HttpToken;
import com.x.base.core.project.http.TokenType;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionUnauthorized;
import com.x.base.core.project.http.*;
import org.apache.commons.lang3.StringUtils;
/**
* 必须由前台已经登陆的用户访问
......@@ -30,11 +30,30 @@ public abstract class UserJaxrsFilter extends TokenFilter {
if (!request.getMethod().equalsIgnoreCase("options")) {
HttpToken httpToken = new HttpToken();
EffectivePerson effectivePerson = httpToken.who(request, response, Config.token().getCipher());
if (!TokenType.user.equals(effectivePerson.getTokenType())) {
if (TokenType.anonymous.equals(effectivePerson.getTokenType())) {
/** 401 Unauthorized 未登录访问被拒绝 */
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.setHeader("Content-Type", "application/json;charset=UTF-8");
ActionResult result = new ActionResult();
ExceptionUnauthorized e = new ExceptionUnauthorized();
result.error(e);
String message = e.getFormatMessage(result.getPrompt(), request.getHeader(ResponseFactory.Accept_Language));
if(StringUtils.isNotBlank(message)) {
result.setMessage(message);
}
response.getWriter().write(result.toJson());
} if (!TokenType.user.equals(effectivePerson.getTokenType())) {
/** 需要自己标志500 */
response.setStatus(500);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.setHeader("Content-Type", "application/json;charset=UTF-8");
response.getWriter().write(FilterTools.Application_Not_User_Json);
ActionResult result = new ActionResult();
ExceptionAccessDenied e = new ExceptionAccessDenied(effectivePerson);
result.error(e);
String message = e.getFormatMessage(result.getPrompt(), request.getHeader(ResponseFactory.Accept_Language));
if(StringUtils.isNotBlank(message)) {
result.setMessage(message);
}
response.getWriter().write(result.toJson());
} else {
chain.doFilter(request, response);
}
......
......@@ -14,7 +14,6 @@ import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.jaxrs.logger.LoggerAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
......@@ -22,7 +21,7 @@ import com.x.base.core.project.logger.LoggerFactory;
@JaxrsDescribe("响应")
public class EchoAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(LoggerAction.class);
private static Logger logger = LoggerFactory.getLogger(EchoAction.class);
@JaxrsMethodDescribe(value = "获取应答.", action = ActionGet.class)
@GET
......
package com.x.base.core.project.jaxrs.logger;
import javax.servlet.ServletContext;
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.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
class ActionDebug extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionDebug.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, ServletContext servletContext) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
com.x.base.core.project.Context ctx = (com.x.base.core.project.Context) servletContext
.getAttribute(com.x.base.core.project.AbstractContext.class.getName());
logger.info("{} change logger level to DEBUG.", ctx.clazz().getName());
LoggerFactory.setLevelDebug();
result.setData(new Wo(true));
return result;
}
public static class Wo extends WrapBoolean {
public Wo(boolean value) {
super(value);
}
}
}
\ No newline at end of file
package com.x.base.core.project.jaxrs.logger;
import javax.servlet.ServletContext;
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.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
class ActionInfo extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionInfo.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, ServletContext servletContext) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
com.x.base.core.project.Context ctx = (com.x.base.core.project.Context) servletContext
.getAttribute(com.x.base.core.project.AbstractContext.class.getName());
logger.info("{} change logger level to INFO.", ctx.clazz().getName());
LoggerFactory.setLevelInfo();
result.setData(new Wo(true));
return result;
}
public static class Wo extends WrapBoolean {
public Wo(boolean value) {
super(value);
}
}
}
\ No newline at end of file
package com.x.base.core.project.jaxrs.logger;
import javax.servlet.ServletContext;
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.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
class ActionTrace extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionTrace.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, ServletContext servletContext) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
com.x.base.core.project.Context ctx = (com.x.base.core.project.Context) servletContext
.getAttribute(com.x.base.core.project.AbstractContext.class.getName());
logger.info("{} change logger level to TRACE.", ctx.clazz().getName());
LoggerFactory.setLevelTrace();
result.setData(new Wo(true));
return result;
}
public static class Wo extends WrapBoolean {
public Wo(boolean value) {
super(value);
}
}
}
\ No newline at end of file
package com.x.base.core.project.jaxrs.logger;
import javax.servlet.ServletContext;
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.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
class ActionWarn extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionWarn.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, ServletContext servletContext) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
com.x.base.core.project.Context ctx = (com.x.base.core.project.Context) servletContext
.getAttribute(com.x.base.core.project.AbstractContext.class.getName());
logger.info("{} change logger level to WARN.", ctx.clazz().getName());
LoggerFactory.setLevelWarn();
result.setData(new Wo(true));
return result;
}
public static class Wo extends WrapBoolean {
public Wo(boolean value) {
super(value);
}
}
}
\ No newline at end of file
package com.x.base.core.project.jaxrs.logger;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
abstract class BaseAction extends StandardJaxrsAction {
}
package com.x.base.core.project.jaxrs.logger;
import javax.servlet.ServletContext;
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.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("logger")
@JaxrsDescribe("日志操作")
public class LoggerAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(LoggerAction.class);
@GET
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
@JaxrsMethodDescribe(value = "获取当前日志级别.", action = ActionGet.class)
public void get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<ActionGet.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionGet().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@GET
@Path("trace")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
@JaxrsMethodDescribe(value = "设置日志级别为TRACE.", action = ActionTrace.class)
public void trace(@Suspended final AsyncResponse asyncResponse, @Context ServletContext servletContext,
@Context HttpServletRequest request) {
ActionResult<ActionTrace.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionTrace().execute(effectivePerson, servletContext);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@GET
@Path("debug")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
@JaxrsMethodDescribe(value = "设置日志级别为DEBUG.", action = ActionDebug.class)
public void debug(@Suspended final AsyncResponse asyncResponse, @Context ServletContext servletContext,
@Context HttpServletRequest request) {
ActionResult<ActionDebug.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDebug().execute(effectivePerson, servletContext);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@GET
@Path("info")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
@JaxrsMethodDescribe(value = "设置日志级别为INFO", action = ActionInfo.class)
public void info(@Suspended final AsyncResponse asyncResponse, @Context ServletContext servletContext,
@Context HttpServletRequest request) {
ActionResult<ActionInfo.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionInfo().execute(effectivePerson, servletContext);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@GET
@Path("warn")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
@JaxrsMethodDescribe(value = "设置日志级别为WARN", action = ActionWarn.class)
public void warn(@Suspended final AsyncResponse asyncResponse, @Context ServletContext servletContext,
@Context HttpServletRequest request) {
ActionResult<ActionWarn.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionWarn().execute(effectivePerson, servletContext);
} 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.base.core.project.logger;
import java.io.PrintStream;
import java.net.InetAddress;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import com.x.base.core.project.message.MessageConnector;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.helpers.MessageFormatter;
import com.x.base.core.project.config.Config;
public class Audit {
private Date start;
private String className = "";
private String person = "";
private String remoteAddress = "";
private String uri = "";
private String userAgent = "";
private String userId = "";
private String userName = "";
protected Audit(String person, String remoteAddress, String uri, String userAgent, String className) {
this.start = new Date();
this.person = Objects.toString(person, "");
if(person==null || person.indexOf("@") == -1){
userId = Objects.toString(person, "");
userName = Objects.toString(person, "");
}else{
String persons[] = person.split("@");
userId = persons[1];
userName = persons[0];
}
this.remoteAddress = Objects.toString(remoteAddress, "");
this.uri = Objects.toString(uri, "");
this.userAgent = Objects.toString(userAgent, "");
this.className = Objects.toString(className, "");
}
public void log1() throws Exception {
this.log1("");
}
/**
* 审计日志
* @param message
* @param os
* @throws Exception
*/
public void log1(String message, Object... os){
try {
if (Config.logLevel().audit().enable()) {
Date end = new Date();
long elapsed = end.getTime() - start.getTime();
PrintStream stream = (PrintStream) Config.resource(Config.RESOURCE_AUDITLOGPRINTSTREAM);
stream.printf("%tF %tT,,,%d,,,%s,,,%s,,,%s,,,%s,,,%s,,,%s%n", end, end, elapsed, this.person,
this.remoteAddress, this.uri, this.userAgent, this.className,
MessageFormatter.arrayFormat(Objects.toString(message, ""), os).getMessage());
}
} catch (Exception e) {
System.out.println("审计日志打印异常"+e.getMessage());
}
}
/**
* 审计日志格式:
* 默认时间戳之类的信息|日志版本号|请求ID|请求深度|请求链|登录账号|员工工号
* |系统归属|系统名称|模块名称|表单类型|操作名称|是否统计上报|扩展信息|时间戳|耗时|请求结果|主机IP
* |主机名|终端类型|终端IP |终端型号|终端IMEI|错误堆栈
* @throws Exception
*/
public void log(String person, String op){
try {
if (Config.logLevel().audit().enable()) {
if(person!=null) {
this.person = person;
if(person.indexOf("@") == -1){
userId = person;
userName = person;
}else{
String persons[] = person.split("@");
userId = persons[1];
userName = persons[0];
}
}
Date end = new Date();
long elapsed = end.getTime() - start.getTime();
InetAddress addr = InetAddress.getLocalHost();
String hostAddress = addr.getHostAddress();
String hostName = addr.getHostName();
String system = Objects.toString(Config.logLevel().audit().getSystem(), "OA");
String systemName = Objects.toString(Config.logLevel().audit().getSystemName(), "OA系统");
String extend1 = Objects.toString(Config.logLevel().audit().getExtend1(), "");
/*String mode = this.uri;
if(this.uri!=null) {
String[] uris = this.uri.split("/");
if (uris.length > 1) {
mode = uris[1];
}
}*/
PrintStream stream = (PrintStream) Config.resource(Config.RESOURCE_AUDITLOGPRINTSTREAM);
String auditLog = String.format("%tF %tT|2.0||1||%s|%s|%s|%s|%s||%s|true|%s|%d|%d|true|%s|%s|%s|%s|%s||", end, end, this.userId,
this.userId, systemName, system, this.uri, op, this.getParameter(op, system, extend1), end.getTime(), elapsed, hostAddress, hostName,
getTerminal(), this.remoteAddress, this.userAgent);
stream.println(auditLog);
HashMap<String, String> map = new HashMap<>();
map.put("auditLog", auditLog);
MessageConnector.send(MessageConnector.TYPE_AUDIT_LOG, op, this.person, map);
}
} catch (Exception e) {
System.out.println("审计日志打印异常"+e.getMessage());
}
}
public String getTerminal(){
if(StringUtils.isNotBlank(this.userAgent)) {
String userAgent = this.userAgent.toLowerCase();
if (userAgent.indexOf("micromessenger") != -1) {
//微信
return "MOA";
} else if (userAgent.indexOf("android") != -1) {
//安卓
return "MOA";
} else if (userAgent.indexOf("iphone") != -1 || userAgent.indexOf("ipad") != -1 || userAgent.indexOf("ipod") != -1) {
//苹果
return "MOA";
} else {
//电脑
return "PC";
}
}
return "PC";
}
public String getParameter(String op,String system,String extend1){
StringBuffer parameter =new StringBuffer();
if("登录".equals(op)){
parameter.append("LOG_RESULT=0&interfacename=").append(system).append("_")
.append(getTerminal()).append("_LOGIN&errorCode=ok&extend1=").append(extend1).append("&LOGIN_ENTRY=0");
}else if("注销".equals(op)){
parameter.append("LOG_RESULT=0&interfacename=").append(system).append("_")
.append(getTerminal()).append("_LOGOUT&errorCode=ok&extend1=").append(extend1).append("&LOGOUT_ENTRY=0");
}else{
parameter.append("LOG_RESULT=0&interfacename=").append(system).append("_")
.append(getTerminal()).append("_OPERATION&errorCode=ok&extend1=").append(extend1);
}
return parameter.toString();
}
}
package com.x.base.core.project.logger;
/**
* Holds the results of formatting done by {@link MessageFormatter}.
*
......@@ -8,32 +7,32 @@ package com.x.base.core.project.logger;
*/
public class FormattingTuple {
static public FormattingTuple NULL = new FormattingTuple(null);
public static FormattingTuple NULL = new FormattingTuple(null);
private String message;
private Throwable throwable;
private Object[] argArray;
private String message;
private Throwable throwable;
private Object[] argArray;
public FormattingTuple(String message) {
this(message, null, null);
}
public FormattingTuple(String message) {
this(message, null, null);
}
public FormattingTuple(String message, Object[] argArray, Throwable throwable) {
this.message = message;
this.throwable = throwable;
this.argArray = argArray;
}
public FormattingTuple(String message, Object[] argArray, Throwable throwable) {
this.message = message;
this.throwable = throwable;
this.argArray = argArray;
}
public String getMessage() {
return message;
}
public String getMessage() {
return message;
}
public Object[] getArgArray() {
return argArray;
}
public Object[] getArgArray() {
return argArray;
}
public Throwable getThrowable() {
return throwable;
}
public Throwable getThrowable() {
return throwable;
}
}
......@@ -3,14 +3,13 @@ package com.x.base.core.project.logger;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.connection.CipherConnectionAction;
......@@ -22,10 +21,11 @@ import com.x.base.core.project.tools.StringTools;
public class Logger {
public static Gson gson = XGsonBuilder.instance();
private final org.slf4j.Logger internalLogger;
Logger(String name) {
this.name = name;
internalLogger = org.slf4j.LoggerFactory.getLogger(name);
}
private String name;
......@@ -34,229 +34,214 @@ public class Logger {
return this.name;
}
static int level = 20;
final static int TRACE_INT = 00;
final static int DEBUG_INT = 10;
final static int INFO_INT = 20;
final static int WARN_INT = 30;
final static int ERROR_INT = 40;
public final static String PRINT = "PRINT";
public final static String TRACE = "TRACE";
public final static String DEBUG = "DEBUG";
public final static String INFO = "INFO";
public final static String WARN = "WARN";
public final static String ERROR = "ERROR";
private final static String PARAMETER_ID = "id";
private final static String PARAMETER_VERSION = "version";
private final static String PARAMETER_OCCURTIME = "occurTime";
private final static String PARAMETER_LOGGERNAME = "loggerName";
private final static String PARAMETER_EXCEPTIONCLASS = "exceptionClass";
private final static String PARAMETER_MESSAGE = "message";
private final static String PARAMETER_STACKTRACE = "stackTrace";
private final static String PARAMETER_PERSON = "person";
private final static String PARAMETER_REQUESTURL = "requestUrl";
private final static String PARAMETER_REQUESTMETHOD = "requestMethod";
private final static String PARAMETER_REQUESTREMOTEADDR = "requestRemoteAddr";
private final static String PARAMETER_REQUESTHOST = "requestRemoteHost";
private final static String PARAMETER_REQUESTHEAD = "requestHead";
private final static String PARAMETER_REQUESTBODY = "requestBody";
private final static String PARAMETER_REQUESTBODYLENGTH = "requestBodyLength";
private final static String HTTPMESSAGEFORMAT = " > person:{}, method:{}, request:{}, remote host:{} address:{}, head:{}, body:{}.";
public boolean isDebug(EffectivePerson effectivePerson) {
if (null != effectivePerson && BooleanUtils.isTrue(effectivePerson.getDebugger())) {
return true;
} else {
return this.isDebug();
}
private static final String PARAMETER_ID = "id";
private static final String PARAMETER_VERSION = "version";
private static final String PARAMETER_OCCURTIME = "occurTime";
private static final String PARAMETER_LOGGERNAME = "loggerName";
private static final String PARAMETER_EXCEPTIONCLASS = "exceptionClass";
private static final String PARAMETER_MESSAGE = "message";
private static final String PARAMETER_STACKTRACE = "stackTrace";
private static final String PARAMETER_PERSON = "person";
private static final String PARAMETER_REQUESTURL = "requestUrl";
private static final String PARAMETER_REQUESTMETHOD = "requestMethod";
private static final String PARAMETER_REQUESTREMOTEADDR = "requestRemoteAddr";
private static final String PARAMETER_REQUESTHOST = "requestRemoteHost";
private static final String PARAMETER_REQUESTHEAD = "requestHead";
private static final String PARAMETER_REQUESTBODY = "requestBody";
private static final String PARAMETER_REQUESTBODYLENGTH = "requestBodyLength";
private static final String ID_TAG = "id:";
private static final String NAME_TAG = ", name:";
private static final String MESSAGE_TAG = ", message:";
private static final String EXCEPTION_TAG = ", exception:";
private static final String HTTPMESSAGEFORMAT = "person:{}, method:{}, request:{}, remoteHost:{}, emoteAddr:{}, head:{}, body:{}";
public boolean isTraceEnabled() {
return internalLogger.isTraceEnabled();
}
public boolean isDebug() {
if (level <= DEBUG_INT) {
return true;
}
return false;
public boolean isDebugEnabled() {
return internalLogger.isDebugEnabled();
}
public void print(String message, Object... os) {
this.log(PRINT, message, os);
public boolean isInfoEnabled() {
return internalLogger.isInfoEnabled();
}
public boolean isWarnEnabled() {
return internalLogger.isWarnEnabled();
}
public boolean isErrorEnabled() {
return internalLogger.isErrorEnabled();
}
@Deprecated
public void debug(EffectivePerson noUse, String message, Object... os) {
debug(message, os);
}
@Deprecated
public void debug(boolean noUse, String message, Object... os) {
debug(message, os);
}
public void trace(String message, Object... os) {
if (level <= TRACE_INT) {
this.log(TRACE, message, os);
if (internalLogger.isTraceEnabled()) {
internalLogger.trace(message, os);
}
}
public void debug(EffectivePerson effectivePerson, String message, Object... os) {
if (null != effectivePerson && BooleanUtils.isTrue(effectivePerson.getDebugger())) {
this.log(DEBUG, message, os);
} else {
this.debug(message, os);
public void trace(String message, Supplier<?>... suppliers) {
if (internalLogger.isTraceEnabled()) {
internalLogger.trace(message, getAll(suppliers));
}
}
public void debug(boolean debugger, String message, Object... os) {
if (BooleanUtils.isTrue(debugger)) {
this.log(DEBUG, message, os);
} else {
this.debug(message, os);
public void debug(String message, Object... os) {
if (internalLogger.isDebugEnabled()) {
internalLogger.debug(message, os);
}
}
public void debug(String message, Object... os) {
if (level <= DEBUG_INT) {
this.log(DEBUG, message, os);
public void debug(String message, Supplier<?>... suppliers) {
if (internalLogger.isDebugEnabled()) {
internalLogger.debug(message, getAll(suppliers));
}
}
public void info(String message, Object... os) {
if (level <= INFO_INT) {
this.log(INFO, message, os);
if (internalLogger.isInfoEnabled()) {
internalLogger.info(message, os);
}
}
public void info(String message, Supplier<?>... suppliers) {
if (internalLogger.isInfoEnabled()) {
internalLogger.info(message, getAll(suppliers));
}
}
public void warn(String message, Object... os) {
if (level <= WARN_INT) {
String id = StringTools.uniqueToken();
StringBuilder sb = this.create(WARN, id);
String str = format(message, os);
sb.append(str);
System.out.println(sb.toString());
String loggerName = this.getName();
Thread thread = new Thread(new Runnable() {
public void run() {
try {
Map<String, Object> parameters = new HashMap<>();
parameters.put(PARAMETER_ID, id);
parameters.put(PARAMETER_VERSION, Config.version());
parameters.put(PARAMETER_OCCURTIME, DateTools.now());
parameters.put(PARAMETER_LOGGERNAME, loggerName);
parameters.put(PARAMETER_MESSAGE, str);
String url = Config.url_x_program_center_jaxrs("warnlog");
CipherConnectionAction.post(false, url, parameters);
} catch (Exception e) {
e.printStackTrace();
}
}
});
thread.start();
String id = StringTools.uniqueToken();
String formattedMessage = format(message, os);
String text = this.message(id, formattedMessage);
if (internalLogger.isWarnEnabled()) {
internalLogger.warn(text);
}
String loggerName = this.getName();
new Thread(() -> {
try {
Map<String, Object> parameters = new HashMap<>();
parameters.put(PARAMETER_ID, id);
parameters.put(PARAMETER_VERSION, Config.version());
parameters.put(PARAMETER_OCCURTIME, DateTools.now());
parameters.put(PARAMETER_LOGGERNAME, loggerName);
parameters.put(PARAMETER_MESSAGE, formattedMessage);
String url = Config.url_x_program_center_jaxrs("warnlog");
CipherConnectionAction.post(false, url, parameters);
} catch (Exception e) {
e.printStackTrace();
}
}, Logger.class.getName() + "-warn").start();
}
public int level() {
return level;
public void warn(String message, Supplier<?>... suppliers) {
warn(message, getAll(suppliers));
}
public void error(Exception e) {
String id = StringTools.uniqueToken();
StringBuilder sb = this.create(ERROR, id);
sb.append(e.getClass().getName());
sb.append("[");
sb.append(e.getMessage());
sb.append("]");
String stackTraceString = ExceptionUtils.getStackTrace(e);
if (!(e instanceof PromptException)) {
sb.append(System.lineSeparator());
sb.append(stackTraceString);
String formattedMessage = this.message(id, e);
if (internalLogger.isErrorEnabled()) {
internalLogger.error(formattedMessage, e);
}
System.err.println(sb.toString());
String loggerName = this.getName();
Thread thread = new Thread(new Runnable() {
public void run() {
try {
Map<String, Object> parameters = new HashMap<>();
parameters.put(PARAMETER_ID, id);
parameters.put(PARAMETER_VERSION, Config.version());
parameters.put(PARAMETER_OCCURTIME, DateTools.now());
parameters.put(PARAMETER_LOGGERNAME, loggerName);
parameters.put(PARAMETER_EXCEPTIONCLASS, e.getClass().getName());
parameters.put(PARAMETER_MESSAGE, e.getMessage());
parameters.put(PARAMETER_STACKTRACE, stackTraceString);
if (e instanceof PromptException) {
String url = Config.url_x_program_center_jaxrs("prompterrorlog");
CipherConnectionAction.post(false, url, parameters);
} else {
String url = Config.url_x_program_center_jaxrs("unexpectederrorlog");
CipherConnectionAction.post(false, url, parameters);
}
} catch (Exception e) {
e.printStackTrace();
new Thread(() -> {
try {
Map<String, Object> parameters = new HashMap<>();
parameters.put(PARAMETER_ID, id);
parameters.put(PARAMETER_VERSION, Config.version());
parameters.put(PARAMETER_OCCURTIME, DateTools.now());
parameters.put(PARAMETER_LOGGERNAME, this.getName());
parameters.put(PARAMETER_EXCEPTIONCLASS, e.getClass().getName());
parameters.put(PARAMETER_MESSAGE, e.getMessage());
parameters.put(PARAMETER_STACKTRACE, ExceptionUtils.getStackTrace(e));
if (e instanceof PromptException) {
String url = Config.url_x_program_center_jaxrs("prompterrorlog");
CipherConnectionAction.post(false, url, parameters);
} else {
String url = Config.url_x_program_center_jaxrs("unexpectederrorlog");
CipherConnectionAction.post(false, url, parameters);
}
} catch (Exception ex) {
ex.printStackTrace();
}
});
thread.start();
}, Logger.class.getName() + "-error").start();
}
public void error(Exception e, EffectivePerson effectivePerson, HttpServletRequest request, JsonElement body) {
String id = StringTools.uniqueToken();
StringBuilder sb = this.create(ERROR, id);
sb.append(e.getMessage());
String headString = this.headToString(request);
String bodyString = this.bodyToString(body);
String requestUrl = request.getRequestURL().toString()
+ (StringUtils.isEmpty(request.getQueryString()) ? "" : "?" + request.getQueryString());
String stackTraceString = ExceptionUtils.getStackTrace(e);
Object[] arr = new String[] { effectivePerson.getDistinguishedName(), request.getMethod(), requestUrl,
request.getRemoteHost(), request.getRemoteAddr(), headString, bodyString };
sb.append(format(HTTPMESSAGEFORMAT, arr));
if (!(e instanceof PromptException)) {
sb.append(System.lineSeparator());
sb.append(stackTraceString);
String requestUrl = url(request);
String formattedMessage = message(id, e, requestToString(effectivePerson, request, headString, bodyString));
if (internalLogger.isErrorEnabled()) {
internalLogger.error(this.message(id, e, formattedMessage), e);
}
System.err.println(sb.toString());
String loggerName = this.getName();
Thread thread = new Thread(new Runnable() {
public void run() {
try {
Map<String, Object> parameters = new HashMap<>();
parameters.put(PARAMETER_ID, id);
parameters.put(PARAMETER_VERSION, Config.version());
parameters.put(PARAMETER_OCCURTIME, DateTools.now());
parameters.put(PARAMETER_LOGGERNAME, loggerName);
parameters.put(PARAMETER_EXCEPTIONCLASS, e.getClass().getName());
parameters.put(PARAMETER_MESSAGE, e.getMessage());
parameters.put(PARAMETER_STACKTRACE, stackTraceString);
parameters.put(PARAMETER_PERSON,
(null == effectivePerson) ? null : effectivePerson.getDistinguishedName());
parameters.put(PARAMETER_REQUESTURL, requestUrl);
parameters.put(PARAMETER_REQUESTMETHOD, request.getMethod());
parameters.put(PARAMETER_REQUESTREMOTEADDR, request.getRemoteAddr());
parameters.put(PARAMETER_REQUESTHOST, request.getRemoteHost());
parameters.put(PARAMETER_REQUESTHEAD, headString);
parameters.put(PARAMETER_REQUESTBODY, bodyString);
parameters.put(PARAMETER_REQUESTBODYLENGTH, bodyString.length());
if (e instanceof PromptException) {
String url = Config.url_x_program_center_jaxrs("prompterrorlog");
CipherConnectionAction.post(false, url, parameters);
} else {
String url = Config.url_x_program_center_jaxrs("unexpectederrorlog");
CipherConnectionAction.post(false, url, parameters);
}
} catch (Exception e) {
e.printStackTrace();
new Thread(() -> {
try {
Map<String, Object> parameters = new HashMap<>();
parameters.put(PARAMETER_ID, id);
parameters.put(PARAMETER_VERSION, Config.version());
parameters.put(PARAMETER_OCCURTIME, DateTools.now());
parameters.put(PARAMETER_LOGGERNAME, getName());
parameters.put(PARAMETER_EXCEPTIONCLASS, e.getClass().getName());
parameters.put(PARAMETER_MESSAGE, e.getMessage());
parameters.put(PARAMETER_STACKTRACE, ExceptionUtils.getStackTrace(e));
parameters.put(PARAMETER_PERSON,
(null == effectivePerson) ? null : effectivePerson.getDistinguishedName());
parameters.put(PARAMETER_REQUESTURL, requestUrl);
parameters.put(PARAMETER_REQUESTMETHOD, request.getMethod());
parameters.put(PARAMETER_REQUESTREMOTEADDR, request.getRemoteAddr());
parameters.put(PARAMETER_REQUESTHOST, request.getRemoteHost());
parameters.put(PARAMETER_REQUESTHEAD, headString);
parameters.put(PARAMETER_REQUESTBODY, bodyString);
parameters.put(PARAMETER_REQUESTBODYLENGTH, bodyString.length());
if (e instanceof PromptException) {
String url = Config.url_x_program_center_jaxrs("prompterrorlog");
CipherConnectionAction.post(false, url, parameters);
} else {
String url = Config.url_x_program_center_jaxrs("unexpectederrorlog");
CipherConnectionAction.post(false, url, parameters);
}
} catch (Exception ex) {
ex.printStackTrace();
}
});
thread.start();
}, Logger.class.getName() + "-error").start();
}
private void log(String logLevel, String message, Object... os) {
StringBuilder sb = this.create(logLevel, null);
sb.append(format(message, os));
System.out.println(sb.toString());
private String message(String id, String message) {
StringBuilder o = new StringBuilder();
o.append(ID_TAG).append(StringUtils.isEmpty(id) ? Thread.currentThread().getName() : id).append(NAME_TAG)
.append(this.name).append(MESSAGE_TAG).append(message).append(".");
return o.toString();
}
private StringBuilder create(String logLevel, String id) {
private String message(String id, Throwable th) {
StringBuilder o = new StringBuilder();
o.append(DateTools.nowMs()).append(" ").append(logLevel);
o.append(" [").append(StringUtils.isEmpty(id) ? Thread.currentThread().getName() : id).append("] ");
o.append(this.name).append(" - ");
return o;
o.append(ID_TAG).append(StringUtils.isEmpty(id) ? Thread.currentThread().getName() : id).append(NAME_TAG)
.append(this.name).append(MESSAGE_TAG).append(th.getMessage()).append(EXCEPTION_TAG)
.append(th.getClass().getName()).append(".");
return o.toString();
}
private String message(String id, Throwable th, String request) {
StringBuilder o = new StringBuilder();
o.append(ID_TAG).append(StringUtils.isEmpty(id) ? Thread.currentThread().getName() : id).append(NAME_TAG)
.append(this.name).append(MESSAGE_TAG).append(th.getMessage()).append(EXCEPTION_TAG)
.append(th.getClass().getName()).append(", ").append(request).append(".");
return o.toString();
}
private static String format(String message, Object... os) {
......@@ -275,9 +260,9 @@ public class Logger {
Enumeration<String> en = request.getHeaderNames();
StringBuilder sb = new StringBuilder();
while (en.hasMoreElements()) {
String name = en.nextElement();
String value = request.getHeader(name);
sb.append(name).append(":").append(value);
String n = en.nextElement();
String v = request.getHeader(n);
sb.append(n).append(":").append(v);
if (en.hasMoreElements()) {
sb.append("\n");
}
......@@ -285,10 +270,31 @@ public class Logger {
return sb.toString();
}
public Audit audit(EffectivePerson effectivePerson) {
Audit o = new Audit(effectivePerson.getDistinguishedName(), effectivePerson.getRemoteAddress(),
effectivePerson.getUri(), effectivePerson.getUserAgent(), this.name);
return o;
public void print(String message, Object... os) {
System.out.println(format(message, os));
}
private String requestToString(EffectivePerson effectivePerson, HttpServletRequest request, String headString,
String bodyString) {
return format(HTTPMESSAGEFORMAT, effectivePerson.getDistinguishedName(), request.getMethod(), this.url(request),
request.getRemoteHost(), request.getRemoteAddr(), headString, bodyString);
}
private String url(HttpServletRequest request) {
return request.getRequestURL().toString()
+ (StringUtils.isEmpty(request.getQueryString()) ? "" : "?" + request.getQueryString());
}
private static Object[] getAll(final Supplier<?>... suppliers) {
if (suppliers == null) {
return new Object[0];
}
final Object[] result = new Object[suppliers.length];
for (int i = 0; i < result.length; i++) {
Supplier<?> supplier = suppliers[i];
result[i] = (supplier == null) ? null : supplier.get();
}
return result;
}
}
\ No newline at end of file
package com.x.base.core.project.logger;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.tools.DateTools;
public class LoggerFactory {
private LoggerFactory() {
}
public static Logger getLogger(Class<?> clz) {
Logger logger = new Logger(clz.getName());
return logger;
}
public static void setLevelTrace() {
Logger.level = Logger.TRACE_INT;
}
public static void setLevelDebug() {
Logger.level = Logger.DEBUG_INT;
}
public static void setLevelInfo() {
Logger.level = Logger.INFO_INT;
}
public static void setLevelWarn() {
Logger.level = Logger.WARN_INT;
}
public static void setLevel(String str) {
if (StringUtils.equalsIgnoreCase(Logger.ERROR, str)) {
Logger.level = Logger.ERROR_INT;
}
if (StringUtils.equalsIgnoreCase(Logger.WARN, str)) {
Logger.level = Logger.WARN_INT;
}
if (StringUtils.equalsIgnoreCase(Logger.INFO, str)) {
Logger.level = Logger.INFO_INT;
}
if (StringUtils.equalsIgnoreCase(Logger.DEBUG, str)) {
Logger.level = Logger.DEBUG_INT;
}
if (StringUtils.equalsIgnoreCase(Logger.TRACE, str)) {
Logger.level = Logger.TRACE_INT;
}
}
public static String getLevel() {
switch (Logger.level) {
case Logger.TRACE_INT:
return Logger.TRACE;
case Logger.DEBUG_INT:
return Logger.DEBUG;
case Logger.WARN_INT:
return Logger.WARN;
default:
return Logger.INFO;
}
}
public static void print(Class<?> cls, String message, Object... os) {
StringBuilder o = new StringBuilder();
o.append(DateTools.now()).append(" ").append(LoggerFactory.class.getSimpleName());
o.append(" [").append(Thread.currentThread().getName()).append("] ");
o.append(cls.getName()).append(" - ");
o.append(MessageFormatter.arrayFormat(message, os).getMessage());
System.out.println(o.toString());
}
public static void print(String message, Object... os) {
print(LoggerFactory.class, message, os);
return new Logger(clz.getName());
}
}
\ No newline at end of file
......@@ -80,6 +80,15 @@ public class OrganizationDefinition {
public final static String ServiceManager = "ServiceManager";
public final static String ServiceManager_description = "服务管理员(系统角色),可以进行服务管理的接口和代理配置。";
public final static String SystemManager = "SystemManager";
public final static String SystemManager_description = "三元管理中的系统管理员(系统角色),负责为系统添加用户和系统运行维护工作。";
public final static String SecurityManager = "SecurityManager";
public final static String SecurityManager_description = "三元管理中的安全管理员(系统角色),负责权限设定,负责系统审计日志、用户和系统管理员操作行为的审查分析。";
public final static String AuditManager = "AuditManager";
public final static String AuditManager_description = "三元管理中的安全审计员(系统角色),负责对系统管理员、安全管理员的操作行为进行审计、跟踪。";
public final static String RoleDefinitionSuffix = "SystemRole";
public final static Pattern person_distinguishedName_pattern = Pattern.compile("^(.+)\\@(\\S+)\\@P$");
......@@ -100,11 +109,18 @@ public class OrganizationDefinition {
public final static Pattern distinguishedName_pattern = Pattern.compile("^(.+)\\@(\\S+)\\@(P|PA|G|R|I|U|UA|UD)$");
public final static List<String> DEFAULTROLES = new UnmodifiableList<String>(ListTools.toList(Manager,
public final static List<String> DEFAULTROLES = new UnmodifiableList<String>(ListTools.toList(Manager,SystemManager,SecurityManager,AuditManager,
AttendanceManager, OrganizationManager, PersonManager, GroupManager, UnitManager, RoleManager,
ProcessPlatformManager, ProcessPlatformCreator, MeetingManager, MeetingViewer, PortalManager, BBSManager,
CMSManager, OKRManager, CRMManager,TeamWorkManager, QueryManager, MessageManager, HotPictureManager, SearchPrivilege, FileManager, ServiceManager));
public static String toDistinguishedName(String name) {
if (!StringUtils.contains(name, "@")) {
name = name + "@" + name + RoleDefinitionSuffix + "@R";
}
return name;
}
public static String name(String distinguishedName) {
if (StringUtils.contains(distinguishedName, "@")) {
return StringUtils.substringBefore(distinguishedName, "@");
......
package com.x.base.core.project.tools;
import static java.util.Locale.ENGLISH;
import java.io.ByteArrayInputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
......@@ -30,9 +28,8 @@ import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.slf4j.helpers.MessageFormatter;
import com.alibaba.druid.sql.visitor.functions.Char;
import com.x.base.core.project.logger.MessageFormatter;
public class StringTools {
......
......@@ -27,7 +27,7 @@ public class URLTools {
*/
public static String encode(String str) {
try {
return URLEncoder.encode(str, StandardCharsets.UTF_8);
return URLEncoder.encode(str, StandardCharsets.UTF_8.name());
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -6,8 +6,7 @@ import com.x.base.core.project.annotation.ModuleType;
@Module(type = ModuleType.ASSEMBLE, category = ModuleCategory.OFFICIAL, name = "极光推送服务模块",
packageName = "com.x.jpush.assemble.control",
containerEntities = { "com.x.jpush.core.entity.SampleEntityClassName" },
storeJars = { "x_organization_core_entity", "x_organization_core_express" },
customJars = { "x_jpush_core_entity" })
containerEntities = { "com.x.jpush.core.entity.SampleEntityClassName","com.x.jpush.core.entity.PushDevice" },
storeJars = { "x_organization_core_entity", "x_organization_core_express", "x_jpush_core_entity" })
public class x_jpush_assemble_control extends Deployable {
}
......@@ -7,7 +7,7 @@
<parent>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.3</version>
<version>6.4</version>
</parent>
<artifactId>x_bbs_assemble_control</artifactId>
<packaging>war</packaging>
......
......@@ -2,18 +2,21 @@ package com.x.bbs.assemble.control;
import java.util.List;
import com.x.bbs.assemble.control.schedule.*;
import org.apache.commons.lang3.BooleanUtils;
import com.x.base.core.project.Context;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.message.MessageConnector;
import com.x.base.core.project.tools.ListTools;
import com.x.bbs.assemble.control.queue.QueueNewReplyNotify;
import com.x.bbs.assemble.control.queue.QueueNewSubjectNotify;
import com.x.bbs.assemble.control.schedule.MarketSubjectTypeTask;
import com.x.bbs.assemble.control.schedule.SubjectReplyTotalStatisticTask;
import com.x.bbs.assemble.control.schedule.SubjectTotalStatisticTask;
import com.x.bbs.assemble.control.schedule.UserCountTodaySetZeroTask;
import com.x.bbs.assemble.control.schedule.UserSubjectReplyPermissionStatisticTask;
import com.x.bbs.assemble.control.service.BBSConfigSettingService;
import com.x.bbs.assemble.control.service.BBSForumInfoServiceAdv;
import com.x.bbs.assemble.control.service.BBSPermissionInfoService;
......@@ -42,7 +45,6 @@ public class ThisApplication {
public static void init() throws Exception {
try {
CacheManager.init(context.clazz().getSimpleName());
LoggerFactory.setLevel(Config.logLevel().x_bbs_assemble_control());
CONFIG_BBS_ANONYMOUS_PERMISSION = (new BBSConfigSettingService())
.getValueWithConfigCode("BBS_ANONYMOUS_PERMISSION");
initAllSystemConfig();
......@@ -52,7 +54,7 @@ public class ThisApplication {
context.schedule(SubjectTotalStatisticTask.class, "0 0 1 * * ?"); // 每天凌晨一点执行
context.schedule(UserCountTodaySetZeroTask.class, "0 1 0 * * ?"); // 每天凌晨执行
context.schedule(MarketSubjectTypeTask.class, "0 0 1 * * ?"); // 每天凌晨一点执行
//context.schedule(MarketSubjectTypeTask.class, "* 0/05 * * * ? "); // 每天凌晨一点执行
// context.schedule(MarketSubjectTypeTask.class, "* 0/05 * * * ? "); // 每天凌晨一点执行
context.schedule(SubjectReplyTotalStatisticTask.class, "0 40 * * * ?");
context.schedule(UserSubjectReplyPermissionStatisticTask.class, "0 0/30 * * * ?");
} catch (Exception e) {
......
......@@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletRequest;
import com.x.base.core.project.cache.Cache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.tools.ListTools;
import com.x.base.core.project.tools.MD5Tool;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
......@@ -63,7 +64,7 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
}
if( check ) {
Cache.CacheKey cacheKey = new Cache.CacheKey( this.getClass(), effectivePerson.getDistinguishedName(), isBBSManager, count, page);
Cache.CacheKey cacheKey = new Cache.CacheKey( this.getClass(), effectivePerson.getDistinguishedName(), MD5Tool.getMD5Str(gson.toJson(wrapIn)), isBBSManager, count, page);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey );
if( optional.isPresent() ){
ActionResult<List<Wo>> result_cache = (ActionResult<List<Wo>>) optional.get();
......
......@@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletRequest;
import com.x.base.core.project.cache.Cache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.tools.MD5Tool;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
......@@ -62,7 +63,7 @@ public class ActionSubjectListForPage extends BaseAction {
}
if( check ) {
Cache.CacheKey cacheKey = new Cache.CacheKey( this.getClass(), effectivePerson.getDistinguishedName(),isBBSManager,page,count);
Cache.CacheKey cacheKey = new Cache.CacheKey( this.getClass(), effectivePerson.getDistinguishedName(), MD5Tool.getMD5Str(gson.toJson(wrapIn)), isBBSManager, page, count);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey );
if( optional.isPresent() ){
ActionResult<List<Wo>> result_cache = (ActionResult<List<Wo>>) optional.get();
......
......@@ -13,6 +13,7 @@ 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.base.core.project.tools.ListTools;
import com.x.base.core.project.tools.MD5Tool;
import com.x.base.core.project.tools.SortTools;
import com.x.base.core.project.x_bbs_assemble_control;
import com.x.bbs.assemble.control.ThisApplication;
......@@ -65,7 +66,7 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
}
if( check ) {
Cache.CacheKey cacheKey = new Cache.CacheKey( this.getClass(), effectivePerson.getDistinguishedName(),isBBSManager,page,count);
Cache.CacheKey cacheKey = new Cache.CacheKey( this.getClass(), effectivePerson.getDistinguishedName(), MD5Tool.getMD5Str(gson.toJson(wrapIn)) ,isBBSManager,page,count);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey );
if( optional.isPresent() ){
ActionResult<List<Wo>> result_cache = (ActionResult<List<Wo>>) optional.get();
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.3</version>
<version>6.4</version>
</parent>
<artifactId>x_bbs_core_entity</artifactId>
<packaging>jar</packaging>
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.3</version>
<version>6.4</version>
</parent>
<artifactId>x_calendar_assemble_control</artifactId>
<packaging>war</packaging>
......
......@@ -6,9 +6,7 @@ import org.apache.commons.lang3.BooleanUtils;
import com.x.base.core.project.Context;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.message.MessageConnector;
import com.x.base.core.project.tools.ListTools;
import com.x.calendar.assemble.control.schedule.AlarmTrigger;
......@@ -33,7 +31,6 @@ public class ThisApplication {
public static void init() throws Exception {
try {
CacheManager.init(context.clazz().getSimpleName());
LoggerFactory.setLevel(Config.logLevel().x_calendar_assemble_control());
MessageConnector.start(context());
// 每30秒检查一次需要推送的消息
context.schedule(AlarmTrigger.class, "0/30 * * * * ?");
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.3</version>
<version>6.4</version>
</parent>
<artifactId>x_calendar_core_entity</artifactId>
<packaging>jar</packaging>
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.3</version>
<version>6.4</version>
</parent>
<artifactId>x_cms_assemble_control</artifactId>
<packaging>war</packaging>
......
......@@ -5,8 +5,6 @@ import java.util.concurrent.ConcurrentMap;
import com.x.base.core.project.Context;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.message.MessageConnector;
import com.x.cms.assemble.control.queue.DataImportStatus;
import com.x.cms.assemble.control.queue.QueueBatchOperation;
......@@ -16,7 +14,6 @@ import com.x.cms.assemble.control.queue.QueueDocumentUpdate;
import com.x.cms.assemble.control.queue.QueueDocumentViewCountUpdate;
import com.x.cms.assemble.control.queue.QueueSendDocumentNotify;
import com.x.cms.assemble.control.timertask.Timertask_BatchOperationTask;
import com.x.cms.assemble.control.timertask.Timertask_CheckDocumentReviewStatus;
import com.x.cms.assemble.control.timertask.Timertask_InitOperationRunning;
import com.x.cms.assemble.control.timertask.Timertask_LogRecordCheckTask;
import com.x.cms.assemble.control.timertask.Timertask_RefreshAllDocumentReviews;
......@@ -51,14 +48,12 @@ public class ThisApplication {
public static void init() throws Exception {
CacheManager.init(context.clazz().getSimpleName());
LoggerFactory.setLevel(Config.logLevel().x_cms_assemble_control());
MessageConnector.start(context());
context().startQueue(queueBatchOperation);
context().startQueue(queueDocumentDelete);
context().startQueue(queueDataRowImport);
context().startQueue(queueDocumentUpdate);
context().startQueue(queueDocumentViewCountUpdate);
//queueSendDocumentNotify.initFixedThreadPool(3);
context().startQueue(queueSendDocumentNotify);
// 每天凌晨2点执行一次
......@@ -67,8 +62,7 @@ public class ThisApplication {
// 每天凌晨1点,计算所有的文档的权限信息
context.schedule(Timertask_RefreshAllDocumentReviews.class, "0 0 1 * * ?");
//集群下多台会一起运行,Timertask_BatchOperationTask运行即可
//context.scheduleLocal(Timertask_CheckDocumentReviewStatus.class, 1200);
// 集群下多台会一起运行,Timertask_BatchOperationTask运行即可
context.scheduleLocal(Timertask_InitOperationRunning.class, 150);
}
......
......@@ -23,7 +23,6 @@ import com.x.cms.assemble.control.ThisApplication;
import com.x.cms.core.entity.Document;
import com.x.cms.core.entity.FileInfo;
import com.x.processplatform.core.entity.content.Attachment;
import com.x.processplatform.core.entity.content.Work;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.tika.Tika;
......@@ -43,7 +42,7 @@ public class ActionFileUploadWithUrl extends BaseAction {
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
if(StringUtils.isEmpty(wi.getDocId())){
throw new ExceptionEntityFieldEmpty(Work.class, wi.getDocId());
throw new ExceptionEntityFieldEmpty(Document.class, wi.getDocId());
}
if(StringUtils.isEmpty(wi.getFileName())){
throw new ExceptionEntityFieldEmpty(Attachment.class, wi.getFileName());
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.3</version>
<version>6.4</version>
</parent>
<artifactId>x_cms_core_entity</artifactId>
<packaging>jar</packaging>
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.3</version>
<version>6.4</version>
</parent>
<artifactId>x_cms_core_express</artifactId>
<packaging>jar</packaging>
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.3</version>
<version>6.4</version>
</parent>
<artifactId>x_component_assemble_control</artifactId>
<packaging>war</packaging>
......
......@@ -2,7 +2,6 @@ package com.x.component.assemble.control;
import com.x.base.core.project.Context;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.component.assemble.control.schedule.InitComponents;
......@@ -24,7 +23,6 @@ public class ThisApplication {
public static void init() {
try {
CacheManager.init(context.clazz().getSimpleName());
LoggerFactory.setLevel(Config.logLevel().x_component_assemble_control());
context.scheduleLocal(InitComponents.class, 1);
} catch (Exception e) {
logger.error(e);
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.3</version>
<version>6.4</version>
</parent>
<artifactId>x_component_core_entity</artifactId>
<packaging>jar</packaging>
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.3</version>
<version>6.4</version>
</parent>
<artifactId>x_console</artifactId>
<packaging>jar</packaging>
......@@ -44,10 +44,6 @@
<groupId>o2oa</groupId>
<artifactId>x_message_core_entity</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
......
......@@ -55,6 +55,7 @@ public class InstrumentationAgent {
if (Files.exists(base.resolve(DYNAMIC_JARS))) {
load(base, DYNAMIC_JARS);
}
setLog4j2(base);
loadWithCfg(base, STORE_JARS);
loadWithCfg(base, ext());
} catch (Exception e) {
......@@ -126,4 +127,8 @@ public class InstrumentationAgent {
throw new IOException("can not define o2server base directory.");
}
private static void setLog4j2(Path base) {
System.setProperty("log4j.configurationFile", base.resolve("commons").resolve("log4j2.xml").toString());
}
}
package com.x.server.console;
import java.io.*;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.lang.reflect.Method;
......@@ -15,12 +22,14 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.regex.Matcher;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.tools.Crypto;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.BooleanUtils;
......@@ -33,6 +42,8 @@ import com.x.base.core.project.config.Config;
import com.x.base.core.project.config.DataServer;
import com.x.base.core.project.config.StorageServer;
import com.x.base.core.project.config.WebServer;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.tools.Crypto;
import com.x.base.core.project.tools.DefaultCharset;
import com.x.base.core.project.tools.StringTools;
import com.x.server.console.action.ActionConfig;
......@@ -40,7 +51,7 @@ import com.x.server.console.action.ActionControl;
import com.x.server.console.action.ActionCreateEncryptKey;
import com.x.server.console.action.ActionSetPassword;
import com.x.server.console.action.ActionVersion;
import com.x.server.console.log.LogTools;
import com.x.server.console.log.Log4j2Configuration;
import com.x.server.console.server.Servers;
public class Main {
......@@ -105,8 +116,7 @@ public class Main {
scanWar(base);
cleanTempDir(base);
createTempClassesDirectory(base);
SystemOutErrorSideCopyBuilder.start();
LogTools.setSlf4jSimple();
Log4j2Configuration.reconfigure();
ResourceFactory.bind();
CommandFactory.printStartHelp();
// 初始化hadoop环境
......
......@@ -24,6 +24,7 @@ import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
import com.google.common.collect.ImmutableList;
import com.x.base.core.project.config.WebServers;
import com.x.base.core.project.tools.*;
import org.apache.commons.codec.binary.Base64;
......@@ -88,6 +89,8 @@ public class NodeAgent extends Thread {
private static final int BUFFER_SIZE = 1024 * 1024 * 1000;
private static List<String> logLevelList = ImmutableList.of("debug", "info", "warn", "error", "print");
private LinkedBlockingQueue<String> commandQueue;
private FileOutputStream fos;
......@@ -313,7 +316,7 @@ public class NodeAgent extends Thread {
private void readLog(long lastTimeFileSize, DataOutputStream dos) throws Exception {
try {
File logFile = new File(Config.base(), "logs/" + DateTools.format(new Date(), "yyyy_MM_dd") + ".out.log");
File logFile = new File(Config.base(), "logs/out.log");
if (logFile.exists()) {
List<Map<String, String>> list = new ArrayList<>();
try (RandomAccessFile randomFile = new RandomAccessFile(logFile, "r")) {
......@@ -333,19 +336,25 @@ public class NodeAgent extends Thread {
String logLevel = "";
if (lineStr.length() > 0) {
if (lineStr.length() > 23) {
time = StringUtils.left(lineStr, 19);
if (DateTools.isDateTime(time)) {
time = StringUtils.left(lineStr, 23);
curTime = time;
if (lineStr.length() > 29) {
logLevel = StringUtils.right(StringUtils.left(lineStr, 29), 5).trim();
String arr[] = lineStr.split(" ");
if(arr.length > 3){
time = arr[0]+ " " +arr[1];
if (time.length()>19 && DateTools.isDateTime(StringUtils.left(time, 19))) {
curTime = time;
if (logLevelList.contains(arr[3].toLowerCase())) {
logLevel = arr[3];
}
} else {
time = curTime;
}
} else {
time = curTime;
}
}
} else {
continue;
if (curReadSize > LOG_MAX_READ_SIZE) {
break;
}else {
continue;
}
}
Map<String, String> map = new HashMap<>();
map.put("logTime", time + "#" + Config.node());
......@@ -459,7 +468,9 @@ public class NodeAgent extends Thread {
}
private void storeWar(String simpleName, byte[] bytes) throws Exception {
ClassInfo classInfo = this.scanModuleClassInfo(simpleName);
File war = new File(Config.dir_store(), simpleName + ".war");
FileUtils.writeByteArrayToFile(war, bytes);
/*ClassInfo classInfo = this.scanModuleClassInfo(simpleName);
Class<?> cls = Class.forName(classInfo.getName());
Module module = cls.getAnnotation(Module.class);
File war = new File(Config.dir_store(), cls.getSimpleName() + ".war");
......@@ -498,7 +509,7 @@ public class NodeAgent extends Thread {
}
}
}
}
}*/
}
private void storeJar(String simpleName, byte[] bytes) throws Exception {
......@@ -534,7 +545,7 @@ public class NodeAgent extends Thread {
File war = new File(Config.dir_custom(true), simpleName + ".war");
File dir = new File(Config.dir_servers_applicationServer_work(), simpleName);
FileUtils.writeByteArrayToFile(war, bytes, false);
boolean isStartApplication = false;// 第一次上传
/*boolean isStartApplication = false;// 第一次上传
if (Servers.applicationServerIsRunning()) {
GzipHandler gzipHandler = (GzipHandler) Servers.applicationServer.getHandler();
HandlerList hanlderList = (HandlerList) gzipHandler.getHandler();
......@@ -556,7 +567,7 @@ public class NodeAgent extends Thread {
customWarPublish(simpleName);
}
}
}
}*/
}
private void customWarPublish(String name) throws Exception {
......@@ -820,47 +831,31 @@ public class NodeAgent extends Thread {
}
public static void main(String[] args) throws Exception {
// File logFile = new File(Config.base(), "logs/" + DateTools.format(new Date(),
// "yyyy_MM_dd") + ".out.log");
File logFile = new File("/Users/chengjian/Desktop/temp/temp/2020_03_12.out.log");
RandomAccessFile randomFile = new RandomAccessFile(logFile, "r");
long lastTimeFileSize = randomFile.length() - 10 * 1024;
long tempSize = lastTimeFileSize;
randomFile.seek(lastTimeFileSize);
String tmp = "";
String lineStr = "2021-09-07 13:52:14,878 [ContextQuartzScheduler-x_calendar_assemble_control_Worker-1] INFO com.x.calendar.assemble.control.schedule.AlarmTrigger - The trigger for calendar alarm execute completed.Tue Sep 07 13:52:14 GMT+08:00 2021";
String time = "";
String curTime = "";
while ((tmp = randomFile.readLine()) != null) {
byte[] bytes = tmp.getBytes("ISO8859-1");
String lineStr = new String(bytes);
tempSize = tempSize + bytes.length + 1;
String time = curTime;
String logLevel = "";
if (lineStr.length() > 0) {
if (lineStr.length() > 23) {
time = StringUtils.left(lineStr, 19);
if (DateTools.isDateTime(time)) {
time = StringUtils.left(lineStr, 23);
curTime = time;
// System.out.println(lineStr);
} else {
if (StringUtils.isEmpty(curTime)) {
continue;
String arr[] = lineStr.split(" ");
if(arr.length > 3){
time = arr[0]+ " " +arr[1];
System.out.println(time);
System.out.println(StringUtils.left(time, 19));
if (time.length()>19 && DateTools.isDateTime(StringUtils.left(time, 19))) {
curTime = time;
if (logLevelList.contains(arr[3].toLowerCase())) {
logLevel = arr[3];
}
} else {
time = curTime;
// System.out.println(lineStr);
}
}
} else {
if (StringUtils.isEmpty(curTime)) {
continue;
} else {
time = curTime;
// System.out.println(lineStr);
}
}
}
lastTimeFileSize = randomFile.length();
tempSize = tempSize - 1;
System.out.println(lastTimeFileSize);
System.out.println(tempSize);
System.out.println(time);
System.out.println(curTime);
System.out.println(logLevel);
}
}
package com.x.server.console.log;
import java.io.PrintStream;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.appender.OutputStreamAppender;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.layout.PatternLayout;
import org.slf4j.LoggerFactory;
public class Log4j2Configuration {
private Log4j2Configuration() {
}
private static final String CONVERSION_PATTERN = "%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %p %c - %m%n";
public static void reconfigure() {
final PrintStream stderr = System.err;
final PrintStream stdout = System.out;
final LoggerContext context = LoggerContext.getContext(false);
final Configuration config = context.getConfiguration();
addStandardOutAppender(config, stdout);
bypassErr(stderr);
bypassOut(stdout);
context.updateLoggers();
}
private static void addStandardOutAppender(final Configuration config, final PrintStream stdout) {
final PatternLayout layout = PatternLayout.newBuilder().withConfiguration(config)
.withPattern(CONVERSION_PATTERN).build();
final Appender appender = OutputStreamAppender.createAppender(layout, null, stdout, "stdout", true, true);
appender.start();
config.addAppender(appender);
config.getRootLogger().addAppender(appender, null, null);
}
private static void bypassErr(final PrintStream stderr) {
BypassLoggerPrintStream printStream = new BypassLoggerPrintStream(stderr,
LoggerFactory.getLogger("System.err"));
System.setErr(printStream);
}
private static void bypassOut(final PrintStream stdout) {
BypassLoggerPrintStream printStream = new BypassLoggerPrintStream(stdout,
LoggerFactory.getLogger("System.out"));
System.setOut(printStream);
}
}
package com.x.server.console.log;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.config.Config;
public class LogTools {
public static void setSlf4jSimple() throws Exception {
String level = "warn";
if (StringUtils.isNotEmpty(Config.currentNode().getLogLevel())) {
level = Config.currentNode().getLogLevel();
}
// "trace", "debug", "info", "warn", "error" or "off"
if (StringUtils.equalsIgnoreCase(level, "trace")) {
System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "trace");
} else if (StringUtils.equalsIgnoreCase(level, "debug")) {
System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "debug");
} else if (StringUtils.equalsIgnoreCase(level, "warn")) {
System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "warn");
} else if (StringUtils.equalsIgnoreCase(level, "error")) {
System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "error");
} else if (StringUtils.equalsIgnoreCase(level, "off")) {
System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "off");
} else {
System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "info");
}
}
}
\ No newline at end of file
......@@ -50,10 +50,8 @@ public abstract class JettySeverTools {
server.addConnector(https);
}
protected static void addHttpConnector(Server server, Integer port, boolean persistentConnectionsEnable)
throws Exception {
protected static void addHttpConnector(Server server, Integer port, boolean persistentConnectionsEnable) {
HttpConfiguration config = new HttpConfiguration();
// config.setOutputBufferSize(1024 * 2048);
config.setPersistentConnectionsEnabled(persistentConnectionsEnable);
config.setRequestHeaderSize(8192 * 2);
config.setResponseHeaderSize(8192 * 2);
......@@ -117,9 +115,10 @@ public abstract class JettySeverTools {
filter = FileFilterUtils.or(filter, new WildcardFileFilter("jetty-all-*.jar"));
filter = FileFilterUtils.or(filter, new WildcardFileFilter("jetty-proxy-*.jar"));
filter = FileFilterUtils.or(filter, new WildcardFileFilter("quartz-*.jar"));
filter = FileFilterUtils.or(filter, new WildcardFileFilter("slf4j-simple-*.jar"));
filter = FileFilterUtils.or(filter, new WildcardFileFilter("jul-to-slf4j-*.jar"));
filter = FileFilterUtils.or(filter, new WildcardFileFilter("log4j-*.jar"));
// filter = FileFilterUtils.or(filter, new WildcardFileFilter("slf4j-api-*.jar"));
// filter = FileFilterUtils.or(filter, new WildcardFileFilter("jul-to-slf4j-*.jar"));
// filter = FileFilterUtils.or(filter, new WildcardFileFilter("log4j-*.jar"));
// filter = FileFilterUtils.or(filter, new WildcardFileFilter("log4j-slf4j-impl-*.jar"));
/* jersey从AppClassLoader加载 */
for (File o : FileUtils.listFiles(Config.dir_commons_ext().toFile(), filter, null)) {
jars.add(o.getAbsolutePath());
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册