@ -1,29 +1,23 @@
package com.fr.design.mainframe.authority ;
import com.fanruan.config.impl.data.ConnectionConfigProviderFactory ;
import com.fanruan.config.impl.data.TableDataConfigProviderFactory ;
import com.fr.base.CloneCollector ;
import com.fr.design.dialog.FineJOptionPane ;
import com.fr.design.i18n.Toolkit ;
import com.fr.design.mainframe.DesignerContext ;
import com.fr.design.mainframe.JTemplate ;
import com.fr.log.FineLoggerFactory ;
import com.fr.workspace.WorkContext ;
import com.fr.workspace.server.authority.user.UserAuthority ;
import com.fr.workspace.server.repository.authority.RemoteAuthorityRepository ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.HashSet ;
import java.util.Iterator ;
import java.util.List ;
import java.util.Map ;
import java.util.Set ;
import static javax.swing.JOptionPane.WARNING_MESSAGE ;
@ -31,6 +25,7 @@ public class JTemplateAuthorityChecker {
JTemplate < ? , ? > jTemplate ;
Set < String > authConnectionNames ;
Set < String > authDatasetNames ;
Set < String > templateDatasetNames ;
Map < String , ElementAuthorityChecker > checkerMap = new HashMap < > ( ) ;
Set < String > authFailConnectionNames = new HashSet < > ( ) ;
Set < String > authFailDatasetNames = new HashSet < > ( ) ;
@ -45,7 +40,12 @@ public class JTemplateAuthorityChecker {
}
private void initAuthNames ( ) {
// 无需获取所有数据集和数据连接了,当前只能获取自己有权限的
// 无需获取所有服务器数据集和数据连接了,因为当前只能获取自己有权限的,只要拿一下模板数据集就行
templateDatasetNames = new HashSet < > ( ) ;
Iterator < String > tableDataNameIterator = jTemplate . getTarget ( ) . getTableDataNameIterator ( ) ;
while ( tableDataNameIterator . hasNext ( ) ) {
templateDatasetNames . add ( tableDataNameIterator . next ( ) ) ;
}
Map < String , Set < String > > authNamesMap = RemoteAuthorityRepository . getInstance ( ) . getAuthServerDataSetAndConnectionNames ( WorkContext . getCurrent ( ) . getConnection ( ) . getUserName ( ) ) ;
if ( authNamesMap ! = null ) {
//有权限的数据连接名称
@ -87,6 +87,8 @@ public class JTemplateAuthorityChecker {
}
}
}
// 排除模板数据集的部分
authFailDatasetNames . removeAll ( templateDatasetNames ) ;
FineLoggerFactory . getLogger ( ) . info ( "JTemplateAuthorityChecker check time consume:" + ( System . currentTimeMillis ( ) - s ) ) ;
return authFailConnectionNames . size ( ) = = 0 & & authFailDatasetNames . size ( ) = = 0 ;
}