|
|
|
@ -7,11 +7,11 @@ import com.fr.design.i18n.Toolkit;
|
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
|
import com.fr.design.mod.ModClassFilter; |
|
|
|
|
import com.fr.file.ConnectionConfig; |
|
|
|
|
import com.fr.file.TableDataConfig; |
|
|
|
|
import com.fr.invoke.ClassHelper; |
|
|
|
|
|
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fr.rpc.ExceptionHandler; |
|
|
|
|
import com.fr.rpc.RPCInvokerExceptionInfo; |
|
|
|
|
import com.fr.stable.Filter; |
|
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
|
import com.fr.workspace.server.authority.user.UserAuthority; |
|
|
|
@ -19,7 +19,6 @@ import com.fr.workspace.server.authority.user.UserAuthority;
|
|
|
|
|
import java.util.Collection; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.Iterator; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
@ -29,7 +28,9 @@ import static javax.swing.JOptionPane.WARNING_MESSAGE;
|
|
|
|
|
|
|
|
|
|
public class JTemplateAuthorityChecker { |
|
|
|
|
JTemplate<?, ?> jTemplate; |
|
|
|
|
Set<String> allConnectionNames; |
|
|
|
|
Set<String> authConnectionNames; |
|
|
|
|
Set<String> allDatasetNames; |
|
|
|
|
Set<String> authDatasetNames; |
|
|
|
|
Map<String, ElementAuthorityChecker> checkerMap = new HashMap<>(); |
|
|
|
|
Set<String> authFailConnectionNames = new HashSet<>(); |
|
|
|
@ -45,18 +46,20 @@ public class JTemplateAuthorityChecker {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initAuthNames() { |
|
|
|
|
allDatasetNames = new HashSet<>(); |
|
|
|
|
for (String authServerDataSetName : TableDataConfig.getInstance().getTableDatas().keySet()) { |
|
|
|
|
allDatasetNames.add(authServerDataSetName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
allConnectionNames = ConnectionConfig.getInstance().getConnections().keySet(); |
|
|
|
|
|
|
|
|
|
UserAuthority templateAuthority = WorkContext.getCurrent().get(UserAuthority.class); |
|
|
|
|
Map<String, Set<String>> authNamesMap = templateAuthority.getAuthServerDataSetAndConnectionNames(); |
|
|
|
|
if (authNamesMap != null) { |
|
|
|
|
//有权限的数据连接名称
|
|
|
|
|
authConnectionNames = authNamesMap.get(UserAuthority.AUTH_CONNECTION_NAMES); |
|
|
|
|
//有权限的数据集名称(模板数据集和服务器数据集)
|
|
|
|
|
//有权限的数据集名称
|
|
|
|
|
authDatasetNames = authNamesMap.get(UserAuthority.AUTH_SERVER_DATASET_NAMES); |
|
|
|
|
Iterator<String> iterator = jTemplate.getTarget().getTableDataNameIterator(); |
|
|
|
|
while (iterator.hasNext()) { |
|
|
|
|
String datasetName = iterator.next(); |
|
|
|
|
authDatasetNames.add(datasetName); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -95,7 +98,8 @@ public class JTemplateAuthorityChecker {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
authFailConnectionNames.retainAll(allConnectionNames); |
|
|
|
|
authFailDatasetNames.retainAll(allDatasetNames); |
|
|
|
|
FineLoggerFactory.getLogger().info("JTemplateAuthorityChecker check time consume:" + (System.currentTimeMillis() - s)); |
|
|
|
|
return authFailConnectionNames.size() == 0 && authFailDatasetNames.size() == 0; |
|
|
|
|
} |
|
|
|
|