2525import java .util .Collection ;
2626import java .util .List ;
2727import java .util .Optional ;
28- import java .util .function .Function ;
2928
3029import org .eclipse .daanse .olap .api .Context ;
3130import org .eclipse .daanse .olap .api .element .Catalog ;
3231import org .eclipse .daanse .olap .xmla .bridge .ContextListSupplyer ;
33- import org .eclipse .daanse .olap .xmla .bridge .RoleUtils ;
3432import org .eclipse .daanse .xmla .api .RequestMetaData ;
35- import org .eclipse .daanse .xmla .api .UserRolePrincipal ;
3633import org .eclipse .daanse .xmla .api .XmlaConstants ;
3734import org .eclipse .daanse .xmla .api .common .enums .ColumnOlapTypeEnum ;
3835import org .eclipse .daanse .xmla .api .common .enums .LevelDbTypeEnum ;
@@ -62,8 +59,7 @@ public DBSchemaDiscoverService(ContextListSupplyer contextsListSupplyer) {
6259 this .contextsListSupplyer = contextsListSupplyer ;
6360 }
6461
65- public List <DbSchemaCatalogsResponseRow > dbSchemaCatalogs (DbSchemaCatalogsRequest request , RequestMetaData metaData ,
66- UserRolePrincipal userRolePrincipal ) {
62+ public List <DbSchemaCatalogsResponseRow > dbSchemaCatalogs (DbSchemaCatalogsRequest request , RequestMetaData metaData ) {
6763
6864 Optional <String > oCatalogName = request .restrictions ().catalogName ();
6965 if (oCatalogName .isPresent ()) {
@@ -85,8 +81,7 @@ public DbSchemaCatalogsResponseRow dbSchemaCatalogsRow(Context catalog) {
8581 Optional .empty (), Optional .empty (), Optional .empty ());
8682 }
8783
88- public List <DbSchemaColumnsResponseRow > dbSchemaColumns (DbSchemaColumnsRequest request , RequestMetaData metaData ,
89- UserRolePrincipal userRolePrincipal ) {
84+ public List <DbSchemaColumnsResponseRow > dbSchemaColumns (DbSchemaColumnsRequest request , RequestMetaData metaData ) {
9085 Optional <String > oCatalog = request .restrictions ().tableCatalog ();
9186 Optional <String > oTableSchema = request .restrictions ().tableSchema ();
9287 Optional <String > oTableName = request .restrictions ().tableName ();
@@ -95,22 +90,22 @@ public List<DbSchemaColumnsResponseRow> dbSchemaColumns(DbSchemaColumnsRequest r
9590 List <DbSchemaColumnsResponseRow > result = new ArrayList <>();
9691 if (oCatalog .isPresent ()) {
9792 Optional <Catalog > oContext = oCatalog
98- .flatMap (name -> contextsListSupplyer .tryGetFirstByName (name , RoleUtils . getRoles ( contextsListSupplyer , r -> userRolePrincipal . hasRole ( r ) )));
93+ .flatMap (name -> contextsListSupplyer .tryGetFirstByName (name , metaData . sessionId ( )));
9994 if (oContext .isPresent ()) {
10095 Catalog catalog = oContext .get ();
10196 result .addAll (
10297 getDbSchemaColumnsResponseRow (catalog , oTableSchema , oTableName , oColumnName , oColumnOlapType ));
10398 }
10499 } else {
105- result .addAll (contextsListSupplyer .get (RoleUtils . getRoles ( contextsListSupplyer , r -> userRolePrincipal . hasRole ( r ) )).stream ()
100+ result .addAll (contextsListSupplyer .get (metaData . sessionId ( )).stream ()
106101 .map (c -> getDbSchemaColumnsResponseRow (c , oTableSchema , oTableName , oColumnName , oColumnOlapType ))
107102 .flatMap (Collection ::stream ).toList ());
108103 }
109104 return result ;
110105 }
111106
112107 public List <DbSchemaProviderTypesResponseRow > dbSchemaProviderTypes (DbSchemaProviderTypesRequest request ,
113- RequestMetaData metaData , UserRolePrincipal userRolePrincipal ) {
108+ RequestMetaData metaData ) {
114109 List <DbSchemaProviderTypesResponseRow > result = new ArrayList <>();
115110 Optional <LevelDbTypeEnum > oLevelDbType = request .restrictions ().dataType ();
116111
@@ -177,48 +172,46 @@ public List<DbSchemaProviderTypesResponseRow> dbSchemaProviderTypes(DbSchemaProv
177172 return result ;
178173 }
179174
180- public List <DbSchemaSchemataResponseRow > dbSchemaSchemata (DbSchemaSchemataRequest request , RequestMetaData metaData ,
181- UserRolePrincipal userRolePrincipal ) {
175+ public List <DbSchemaSchemataResponseRow > dbSchemaSchemata (DbSchemaSchemataRequest request , RequestMetaData metaData ) {
182176 String catalogName = request .restrictions ().catalogName ();
183177 String schemaName = request .restrictions ().schemaName ();
184178 String schemaOwner = request .restrictions ().schemaOwner ();
185179 List <DbSchemaSchemataResponseRow > result = new ArrayList <>();
186180 if (catalogName != null ) {
187- Optional <Catalog > oCatalog = contextsListSupplyer .tryGetFirstByName (catalogName , RoleUtils . getRoles ( contextsListSupplyer , r -> userRolePrincipal . hasRole ( r ) ));
181+ Optional <Catalog > oCatalog = contextsListSupplyer .tryGetFirstByName (catalogName , metaData . sessionId ( ));
188182 if (oCatalog .isPresent ()) {
189183 result .addAll (getDbSchemaSchemataResponseRow (oCatalog .get (), schemaName , schemaOwner ));
190184 }
191185 } else {
192- result .addAll (contextsListSupplyer .get (RoleUtils . getRoles ( contextsListSupplyer , r -> userRolePrincipal . hasRole ( r ) )).stream ()
186+ result .addAll (contextsListSupplyer .get (metaData . sessionId ( )).stream ()
193187 .map (c -> getDbSchemaSchemataResponseRow (c , schemaName , schemaOwner )).flatMap (Collection ::stream )
194188 .toList ());
195189 }
196190 return result ;
197191 }
198192
199193 public List <DbSchemaSourceTablesResponseRow > dbSchemaSourceTables (DbSchemaSourceTablesRequest request ,
200- RequestMetaData metaData , UserRolePrincipal userRolePrincipal ) {
194+ RequestMetaData metaData ) {
201195 Optional <String > oCatalogName = request .restrictions ().catalogName ();
202196 Optional <String > oSchemaName = request .restrictions ().schemaName ();
203197 String tableName = request .restrictions ().tableName ();
204198 TableTypeEnum tableType = request .restrictions ().tableType ();
205199
206200 if (oCatalogName .isPresent ()) {
207201 Optional <Catalog > oCatalog = oCatalogName
208- .flatMap (name -> contextsListSupplyer .tryGetFirstByName (name , RoleUtils . getRoles ( contextsListSupplyer , r -> userRolePrincipal . hasRole ( r ) )));
202+ .flatMap (name -> contextsListSupplyer .tryGetFirstByName (name , metaData . sessionId ( )));
209203 if (oCatalog .isPresent ()) {
210204 return getDbSchemaSourceTablesResponseRow (oCatalog .get (), List .of (tableType .getValue ()));
211205 }
212206 } else {
213- return contextsListSupplyer .get (RoleUtils . getRoles ( contextsListSupplyer , r -> userRolePrincipal . hasRole ( r ) )).stream ()
207+ return contextsListSupplyer .get (metaData . sessionId ( )).stream ()
214208 .map (c -> getDbSchemaSourceTablesResponseRow (c , List .of (tableType .getValue ())))
215209 .flatMap (Collection ::stream ).toList ();
216210 }
217211 return List .of ();
218212 }
219213
220- public List <DbSchemaTablesResponseRow > dbSchemaTables (DbSchemaTablesRequest request , RequestMetaData metaData ,
221- UserRolePrincipal userRolePrincipal ) {
214+ public List <DbSchemaTablesResponseRow > dbSchemaTables (DbSchemaTablesRequest request , RequestMetaData metaData ) {
222215 Optional <String > oTableCatalog = request .restrictions ().tableCatalog ();
223216 Optional <String > oTableSchema = request .restrictions ().tableSchema ();
224217 Optional <String > oTableName = request .restrictions ().tableName ();
@@ -230,32 +223,32 @@ public List<DbSchemaTablesResponseRow> dbSchemaTables(DbSchemaTablesRequest requ
230223
231224 if (oTableCatalog .isPresent ()) {
232225 Optional <Catalog > oCatalog = oTableCatalog
233- .flatMap (name -> contextsListSupplyer .tryGetFirstByName (name , RoleUtils . getRoles ( contextsListSupplyer , r -> userRolePrincipal . hasRole ( r ) )));
226+ .flatMap (name -> contextsListSupplyer .tryGetFirstByName (name , metaData . sessionId ( )));
234227 if (oCatalog .isPresent ()) {
235228 return Utils .getDbSchemaTablesResponseRow (oCatalog .get (), oTableSchema , oTableName , oTableType );
236229 }
237230 } else {
238- return contextsListSupplyer .get (RoleUtils . getRoles ( contextsListSupplyer , r -> userRolePrincipal . hasRole ( r ) )).stream ()
231+ return contextsListSupplyer .get (metaData . sessionId ( )).stream ()
239232 .map (c -> Utils .getDbSchemaTablesResponseRow (c , oTableSchema , oTableName , oTableType ))
240233 .flatMap (Collection ::stream ).toList ();
241234 }
242235 return List .of ();
243236 }
244237
245238 public List <DbSchemaTablesInfoResponseRow > dbSchemaTablesInfo (DbSchemaTablesInfoRequest request ,
246- RequestMetaData metaData , UserRolePrincipal userRolePrincipal ) {
239+ RequestMetaData metaData ) {
247240 Optional <String > oCatalogName = request .restrictions ().catalogName ();
248241 Optional <String > oSchemaName = request .restrictions ().schemaName ();
249242 String tableName = request .restrictions ().tableName ();
250243 TableTypeEnum tableType = request .restrictions ().tableType ();
251244 if (oCatalogName .isPresent ()) {
252245 Optional <Catalog > oCatalog = oCatalogName
253- .flatMap (name -> contextsListSupplyer .tryGetFirstByName (name , RoleUtils . getRoles ( contextsListSupplyer , r -> userRolePrincipal . hasRole ( r ) )));
246+ .flatMap (name -> contextsListSupplyer .tryGetFirstByName (name , metaData . sessionId ( )));
254247 if (oCatalog .isPresent ()) {
255248 return getDbSchemaTablesInfoResponseRow (oCatalog .get (), oSchemaName , tableName , tableType );
256249 }
257250 } else {
258- return contextsListSupplyer .get (RoleUtils . getRoles ( contextsListSupplyer , r -> userRolePrincipal . hasRole ( r ) )).stream ()
251+ return contextsListSupplyer .get (metaData . sessionId ( )).stream ()
259252 .map (c -> getDbSchemaTablesInfoResponseRow (c , oSchemaName , tableName , tableType ))
260253 .flatMap (Collection ::stream ).toList ();
261254 }
0 commit comments