1616import org .elasticsearch .client .internal .Client ;
1717import org .elasticsearch .cluster .metadata .IndexMetadata ;
1818import org .elasticsearch .cluster .metadata .MappingMetadata ;
19+ import org .elasticsearch .cluster .project .ProjectResolver ;
1920import org .elasticsearch .cluster .service .ClusterService ;
2021import org .elasticsearch .common .compress .CompressedXContent ;
2122import org .elasticsearch .common .settings .IndexScopedSettings ;
@@ -46,6 +47,7 @@ public class CreateIndexFromSourceTransportAction extends HandledTransportAction
4647 private final ClusterService clusterService ;
4748 private final Client client ;
4849 private final IndexScopedSettings indexScopedSettings ;
50+ private final ProjectResolver projectResolver ;
4951 private static final Set <String > INDEX_BLOCK_SETTINGS = Set .of (
5052 IndexMetadata .SETTING_READ_ONLY ,
5153 IndexMetadata .SETTING_READ_ONLY_ALLOW_DELETE ,
@@ -60,7 +62,8 @@ public CreateIndexFromSourceTransportAction(
6062 ClusterService clusterService ,
6163 ActionFilters actionFilters ,
6264 Client client ,
63- IndexScopedSettings indexScopedSettings
65+ IndexScopedSettings indexScopedSettings ,
66+ ProjectResolver projectResolver
6467 ) {
6568 super (
6669 CreateIndexFromSourceAction .NAME ,
@@ -73,12 +76,13 @@ public CreateIndexFromSourceTransportAction(
7376 this .clusterService = clusterService ;
7477 this .client = client ;
7578 this .indexScopedSettings = indexScopedSettings ;
79+ this .projectResolver = projectResolver ;
7680 }
7781
7882 @ Override
7983 protected void doExecute (Task task , CreateIndexFromSourceAction .Request request , ActionListener <AcknowledgedResponse > listener ) {
8084
81- IndexMetadata sourceIndex = clusterService .state (). getMetadata (). getProject ( ).index (request .sourceIndex ());
85+ IndexMetadata sourceIndex = projectResolver . getProjectMetadata ( clusterService .state ()).index (request .sourceIndex ());
8286
8387 if (sourceIndex == null ) {
8488 listener .onFailure (new IndexNotFoundException (request .sourceIndex ()));
0 commit comments