mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-08 01:48:33 +08:00
日志优化
This commit is contained in:
parent
b809a0808e
commit
b657be1872
@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ActiveDirectoryUtils extends LdapUtils {
|
public class ActiveDirectoryUtils extends LdapUtils {
|
||||||
private final static Logger _logger = LoggerFactory.getLogger(ActiveDirectoryUtils.class);
|
private static final Logger _logger = LoggerFactory.getLogger(ActiveDirectoryUtils.class);
|
||||||
|
|
||||||
protected String domain;
|
protected String domain;
|
||||||
|
|
||||||
@ -87,9 +87,9 @@ public class ActiveDirectoryUtils extends LdapUtils {
|
|||||||
activeDirectoryDomain = domain;
|
activeDirectoryDomain = domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.info("PROVIDER_DOMAIN:" + activeDirectoryDomain + " for " + domain);
|
_logger.info("PROVIDER_DOMAIN : {} for {}" ,activeDirectoryDomain, domain);
|
||||||
String activeDirectoryPrincipal = activeDirectoryDomain + "\\" + principal;
|
String activeDirectoryPrincipal = activeDirectoryDomain + "\\" + principal;
|
||||||
_logger.debug("Active Directory SECURITY_PRINCIPAL : " + activeDirectoryPrincipal);
|
_logger.debug("Active Directory SECURITY_PRINCIPAL : {}" , activeDirectoryPrincipal);
|
||||||
props.setProperty(Context.SECURITY_PRINCIPAL, activeDirectoryPrincipal);
|
props.setProperty(Context.SECURITY_PRINCIPAL, activeDirectoryPrincipal);
|
||||||
props.setProperty(Context.SECURITY_CREDENTIALS, credentials);
|
props.setProperty(Context.SECURITY_CREDENTIALS, credentials);
|
||||||
|
|
||||||
|
|||||||
@ -108,9 +108,9 @@ public class LdapUtils {
|
|||||||
DirContext ctx = null;
|
DirContext ctx = null;
|
||||||
try {
|
try {
|
||||||
ctx = new InitialDirContext(properties);
|
ctx = new InitialDirContext(properties);
|
||||||
_logger.info("connect to ldap " + providerUrl + " seccessful.");
|
_logger.info("connect to ldap {} seccessful.",providerUrl);
|
||||||
} catch (NamingException e) {
|
} catch (NamingException e) {
|
||||||
_logger.error("connect to ldap " + providerUrl + " fail.");
|
_logger.error("connect to ldap {} fail.",providerUrl);
|
||||||
_logger.error(e.getMessage());
|
_logger.error(e.getMessage());
|
||||||
}
|
}
|
||||||
return ctx;
|
return ctx;
|
||||||
|
|||||||
@ -41,7 +41,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ActiveDirectoryOrganizationService extends AbstractSynchronizerService implements ISynchronizerService{
|
public class ActiveDirectoryOrganizationService extends AbstractSynchronizerService implements ISynchronizerService{
|
||||||
final static Logger _logger = LoggerFactory.getLogger(ActiveDirectoryOrganizationService.class);
|
static final Logger _logger = LoggerFactory.getLogger(ActiveDirectoryOrganizationService.class);
|
||||||
|
|
||||||
ActiveDirectoryUtils ldapUtils;
|
ActiveDirectoryUtils ldapUtils;
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ public class ActiveDirectoryOrganizationService extends AbstractSynchronizerSer
|
|||||||
String parentNamePath= organization.getNamePath().substring(0, organization.getNamePath().lastIndexOf("/"));
|
String parentNamePath= organization.getNamePath().substring(0, organization.getNamePath().lastIndexOf("/"));
|
||||||
|
|
||||||
if(orgsNamePathMap.get(organization.getNamePath())!=null) {
|
if(orgsNamePathMap.get(organization.getNamePath())!=null) {
|
||||||
_logger.info("org " + orgsNamePathMap.get(organization.getNamePath()).getNamePath()+" exists.");
|
_logger.info("org {} exists." , orgsNamePathMap.get(organization.getNamePath()).getNamePath());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ public class ActiveDirectoryOrganizationService extends AbstractSynchronizerSer
|
|||||||
organization.setParentId(parentOrg.getId());
|
organization.setParentId(parentOrg.getId());
|
||||||
organization.setParentName(parentOrg.getOrgName());
|
organization.setParentName(parentOrg.getOrgName());
|
||||||
organization.setCodePath(parentOrg.getCodePath()+"/"+organization.getId());
|
organization.setCodePath(parentOrg.getCodePath()+"/"+organization.getId());
|
||||||
_logger.info("parentNamePath " + parentNamePath+" , namePah " + organization.getNamePath());
|
_logger.info("parentNamePath {} , namePah {}" ,parentNamePath, organization.getNamePath());
|
||||||
|
|
||||||
//synchro Related
|
//synchro Related
|
||||||
SynchroRelated synchroRelated =
|
SynchroRelated synchroRelated =
|
||||||
@ -81,7 +81,7 @@ public class ActiveDirectoryOrganizationService extends AbstractSynchronizerSer
|
|||||||
if(synchroRelated == null) {
|
if(synchroRelated == null) {
|
||||||
organization.setId(organization.generateId());
|
organization.setId(organization.generateId());
|
||||||
organizationsService.insert(organization);
|
organizationsService.insert(organization);
|
||||||
_logger.debug("Organizations : " + organization);
|
_logger.debug("Organizations : {}" , organization);
|
||||||
|
|
||||||
synchroRelated = buildSynchroRelated(organization,organization.getLdapDn(),organization.getOrgName());
|
synchroRelated = buildSynchroRelated(organization,organization.getLdapDn(),organization.getOrgName());
|
||||||
}else {
|
}else {
|
||||||
@ -141,7 +141,7 @@ public class ActiveDirectoryOrganizationService extends AbstractSynchronizerSer
|
|||||||
_logger.debug("Sync OrganizationalUnit {} , name [{}] , NameInNamespace [{}]" ,
|
_logger.debug("Sync OrganizationalUnit {} , name [{}] , NameInNamespace [{}]" ,
|
||||||
(++recordCount),sr.getName(),sr.getNameInNamespace());
|
(++recordCount),sr.getName(),sr.getNameInNamespace());
|
||||||
|
|
||||||
HashMap<String,Attribute> attributeMap = new HashMap<String,Attribute>();
|
HashMap<String,Attribute> attributeMap = new HashMap<>();
|
||||||
NamingEnumeration<? extends Attribute> attrs = sr.getAttributes().getAll();
|
NamingEnumeration<? extends Attribute> attrs = sr.getAttributes().getAll();
|
||||||
while (null != attrs && attrs.hasMoreElements()) {
|
while (null != attrs && attrs.hasMoreElements()) {
|
||||||
Attribute objAttrs = attrs.nextElement();
|
Attribute objAttrs = attrs.nextElement();
|
||||||
@ -208,7 +208,7 @@ public class ActiveDirectoryOrganizationService extends AbstractSynchronizerSer
|
|||||||
org.setInstId(this.synchronizer.getInstId());
|
org.setInstId(this.synchronizer.getInstId());
|
||||||
org.setStatus(ConstsStatus.ACTIVE);
|
org.setStatus(ConstsStatus.ACTIVE);
|
||||||
|
|
||||||
_logger.debug("Organization " + org);
|
_logger.debug("Organization {}" , org);
|
||||||
return org;
|
return org;
|
||||||
} catch (NamingException e) {
|
} catch (NamingException e) {
|
||||||
_logger.error("NamingException " , e);
|
_logger.error("NamingException " , e);
|
||||||
|
|||||||
@ -45,8 +45,7 @@ import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
|||||||
|
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
public class SynchronizerAutoConfiguration implements InitializingBean {
|
public class SynchronizerAutoConfiguration implements InitializingBean {
|
||||||
private static final Logger _logger =
|
private static final Logger _logger = LoggerFactory.getLogger(SynchronizerAutoConfiguration.class);
|
||||||
LoggerFactory.getLogger(SynchronizerAutoConfiguration.class);
|
|
||||||
public static final String SYNCHRONIZERS_SELECT_STATEMENT = "select * from mxk_synchronizers where status ='1'";
|
public static final String SYNCHRONIZERS_SELECT_STATEMENT = "select * from mxk_synchronizers where status ='1'";
|
||||||
|
|
||||||
@Bean(name = "schedulerSynchronizerJobs")
|
@Bean(name = "schedulerSynchronizerJobs")
|
||||||
@ -76,7 +75,7 @@ public class SynchronizerAutoConfiguration implements InitializingBean {
|
|||||||
Synchronizers synchronizer) throws SchedulerException {
|
Synchronizers synchronizer) throws SchedulerException {
|
||||||
JobDetail jobDetail =
|
JobDetail jobDetail =
|
||||||
JobBuilder.newJob(SynchronizerJob.class)
|
JobBuilder.newJob(SynchronizerJob.class)
|
||||||
.withIdentity(synchronizer.getService()+"Job", "SynchronizerGroups")
|
.withIdentity(synchronizer.getService()+"_Job", "SynchronizerGroups")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
JobDataMap jobDataMap = new JobDataMap();
|
JobDataMap jobDataMap = new JobDataMap();
|
||||||
@ -87,7 +86,7 @@ public class SynchronizerAutoConfiguration implements InitializingBean {
|
|||||||
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(synchronizer.getScheduler());
|
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(synchronizer.getScheduler());
|
||||||
CronTrigger cronTrigger =
|
CronTrigger cronTrigger =
|
||||||
TriggerBuilder.newTrigger()
|
TriggerBuilder.newTrigger()
|
||||||
.withIdentity("trigger"+synchronizer.getService(), "SynchronizerGroups")
|
.withIdentity("trigger_"+synchronizer.getService(), "SynchronizerGroups")
|
||||||
.usingJobData(jobDataMap)
|
.usingJobData(jobDataMap)
|
||||||
.withSchedule(scheduleBuilder)
|
.withSchedule(scheduleBuilder)
|
||||||
.build();
|
.build();
|
||||||
@ -106,8 +105,7 @@ public class SynchronizerAutoConfiguration implements InitializingBean {
|
|||||||
synchronizer.setDriverClass(rs.getString("driverclass"));
|
synchronizer.setDriverClass(rs.getString("driverclass"));
|
||||||
synchronizer.setPrincipal( rs.getString("principal"));
|
synchronizer.setPrincipal( rs.getString("principal"));
|
||||||
synchronizer.setCredentials(
|
synchronizer.setCredentials(
|
||||||
PasswordReciprocal.getInstance().decoder(
|
PasswordReciprocal.getInstance().decoder(rs.getString("credentials")));
|
||||||
rs.getString("credentials")));
|
|
||||||
synchronizer.setResumeTime( rs.getString("resumetime"));
|
synchronizer.setResumeTime( rs.getString("resumetime"));
|
||||||
synchronizer.setSuspendTime(rs.getString("suspendtime"));
|
synchronizer.setSuspendTime(rs.getString("suspendtime"));
|
||||||
synchronizer.setUserFilters( rs.getString("userfilters"));
|
synchronizer.setUserFilters( rs.getString("userfilters"));
|
||||||
|
|||||||
@ -29,16 +29,16 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
public class SynchronizerJob implements Job {
|
public class SynchronizerJob implements Job {
|
||||||
static final Logger logger = LoggerFactory.getLogger(SynchronizerJob.class);
|
static final Logger logger = LoggerFactory.getLogger(SynchronizerJob.class);
|
||||||
|
|
||||||
SynchronizersService synchronizersService;
|
|
||||||
|
|
||||||
public static class JOBSTATUS{
|
public static class JOBSTATUS{
|
||||||
public static int STOP = 0;
|
public static final int STOP = 0;
|
||||||
public static int RUNNING = 1;
|
public static final int RUNNING = 1;
|
||||||
public static int FINISHED = 2;
|
public static final int FINISHED = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HashMap<String,Integer> jobStatus = new HashMap<String,Integer>();
|
SynchronizersService synchronizersService;
|
||||||
|
|
||||||
|
private static HashMap<String,Integer> jobStatus = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext context){
|
public void execute(JobExecutionContext context){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user