delete maxkey-synchronizer-reorgdept & settings.gradle文件优化

This commit is contained in:
MaxKey 2024-06-24 20:57:09 +08:00
parent 2df897913b
commit f3ccc7c831
8 changed files with 99 additions and 136 deletions

View File

@ -102,6 +102,7 @@ public class OrganizationsService extends JpaService<Organizations>{
return false;
}
public void reorgNamePath(String instId) {
_logger.debug("instId {}", instId);
if (StringUtils.isBlank(instId)) {
@ -139,14 +140,13 @@ public class OrganizationsService extends JpaService<Organizations>{
}
}
public static boolean isRootOrg(Organizations rootOrg){
return (
rootOrg.getParentId() == null
|| rootOrg.getParentId().equalsIgnoreCase("-1")
|| rootOrg.getParentId().equalsIgnoreCase("0")
boolean isRootOrg(Organizations rootOrg) {
if (rootOrg.getParentId() == null || rootOrg.getParentId().equalsIgnoreCase("-1")
|| rootOrg.getParentId().equalsIgnoreCase(rootOrg.getId())
|| rootOrg.getParentId().equalsIgnoreCase(rootOrg.getInstId())
);
|| rootOrg.getParentId().equalsIgnoreCase(rootOrg.getInstId())) {
return true;
}
return false;
}
void reorg(HashMap<String, Organizations> orgMap, List<Organizations> orgList, Organizations rootOrg) {
@ -161,9 +161,8 @@ public class OrganizationsService extends JpaService<Organizations>{
rootOrg.setReorgNamePath(true);
for (Organizations org : orgList) {
if (org.isReorgNamePath()) {
if (org.isReorgNamePath())
continue;
}
if (org.getParentId().equalsIgnoreCase(rootOrg.getId())) {
reorg(orgMap, orgList, org);
}

View File

@ -1,14 +0,0 @@
description = "maxkey-synchronizer-reorgdept"
apply plugin: 'java'
dependencies {
//local jars
implementation fileTree(dir: '../maxkey-lib/*/', include: '*.jar')
implementation project(":maxkey-common")
implementation project(":maxkey-core")
implementation project(":maxkey-persistence")
implementation project(":maxkey-synchronizers:maxkey-synchronizer")
}

View File

@ -1,60 +0,0 @@
/*
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.maxkey.synchronizer.reorg;
import org.dromara.maxkey.entity.Synchronizers;
import org.dromara.maxkey.synchronizer.ISynchronizerService;
import org.dromara.maxkey.synchronizer.reorg.service.ReorgDeptService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ReorgDeptSynchronizerService implements ISynchronizerService {
static final Logger _logger = LoggerFactory.getLogger(ReorgDeptSynchronizerService.class);
Synchronizers synchronizer;
@Autowired
ReorgDeptService reorgDeptService;
public ReorgDeptSynchronizerService() {
super();
}
public void sync() throws Exception {
_logger.info("Sync ...");
reorgDeptService.setSynchronizer(synchronizer);
reorgDeptService.sync();
}
public void setReorgDeptService(ReorgDeptService reorgDeptService) {
this.reorgDeptService = reorgDeptService;
}
@Override
public void setSynchronizer(Synchronizers synchronizer) {
this.synchronizer = synchronizer;
}
}

View File

@ -1,36 +0,0 @@
/*
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.maxkey.synchronizer.reorg.service;
import org.dromara.maxkey.synchronizer.AbstractSynchronizerService;
import org.dromara.maxkey.synchronizer.ISynchronizerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@Service
public class ReorgDeptService extends AbstractSynchronizerService implements ISynchronizerService{
static final Logger _logger = LoggerFactory.getLogger(ReorgDeptService.class);
public void sync() {
_logger.info("Sync Organizations ...");
organizationsService.reorgNamePath(this.synchronizer.getInstId());
}
}

View File

@ -22,9 +22,11 @@ import org.dromara.maxkey.configuration.ApplicationConfig;
import org.dromara.maxkey.listener.DynamicGroupsListenerAdapter;
import org.dromara.maxkey.listener.ListenerAdapter;
import org.dromara.maxkey.listener.ListenerParameter;
import org.dromara.maxkey.listener.ReorgDeptListenerAdapter;
import org.dromara.maxkey.listener.SessionListenerAdapter;
import org.dromara.maxkey.persistence.service.ConnectorsService;
import org.dromara.maxkey.persistence.service.GroupsService;
import org.dromara.maxkey.persistence.service.OrganizationsService;
import org.dromara.maxkey.provision.thread.ProvisioningRunner;
import org.dromara.maxkey.provision.thread.ProvisioningRunnerThread;
import org.quartz.Scheduler;
@ -55,6 +57,20 @@ public class MaxKeyMgtListenerConfig {
return "sessionListenerAdapter";
}
@Bean
public String reorgDeptListenerAdapter(
Scheduler scheduler,
OrganizationsService organizationsService) throws SchedulerException {
ListenerAdapter.addListener(
scheduler,
ReorgDeptListenerAdapter.class,
"0 0/30 * * * ?",//30 minutes
new ListenerParameter().add("organizationsService",organizationsService).build()
);
logger.debug("ReorgDept ListenerAdapter inited .");
return "reorgDeptListenerAdapter";
}
@Bean
public String dynamicGroupsListenerAdapter(
Scheduler scheduler,

View File

@ -0,0 +1,59 @@
/*
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.maxkey.listener;
import java.io.Serializable;
import org.dromara.maxkey.persistence.service.OrganizationsService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ReorgDeptListenerAdapter extends ListenerAdapter implements Job , Serializable {
static final Logger _logger = LoggerFactory.getLogger(ReorgDeptListenerAdapter.class);
private static final long serialVersionUID = 4782358765969474833L;
transient OrganizationsService organizationsService;
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
if(jobStatus == JOBSTATUS.RUNNING) {return;}
init(context);
_logger.debug("running ... " );
jobStatus = JOBSTATUS.RUNNING;
try {
organizationsService.reorgNamePath(null);
_logger.debug("finished " );
jobStatus = JOBSTATUS.FINISHED;
}catch(Exception e) {
jobStatus = JOBSTATUS.ERROR;
_logger.error("Exception " ,e);
}
}
@Override
protected void init(JobExecutionContext context){
super.init(context);
if(organizationsService == null) {
organizationsService = getParameter("organizationsService",OrganizationsService.class);
}
}
}

View File

@ -48,7 +48,7 @@ public class SessionListenerAdapter extends ListenerAdapter implements Job , S
for (HistoryLogin login : sessionManager.querySessions()) {
Session session = sessionManager.get(login.getSessionId());
if(session == null) {
logger.debug("user {} session {} Login at {} and TimeOut at {} ." ,
logger.debug("TimeOut user {} session {} Login at {} and at {} ." ,
login.getUsername(),
login.getId(),
login.getLoginTime(),

View File

@ -1,5 +1,5 @@
/*
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
* Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -45,7 +45,6 @@ include ('maxkey-synchronizers:maxkey-synchronizer-dingtalk')
include ('maxkey-synchronizers:maxkey-synchronizer-feishu')
include ('maxkey-synchronizers:maxkey-synchronizer-jdbc')
include ('maxkey-synchronizers:maxkey-synchronizer-ldap')
include ('maxkey-synchronizers:maxkey-synchronizer-reorgdept')
include ('maxkey-synchronizers:maxkey-synchronizer-workweixin')
//Protocol