From d015aa057365b82076daa449dbc990bf7ae75fa0 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Thu, 12 Dec 2024 16:37:22 -0500 Subject: [PATCH] reorg Signed-off-by: Craig Perkins --- .../sampleextension/SampleExtensionPlugin.java | 12 ++++++------ .../sampleextension/actions/SampleResource.java | 4 ++++ .../{ => create}/CreateSampleResourceAction.java | 2 +- .../{ => create}/CreateSampleResourceRestAction.java | 3 ++- .../CreateSampleResourceTransportAction.java | 5 +++-- .../actions/{ => list}/ListSampleResourceAction.java | 2 +- .../{ => list}/ListSampleResourceRequest.java | 2 +- .../{ => list}/ListSampleResourceResponse.java | 5 +++-- .../{ => list}/ListSampleResourceRestAction.java | 2 +- .../ListSampleResourceTransportAction.java | 3 ++- 10 files changed, 24 insertions(+), 16 deletions(-) rename sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/{ => create}/CreateSampleResourceAction.java (92%) rename sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/{ => create}/CreateSampleResourceRestAction.java (92%) rename sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/{ => create}/CreateSampleResourceTransportAction.java (89%) rename sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/{ => list}/ListSampleResourceAction.java (92%) rename sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/{ => list}/ListSampleResourceRequest.java (94%) rename sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/{ => list}/ListSampleResourceResponse.java (89%) rename sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/{ => list}/ListSampleResourceRestAction.java (95%) rename sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/{ => list}/ListSampleResourceTransportAction.java (94%) diff --git a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/SampleExtensionPlugin.java b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/SampleExtensionPlugin.java index c6d541f7f0..a8cb3f084a 100644 --- a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/SampleExtensionPlugin.java +++ b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/SampleExtensionPlugin.java @@ -38,13 +38,13 @@ import org.opensearch.rest.RestController; import org.opensearch.rest.RestHandler; import org.opensearch.script.ScriptService; -import org.opensearch.security.sampleextension.actions.CreateSampleResourceAction; -import org.opensearch.security.sampleextension.actions.CreateSampleResourceRestAction; -import org.opensearch.security.sampleextension.actions.CreateSampleResourceTransportAction; -import org.opensearch.security.sampleextension.actions.ListSampleResourceAction; -import org.opensearch.security.sampleextension.actions.ListSampleResourceRestAction; -import org.opensearch.security.sampleextension.actions.ListSampleResourceTransportAction; import org.opensearch.security.sampleextension.actions.SampleResource; +import org.opensearch.security.sampleextension.actions.create.CreateSampleResourceAction; +import org.opensearch.security.sampleextension.actions.create.CreateSampleResourceRestAction; +import org.opensearch.security.sampleextension.actions.create.CreateSampleResourceTransportAction; +import org.opensearch.security.sampleextension.actions.list.ListSampleResourceAction; +import org.opensearch.security.sampleextension.actions.list.ListSampleResourceRestAction; +import org.opensearch.security.sampleextension.actions.list.ListSampleResourceTransportAction; import org.opensearch.security.sampleextension.actions.sharing.UpdateSampleResourceSharingAction; import org.opensearch.security.sampleextension.actions.sharing.UpdateSampleResourceSharingRestAction; import org.opensearch.security.sampleextension.actions.sharing.UpdateSampleResourceSharingTransportAction; diff --git a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/SampleResource.java b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/SampleResource.java index ba6d1c97d2..af2b51cdcc 100644 --- a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/SampleResource.java +++ b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/SampleResource.java @@ -24,6 +24,10 @@ public SampleResource() {} this.name = in.readString(); } + public static SampleResource from(StreamInput in) throws IOException { + return new SampleResource(in); + } + @Override public String getResourceType() { return "sample_resource"; diff --git a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/CreateSampleResourceAction.java b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/create/CreateSampleResourceAction.java similarity index 92% rename from sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/CreateSampleResourceAction.java rename to sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/create/CreateSampleResourceAction.java index a3a32db1e3..19c2685ec3 100644 --- a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/CreateSampleResourceAction.java +++ b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/create/CreateSampleResourceAction.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.security.sampleextension.actions; +package org.opensearch.security.sampleextension.actions.create; import org.opensearch.action.ActionType; import org.opensearch.security.spi.actions.CreateResourceResponse; diff --git a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/CreateSampleResourceRestAction.java b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/create/CreateSampleResourceRestAction.java similarity index 92% rename from sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/CreateSampleResourceRestAction.java rename to sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/create/CreateSampleResourceRestAction.java index 210105c878..07d8a0f68a 100644 --- a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/CreateSampleResourceRestAction.java +++ b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/create/CreateSampleResourceRestAction.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.security.sampleextension.actions; +package org.opensearch.security.sampleextension.actions.create; import java.io.IOException; import java.util.List; @@ -17,6 +17,7 @@ import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.RestRequest; import org.opensearch.rest.action.RestToXContentListener; +import org.opensearch.security.sampleextension.actions.SampleResource; import org.opensearch.security.spi.actions.CreateResourceRequest; import static java.util.Collections.singletonList; diff --git a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/CreateSampleResourceTransportAction.java b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/create/CreateSampleResourceTransportAction.java similarity index 89% rename from sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/CreateSampleResourceTransportAction.java rename to sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/create/CreateSampleResourceTransportAction.java index a67134bf4e..92d498a8c3 100644 --- a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/CreateSampleResourceTransportAction.java +++ b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/create/CreateSampleResourceTransportAction.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.security.sampleextension.actions; +package org.opensearch.security.sampleextension.actions.create; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -14,6 +14,7 @@ import org.opensearch.action.support.ActionFilters; import org.opensearch.client.Client; import org.opensearch.common.inject.Inject; +import org.opensearch.security.sampleextension.actions.SampleResource; import org.opensearch.security.spi.actions.CreateResourceTransportAction; import org.opensearch.transport.TransportService; @@ -27,6 +28,6 @@ public class CreateSampleResourceTransportAction extends CreateResourceTransport @Inject public CreateSampleResourceTransportAction(TransportService transportService, ActionFilters actionFilters, Client nodeClient) { - super(transportService, actionFilters, nodeClient, CreateSampleResourceAction.NAME, RESOURCE_INDEX_NAME, SampleResource::new); + super(transportService, actionFilters, nodeClient, CreateSampleResourceAction.NAME, RESOURCE_INDEX_NAME, SampleResource::from); } } diff --git a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceAction.java b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceAction.java similarity index 92% rename from sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceAction.java rename to sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceAction.java index b4c3f39726..aac9ab10d9 100644 --- a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceAction.java +++ b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceAction.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.security.sampleextension.actions; +package org.opensearch.security.sampleextension.actions.list; import org.opensearch.action.ActionType; diff --git a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceRequest.java b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceRequest.java similarity index 94% rename from sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceRequest.java rename to sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceRequest.java index 041a5964e7..3a6acb5cfb 100644 --- a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceRequest.java +++ b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceRequest.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.security.sampleextension.actions; +package org.opensearch.security.sampleextension.actions.list; import java.io.IOException; diff --git a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceResponse.java b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceResponse.java similarity index 89% rename from sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceResponse.java rename to sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceResponse.java index 6569510284..9eb14cac61 100644 --- a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceResponse.java +++ b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceResponse.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.security.sampleextension.actions; +package org.opensearch.security.sampleextension.actions.list; import java.io.IOException; import java.util.List; @@ -16,6 +16,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.security.sampleextension.actions.SampleResource; import org.opensearch.security.spi.AbstractResource; /** @@ -44,7 +45,7 @@ public void writeTo(StreamOutput out) throws IOException { * @param in the stream input */ public ListSampleResourceResponse(final StreamInput in) throws IOException { - resources = in.readList(SampleResource::new); + resources = in.readList(SampleResource::from); } @Override diff --git a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceRestAction.java b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceRestAction.java similarity index 95% rename from sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceRestAction.java rename to sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceRestAction.java index 97e54904e3..4bab2c9ce6 100644 --- a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceRestAction.java +++ b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceRestAction.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.security.sampleextension.actions; +package org.opensearch.security.sampleextension.actions.list; import java.util.List; diff --git a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceTransportAction.java b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceTransportAction.java similarity index 94% rename from sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceTransportAction.java rename to sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceTransportAction.java index e2785f9d1c..864f7c6bdf 100644 --- a/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/ListSampleResourceTransportAction.java +++ b/sample-extension-plugin/src/main/java/org/opensearch/security/sampleextension/actions/list/ListSampleResourceTransportAction.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.security.sampleextension.actions; +package org.opensearch.security.sampleextension.actions.list; import java.util.List; @@ -15,6 +15,7 @@ import org.opensearch.client.Client; import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; +import org.opensearch.security.sampleextension.actions.SampleResource; import org.opensearch.security.sampleextension.resource.SampleResourceSharingService; import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService;