You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2017/04/19 21:56:49 UTC
[1/5] geode git commit: GEODE-2103 Update gfsh start server|locator
command reference page. [Forced Update!]
Repository: geode
Updated Branches:
refs/heads/feature/GEODE-2632-3 47f7d705f -> c03218b7d (forced update)
GEODE-2103 Update gfsh start server|locator command
reference page.
- the optional http-service-port defaults to 7070
- both http-service-port and http-service-bind-address
are available for gfsh start server and gfsh start locator
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/3a4c6fc6
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/3a4c6fc6
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/3a4c6fc6
Branch: refs/heads/feature/GEODE-2632-3
Commit: 3a4c6fc66afc59ba907ca815274a1ca73db0a8c3
Parents: 1156011
Author: Karen Miller <km...@pivotal.io>
Authored: Tue Apr 18 15:11:38 2017 -0700
Committer: Karen Miller <km...@pivotal.io>
Committed: Tue Apr 18 17:02:51 2017 -0700
----------------------------------------------------------------------
.../gfsh/command-pages/start.html.md.erb | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/3a4c6fc6/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb
----------------------------------------------------------------------
diff --git a/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb b/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb
index 7fb5165..60ba254 100644
--- a/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb
+++ b/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb
@@ -275,7 +275,9 @@ start locator --name=value [--bind-address=value] [--force(=value)] [--group=val
[--locators=value] [--log-level=value] [--mcast-address=value] [--mcast-port=value] [--port=value] [--dir=value]
[--properties-file=value] [--security-properties-file=value] [--initial-heap=value] [--max-heap=value]
[--connect(=value)] [--enable-cluster-configuration(=value)] [--load-from-cluster-configuration-dir(=value)]
- [--cluster-config-dir=value] [--J=value(,value)*]
+ [--cluster-config-dir=value]
+ [--http-service-port=value] [--http-service-bind-address=value]
+ [--J=value(,value)*]
```
<a id="topic_591260CF25D64562A0EDD7260D2AC6D4__table_hly_vvg_2w"></a>
@@ -398,6 +400,17 @@ See <a href="../../../configuring/cluster_config/gfsh_persist.html">Overview of
<td>cluster-config</td>
</tr>
<tr class="even">
+<td><span class="keyword parmname">\-\-http-service-port</span></td>
+<td>Specifies the port on which the HTTP service will listen.</td>
+<td>7070</td>
+</tr>
+<tr class="even">
+<td><span class="keyword parmname">\-\-http-service-bind-address</span></td>
+<td>Specifies the IP address to which the HTTP service will be bound.
+</td>
+<td>the local host machine's address</td>
+</tr>
+<tr class="even">
<td><span class="keyword parmname">\-\-J </span></td>
<td>Argument passed to the JVM on which the Locator will run. For example, specifying <code class="ph codeph">--J=-Dfoo.bar=true</code> sets property "foo.bar" to "true".
<div class="note note">
@@ -756,13 +769,13 @@ See <a href="../../../configuring/cluster_config/gfsh_persist.html">Overview of
<tr class="even">
<td><span class="keyword parmname">\-\-http-service-port</span></td>
<td>Specifies the port on which the HTTP service will listen.</td>
-<td></td>
+<td>7070</td>
</tr>
<tr class="even">
<td><span class="keyword parmname">\-\-http-service-bind-address</span></td>
<td>Specifies the IP address to which the HTTP service will be bound.
</td>
-<td>all local addresses</td>
+<td>the local host machine's address</td>
</tr>
<tr class="even">
<td><span class="keyword parmname">\-\-user</span></td>
[2/5] geode git commit: GEODE-2103 Revise http-service-port defn per
review
Posted by kl...@apache.org.
GEODE-2103 Revise http-service-port defn per review
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/fdb78052
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/fdb78052
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/fdb78052
Branch: refs/heads/feature/GEODE-2632-3
Commit: fdb7805292e34b7df998ac391b3ef98bc7778cbc
Parents: 3a4c6fc
Author: Karen Miller <km...@pivotal.io>
Authored: Wed Apr 19 13:45:28 2017 -0700
Committer: Karen Miller <km...@pivotal.io>
Committed: Wed Apr 19 13:45:28 2017 -0700
----------------------------------------------------------------------
geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/fdb78052/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb
----------------------------------------------------------------------
diff --git a/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb b/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb
index 60ba254..4cdab79 100644
--- a/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb
+++ b/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb
@@ -401,7 +401,7 @@ See <a href="../../../configuring/cluster_config/gfsh_persist.html">Overview of
</tr>
<tr class="even">
<td><span class="keyword parmname">\-\-http-service-port</span></td>
-<td>Specifies the port on which the HTTP service will listen.</td>
+<td>Specifies the HTTP service port.</td>
<td>7070</td>
</tr>
<tr class="even">
@@ -768,7 +768,7 @@ See <a href="../../../configuring/cluster_config/gfsh_persist.html">Overview of
</tr>
<tr class="even">
<td><span class="keyword parmname">\-\-http-service-port</span></td>
-<td>Specifies the port on which the HTTP service will listen.</td>
+<td>Specifies the HTTP service port.</td>
<td>7070</td>
</tr>
<tr class="even">
[3/5] geode git commit: Merge branch 'feature/GEODE-2103-2' into
develop
Posted by kl...@apache.org.
Merge branch 'feature/GEODE-2103-2' into develop
This closes #462
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/8ea0f906
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/8ea0f906
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/8ea0f906
Branch: refs/heads/feature/GEODE-2632-3
Commit: 8ea0f906917b40156d711717985b212364be72e1
Parents: 76c4983 fdb7805
Author: Karen Miller <km...@pivotal.io>
Authored: Wed Apr 19 13:49:51 2017 -0700
Committer: Karen Miller <km...@pivotal.io>
Committed: Wed Apr 19 13:49:51 2017 -0700
----------------------------------------------------------------------
.../gfsh/command-pages/start.html.md.erb | 21 ++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
[4/5] geode git commit: GEODE-2605: Modified gfsh search lucene to
require DATA:WRITE privilege to match client
Posted by kl...@apache.org.
GEODE-2605: Modified gfsh search lucene to require DATA:WRITE privilege to match client
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/9b49bc8f
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/9b49bc8f
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/9b49bc8f
Branch: refs/heads/feature/GEODE-2632-3
Commit: 9b49bc8fc53cb2520215e90930b2c9a27a918921
Parents: 8ea0f90
Author: Barry Oglesby <bo...@pivotal.io>
Authored: Mon Apr 17 12:45:31 2017 -0700
Committer: Barry Oglesby <bo...@pivotal.io>
Committed: Wed Apr 19 14:26:44 2017 -0700
----------------------------------------------------------------------
.../internal/cli/LuceneIndexCommands.java | 7 +-
.../lucene/LuceneClientSecurityDUnitTest.java | 128 ++++++++
.../lucene/LuceneCommandsSecurityDUnitTest.java | 303 +++++++++++++++++++
3 files changed, 433 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/9b49bc8f/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
index 3fa34e7..4bfa868 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
@@ -250,7 +250,6 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
@SuppressWarnings("unchecked")
protected List<LuceneIndexDetails> getIndexDetails(LuceneIndexInfo indexInfo) throws Exception {
- this.securityService.authorizeRegionManage(indexInfo.getRegionPath());
final ResultCollector<?, ?> rc =
executeFunctionOnRegion(describeIndexFunction, indexInfo, true);
final List<LuceneIndexDetails> funcResults = (List<LuceneIndexDetails>) rc.getResult();
@@ -262,7 +261,7 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
help = LuceneCliStrings.LUCENE_SEARCH_INDEX__HELP)
@CliMetaData(shellOnly = false,
relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
- @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
+ @ResourceOperation(resource = Resource.DATA, operation = Operation.WRITE)
public Result searchIndex(@CliOption(key = LuceneCliStrings.LUCENE__INDEX_NAME, mandatory = true,
help = LuceneCliStrings.LUCENE_SEARCH_INDEX__NAME__HELP) final String indexName,
@@ -531,8 +530,6 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
private List<LuceneSearchResults> getSearchResults(final LuceneQueryInfo queryInfo)
throws Exception {
- securityService.authorizeRegionManage(queryInfo.getRegionPath());
-
final String[] groups = {};
final ResultCollector<?, ?> rc = this.executeSearch(queryInfo);
final List<Set<LuceneSearchResults>> functionResults =
@@ -588,7 +585,7 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
@CliAvailabilityIndicator({LuceneCliStrings.LUCENE_SEARCH_INDEX,
LuceneCliStrings.LUCENE_CREATE_INDEX, LuceneCliStrings.LUCENE_DESCRIBE_INDEX,
- LuceneCliStrings.LUCENE_LIST_INDEX})
+ LuceneCliStrings.LUCENE_LIST_INDEX, LuceneCliStrings.LUCENE_DESTROY_INDEX})
public boolean indexCommandsAvailable() {
return (!CliUtil.isGfshVM() || (getGfsh() != null && getGfsh().isConnectedAndReady()));
}
http://git-wip-us.apache.org/repos/asf/geode/blob/9b49bc8f/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneClientSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneClientSecurityDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneClientSecurityDUnitTest.java
new file mode 100644
index 0000000..67103ff
--- /dev/null
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneClientSecurityDUnitTest.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.cache.lucene;
+
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientCacheFactory;
+import org.apache.geode.cache.client.ClientRegionShortcut;
+import org.apache.geode.cache.client.ServerOperationException;
+import org.apache.geode.cache.server.CacheServer;
+import org.apache.geode.security.NotAuthorizedException;
+import org.apache.geode.security.SimpleTestSecurityManager;
+import org.apache.geode.security.templates.UserPasswordAuthInit;
+import org.apache.geode.test.dunit.SerializableCallableIF;
+import org.apache.geode.test.dunit.SerializableRunnableIF;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.util.Properties;
+
+import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
+import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTH_INIT;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+@Category({DistributedTest.class, SecurityTest.class})
+@RunWith(JUnitParamsRunner.class)
+public class LuceneClientSecurityDUnitTest extends LuceneQueriesAccessorBase {
+
+ @Test
+ @Parameters(method = "getSearchIndexUserNameAndExpectedResponses")
+ public void verifySearchIndexPermissions(
+ LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse user) {
+ // Start server
+ int serverPort = dataStore1.invoke(startCacheServer());
+
+ // Create index and region
+ dataStore1.invoke(() -> createIndexAndRegion());
+
+ // Start client
+ accessor.invoke(() -> startClient(user.getUserName(), serverPort));
+
+ // Attempt query
+ accessor.invoke(
+ () -> executeTextSearch(user.getExpectAuthorizationError(), user.getExpectedResponse()));
+ }
+
+ private SerializableCallableIF<Integer> startCacheServer() {
+ return () -> {
+ Properties props = new Properties();
+ props.setProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName());
+ final Cache cache = getCache(props);
+ final CacheServer server = cache.addCacheServer();
+ server.setPort(0);
+ server.start();
+ LuceneService luceneService = LuceneServiceProvider.get(cache);
+ luceneService.createIndexFactory().addField("text").create(INDEX_NAME, REGION_NAME);
+ cache.createRegionFactory(RegionShortcut.PARTITION).create(REGION_NAME);
+ return server.getPort();
+ };
+ }
+
+ private SerializableRunnableIF createIndexAndRegion() {
+ return () -> {
+ Cache cache = getCache();
+ LuceneService luceneService = LuceneServiceProvider.get(cache);
+ luceneService.createIndexFactory().setFields("field1").create(INDEX_NAME, REGION_NAME);
+ cache.createRegionFactory(RegionShortcut.PARTITION).create(REGION_NAME);
+ };
+ }
+
+ private SerializableRunnableIF startClient(String userName, int serverPort) {
+ return () -> {
+ Properties props = new Properties();
+ props.setProperty("security-username", userName);
+ props.setProperty("security-password", userName);
+ props.setProperty(SECURITY_CLIENT_AUTH_INIT, UserPasswordAuthInit.class.getName());
+ ClientCacheFactory clientCacheFactory = new ClientCacheFactory(props);
+ clientCacheFactory.addPoolServer("localhost", serverPort);
+ ClientCache clientCache = getClientCache(clientCacheFactory);
+ clientCache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create(REGION_NAME);
+ };
+ }
+
+ private SerializableRunnableIF executeTextSearch(boolean expectAuthorizationError,
+ String expectedResponse) {
+ return () -> {
+ LuceneService service = LuceneServiceProvider.get(getCache());
+ LuceneQuery<Integer, TestObject> query =
+ service.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME, "test", "text");
+ try {
+ query.findKeys();
+ assertFalse(expectAuthorizationError);
+ } catch (ServerOperationException e) {
+ assertTrue(e.getCause() != null && e.getCause() instanceof NotAuthorizedException);
+ assertTrue(expectAuthorizationError);
+ assertTrue(e.getLocalizedMessage().contains(expectedResponse));
+ }
+ };
+ }
+
+ protected LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse[] getSearchIndexUserNameAndExpectedResponses() {
+ return new LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse[] {
+ new LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse("nopermissions", true,
+ "nopermissions not authorized for DATA:WRITE"),
+ new LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse("datawrite", false, null)};
+ }
+}
http://git-wip-us.apache.org/repos/asf/geode/blob/9b49bc8f/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java
new file mode 100644
index 0000000..ad734e8
--- /dev/null
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java
@@ -0,0 +1,303 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.cache.lucene;
+
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.cache.lucene.internal.cli.LuceneCliStrings;
+import org.apache.geode.cache.lucene.internal.cli.LuceneIndexCommands;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.CommandManager;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.CommandResult;
+import org.apache.geode.management.internal.cli.result.ErrorResultData;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.security.SimpleTestSecurityManager;
+import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
+import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@Category({DistributedTest.class, SecurityTest.class})
+@RunWith(JUnitParamsRunner.class)
+public class LuceneCommandsSecurityDUnitTest extends JUnit4CacheTestCase {
+
+ @Rule
+ public LocatorServerStartupRule locatorServer = new LocatorServerStartupRule();
+
+ @Rule
+ public GfshShellConnectionRule gfshShell = new GfshShellConnectionRule();
+
+ private MemberVM locator;
+
+ private MemberVM server;
+
+ @Before
+ public void before() throws Exception {
+ startLocator();
+ startServer();
+ }
+
+ private void startLocator() throws Exception {
+ Properties props = new Properties();
+ props.setProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName());
+ this.locator = this.locatorServer.startLocatorVM(0, props);
+ }
+
+ private void startServer() throws Exception {
+ Properties props = new Properties();
+ props.setProperty("security-username", "clustermanage");
+ props.setProperty("security-password", "clustermanage");
+ this.server = this.locatorServer.startServerVM(1, props, this.locator.getPort());
+ }
+
+ @Test
+ @Parameters(method = "getCreateIndexUserNameAndExpectedResponses")
+ public void verifyCreateIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
+ // Connect gfsh
+ this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
+ GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
+
+ // Attempt to create lucene index
+ CommandResult result = this.gfshShell.executeCommand(getCreateIndexCommand());
+
+ // Verify result
+ verifyResult(user, result);
+ }
+
+ @Test
+ @Parameters(method = "getSearchIndexUserNameAndExpectedResponses")
+ public void verifySearchIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
+ // Create index and region
+ createIndexAndRegion();
+
+ // Connect gfsh
+ this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
+ GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
+
+ // Attempt to search lucene index
+ CommandResult result = this.gfshShell.executeCommand(getSearchIndexCommand());
+
+ // Verify result
+ verifyResult(user, result);
+ }
+
+ @Test
+ @Parameters(method = "getListIndexesUserNameAndExpectedResponses")
+ public void verifyListIndexesPermissions(UserNameAndExpectedResponse user) throws Exception {
+ // Create index and region
+ createIndexAndRegion();
+
+ // Connect gfsh
+ this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
+ GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
+
+ // Attempt to search lucene index
+ CommandResult result = this.gfshShell.executeCommand(getListIndexesCommand());
+
+ // Verify result
+ verifyResult(user, result);
+ }
+
+ @Test
+ @Parameters(method = "getDescribeIndexUserNameAndExpectedResponses")
+ public void verifyDescribeIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
+ // Create index and region
+ createIndexAndRegion();
+
+ // Connect gfsh
+ this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
+ GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
+
+ // Attempt to search lucene index
+ CommandResult result = this.gfshShell.executeCommand(getDescribeIndexCommand());
+
+ // Verify result
+ verifyResult(user, result);
+ }
+
+ @Test
+ @Parameters(method = "getDestroyIndexUserNameAndExpectedResponses")
+ public void verifyDestroyIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
+ // Create index and region
+ createIndexAndRegion();
+
+ // Connect gfsh
+ this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
+ GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
+
+ // Attempt to search lucene index
+ CommandResult result = this.gfshShell.executeCommand(getDestroyIndexCommand());
+
+ // Verify result
+ verifyResult(user, result);
+ }
+
+ private void createIndexAndRegion() throws Exception {
+ // Connect gfsh to locator with permissions necessary to create an index and region
+ this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
+ GfshShellConnectionRule.PortType.locator, "datamanage", "datamanage");
+
+ // Create lucene index
+ this.gfshShell.executeAndVerifyCommand(getCreateIndexCommand());
+
+ // Create region
+ this.gfshShell.executeAndVerifyCommand(getCreateRegionCommand());
+
+ // Disconnect gfsh
+ this.gfshShell.disconnect();
+ }
+
+ private void verifyResult(UserNameAndExpectedResponse user, CommandResult result) {
+ if (user.getExpectAuthorizationError()) {
+ assertTrue(result.getResultData() instanceof ErrorResultData);
+ assertEquals(ResultBuilder.ERRORCODE_UNAUTHORIZED,
+ ((ErrorResultData) result.getResultData()).getErrorCode());
+ } else {
+ assertEquals(Result.Status.OK, result.getStatus());
+ }
+ assertTrue(this.gfshShell.getGfshOutput().contains(user.getExpectedResponse()));
+ }
+
+ private String getCreateIndexCommand() throws Exception {
+ CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance());
+ CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
+ csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+ csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+ csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1");
+ return csb.toString();
+ }
+
+ private String getCreateRegionCommand() throws Exception {
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);
+ csb.addOption(CliStrings.CREATE_REGION__REGION, REGION_NAME);
+ csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT,
+ RegionShortcut.PARTITION_REDUNDANT.name());
+ return csb.toString();
+ }
+
+ private String getSearchIndexCommand() throws Exception {
+ CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance());
+ CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_SEARCH_INDEX);
+ csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+ csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+ csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "field1:value1");
+ csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field1");
+ return csb.toString();
+ }
+
+ private String getListIndexesCommand() throws Exception {
+ CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX);
+ return csb.toString();
+ }
+
+ private String getDescribeIndexCommand() throws Exception {
+ CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESCRIBE_INDEX);
+ csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+ csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+ return csb.toString();
+ }
+
+ private String getDestroyIndexCommand() throws Exception {
+ CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance());
+ CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESTROY_INDEX);
+ csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+ csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+ return csb.toString();
+ }
+
+ protected UserNameAndExpectedResponse[] getCreateIndexUserNameAndExpectedResponses() {
+ return new UserNameAndExpectedResponse[] {
+ new UserNameAndExpectedResponse("nopermissions", true,
+ "Unauthorized. Reason : nopermissions not authorized for DATA:MANAGE:region"),
+ new UserNameAndExpectedResponse("datamanageregion", false,
+ "Successfully created lucene index")};
+ }
+
+ protected UserNameAndExpectedResponse[] getSearchIndexUserNameAndExpectedResponses() {
+ return new UserNameAndExpectedResponse[] {
+ new UserNameAndExpectedResponse("nopermissions", true,
+ "Unauthorized. Reason : nopermissions not authorized for DATA:WRITE"),
+ new UserNameAndExpectedResponse("datawrite", false, "No results")};
+ }
+
+ protected UserNameAndExpectedResponse[] getListIndexesUserNameAndExpectedResponses() {
+ return new UserNameAndExpectedResponse[] {
+ new UserNameAndExpectedResponse("nopermissions", true,
+ "Unauthorized. Reason : nopermissions not authorized for CLUSTER:READ"),
+ new UserNameAndExpectedResponse("clusterread", false, "Index Name")};
+ }
+
+ protected UserNameAndExpectedResponse[] getDescribeIndexUserNameAndExpectedResponses() {
+ return new UserNameAndExpectedResponse[] {
+ new UserNameAndExpectedResponse("nopermissions", true,
+ "Unauthorized. Reason : nopermissions not authorized for CLUSTER:READ"),
+ new UserNameAndExpectedResponse("clusterread", false, "Index Name")};
+ }
+
+ protected UserNameAndExpectedResponse[] getDestroyIndexUserNameAndExpectedResponses() {
+ return new UserNameAndExpectedResponse[] {
+ new UserNameAndExpectedResponse("nopermissions", true,
+ "Unauthorized. Reason : nopermissions not authorized for DATA:MANAGE:region"),
+ new UserNameAndExpectedResponse("datamanageregion", false,
+ "Successfully destroyed lucene index")};
+ }
+
+ public static class UserNameAndExpectedResponse implements Serializable {
+
+ private final String userName;
+
+ private final boolean expectAuthorizationError;
+
+ private final String expectedResponse;
+
+ public UserNameAndExpectedResponse(String userName, boolean expectAuthorizationError,
+ String expectedResponse) {
+ this.userName = userName;
+ this.expectAuthorizationError = expectAuthorizationError;
+ this.expectedResponse = expectedResponse;
+ }
+
+ public String getUserName() {
+ return this.userName;
+ }
+
+ public boolean getExpectAuthorizationError() {
+ return this.expectAuthorizationError;
+ }
+
+ public String getExpectedResponse() {
+ return this.expectedResponse;
+ }
+ }
+}
[5/5] geode git commit: 2632: refactor code to reduce
GemFireCacheImpl dependencies
Posted by kl...@apache.org.
2632: refactor code to reduce GemFireCacheImpl dependencies
* extract fetching GemFireCacheImpl to Provider interface/class
* use InternalCache instead of casting to Impl
* delete useless javadocs and comments
* reduce scope of constants, vars and methods
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/c03218b7
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/c03218b7
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/c03218b7
Branch: refs/heads/feature/GEODE-2632-3
Commit: c03218b7d81d136be4003460dab335fc886483f7
Parents: 9b49bc8
Author: Kirk Lund <kl...@apache.org>
Authored: Wed Apr 19 09:56:24 2017 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Wed Apr 19 14:56:35 2017 -0700
----------------------------------------------------------------------
.../web/controllers/AbstractBaseController.java | 194 +++++++++----------
.../web/controllers/BaseControllerAdvice.java | 28 ++-
.../web/controllers/CommonCrudController.java | 29 +--
.../controllers/FunctionAccessController.java | 39 ++--
.../web/controllers/PdxBasedCrudController.java | 28 ++-
.../web/controllers/QueryAccessController.java | 49 ++---
.../web/controllers/support/CacheProvider.java | 22 +++
.../controllers/support/CacheProviderImpl.java | 29 +++
8 files changed, 219 insertions(+), 199 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/c03218b7/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/AbstractBaseController.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/AbstractBaseController.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/AbstractBaseController.java
index 68080a3..d8eb572 100644
--- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/AbstractBaseController.java
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/AbstractBaseController.java
@@ -12,15 +12,44 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.rest.internal.web.controllers;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.annotation.PostConstruct;
+
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.logging.log4j.Logger;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.util.Assert;
+import org.springframework.util.ClassUtils;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
+
import org.apache.geode.SerializationException;
-import org.apache.geode.cache.Cache;
import org.apache.geode.cache.CacheLoaderException;
import org.apache.geode.cache.CacheWriterException;
import org.apache.geode.cache.LowMemoryException;
@@ -33,11 +62,12 @@ import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.distributed.LeaseExpiredException;
import org.apache.geode.distributed.internal.DistributionManager;
import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.pdx.JSONFormatter;
import org.apache.geode.pdx.JSONFormatterException;
import org.apache.geode.pdx.PdxInstance;
+import org.apache.geode.rest.internal.web.controllers.support.CacheProvider;
import org.apache.geode.rest.internal.web.controllers.support.JSONTypes;
import org.apache.geode.rest.internal.web.controllers.support.UpdateOp;
import org.apache.geode.rest.internal.web.exception.DataTypeNotSupportedException;
@@ -51,79 +81,49 @@ import org.apache.geode.rest.internal.web.util.IdentifiableUtils;
import org.apache.geode.rest.internal.web.util.JSONUtils;
import org.apache.geode.rest.internal.web.util.NumberUtils;
import org.apache.geode.rest.internal.web.util.ValidationUtils;
-import org.apache.logging.log4j.Logger;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.util.Assert;
-import org.springframework.util.ClassUtils;
-import org.springframework.util.CollectionUtils;
-import org.springframework.util.StringUtils;
-import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicLong;
-import javax.annotation.PostConstruct;
-
/**
* AbstractBaseController class contains common functionalities required for other controllers.
*
* @since GemFire 8.0
*/
-
@SuppressWarnings("unused")
public abstract class AbstractBaseController {
- protected static final String NEW_META_DATA_PROPERTY = "@new";
- protected static final String OLD_META_DATA_PROPERTY = "@old";
- protected static final String TYPE_META_DATA_PROPERTY = "@type";
- protected static final String UTF_8 = "UTF-8";
- protected static final String DEFAULT_ENCODING = UTF_8;
+ private static final String NEW_META_DATA_PROPERTY = "@new";
+ private static final String OLD_META_DATA_PROPERTY = "@old";
+ private static final String TYPE_META_DATA_PROPERTY = "@type";
+ private static final String UTF_8 = "UTF-8";
+ private static final String DEFAULT_ENCODING = UTF_8;
private static final Logger logger = LogService.getLogger();
private static final AtomicLong ID_SEQUENCE = new AtomicLong(0l);
- // private Cache cache = GemFireCacheImpl.getExisting(null);
@Autowired
- protected RestSecurityService securityService;
+ private RestSecurityService securityService;
@Autowired
private ObjectMapper objectMapper;
+ @Autowired
+ private CacheProvider cacheProvider;
@PostConstruct
private void init() {
JSONUtils.setObjectMapper(objectMapper);
}
- protected Cache getCache() {
- Cache cache = GemFireCacheImpl.getExisting();
+ protected InternalCache getCache() {
+ InternalCache cache = cacheProvider.getInternalCache();
Assert.state(cache != null, "The Gemfire Cache reference was not properly initialized");
return cache;
}
- protected URI toUri(final String... pathSegments) {
+ URI toUri(final String... pathSegments) {
return ServletUriComponentsBuilder.fromCurrentContextPath().path(getRestApiVersion())
.pathSegment(pathSegments).build().toUri();
}
protected abstract String getRestApiVersion();
- protected String validateQuery(String queryInUrl, String queryInBody) {
+ String validateQuery(String queryInUrl, String queryInBody) {
if (!(StringUtils.hasText(queryInUrl) || StringUtils.hasText(queryInBody))) {
throw new GemfireRestException("could not process null value specified in query String");
@@ -131,7 +131,7 @@ public abstract class AbstractBaseController {
return (StringUtils.hasText(queryInUrl) ? decode(queryInUrl) : queryInBody);
}
- protected String decode(final String value) {
+ String decode(final String value) {
if (value == null) {
throw new GemfireRestException("could not process null value specified in query String");
}
@@ -175,7 +175,7 @@ public abstract class AbstractBaseController {
}
@SuppressWarnings("unchecked")
- protected <T> T casValue(String regionNamePath, String key, String jsonData) {
+ private <T> T casValue(String regionNamePath, String key, String jsonData) {
JSONObject jsonObject;
try {
jsonObject = new JSONObject(jsonData);
@@ -189,7 +189,7 @@ public abstract class AbstractBaseController {
}
}
- public ResponseEntity<String> processQueryResponse(Query query, Object args[], Object queryResult)
+ ResponseEntity<String> processQueryResponse(Query query, Object args[], Object queryResult)
throws JSONException {
if (queryResult instanceof Collection<?>) {
Collection processedResults = new ArrayList(((Collection) queryResult).size());
@@ -207,7 +207,7 @@ public abstract class AbstractBaseController {
}
}
- protected Collection<PdxInstance> convertJsonArrayIntoPdxCollection(final String jsonArray) {
+ Collection<PdxInstance> convertJsonArrayIntoPdxCollection(final String jsonArray) {
JSONArray jsonArr = null;
try {
jsonArr = new JSONArray(jsonArray);
@@ -229,18 +229,7 @@ public abstract class AbstractBaseController {
}
}
-
- /*
- * protected PdxInstance convertJsonIntoPdxCollection(final String jsonArray) { JSONArray jsonArr
- * = null;
- *
- * PdxInstance pi = convert(jsonArray);
- * System.out.println("Successfully converted into PdxInstance..!!"); return pi;
- *
- * }
- */
-
- protected Object casValue(final String regionNamePath, final Object key, final Object oldValue,
+ private Object casValue(final String regionNamePath, final Object key, final Object oldValue,
final Object newValue) {
final Region<Object, Object> region = getRegion(regionNamePath);
try {
@@ -281,7 +270,7 @@ public abstract class AbstractBaseController {
}
}
- protected void replaceValue(final String regionNamePath, final Object key,
+ private void replaceValue(final String regionNamePath, final Object key,
final PdxInstance value) {
try {
if (getRegion(regionNamePath).replace(key, value) == null) {
@@ -367,7 +356,7 @@ public abstract class AbstractBaseController {
}
}
- protected void putValue(final String regionNamePath, final Object key, final Object value) {
+ private void putValue(final String regionNamePath, final Object key, final Object value) {
try {
getRegion(regionNamePath).put(key, value);
} catch (NullPointerException npe) {
@@ -397,23 +386,23 @@ public abstract class AbstractBaseController {
}
}
- protected void deleteQueryId(final String regionNamePath, final String key) {
+ private void deleteQueryId(final String regionNamePath, final String key) {
getQueryStore(regionNamePath).remove(key);
}
- protected void deleteNamedQuery(final String regionNamePath, final String key) {
+ void deleteNamedQuery(final String regionNamePath, final String key) {
// Check whether query ID exist in region or not
checkForQueryIdExist(regionNamePath, key);
deleteQueryId(regionNamePath, key);
}
- protected void checkForQueryIdExist(String region, String key) {
+ void checkForQueryIdExist(String region, String key) {
if (!getQueryStore(region).containsKey(key)) {
throw new ResourceNotFoundException(String.format("Named query (%1$s) does not exist!", key));
}
}
- protected Region<String, String> getQueryStore(final String namePath) {
+ Region<String, String> getQueryStore(final String namePath) {
return ValidationUtils.returnValueThrowOnNull(getCache().<String, String>getRegion(namePath),
new GemfireRestException(String.format("Query store does not exist!", namePath)));
}
@@ -436,8 +425,7 @@ public abstract class AbstractBaseController {
}
}
- protected void updateNamedQuery(final String regionNamePath, final String key,
- final String value) {
+ void updateNamedQuery(final String regionNamePath, final String key, final String value) {
try {
getQueryStore(regionNamePath).put(key, value);
} catch (NullPointerException npe) {
@@ -457,8 +445,7 @@ public abstract class AbstractBaseController {
}
@SuppressWarnings("unchecked")
- protected <T> T createNamedQuery(final String regionNamePath, final String key,
- final String value) {
+ <T> T createNamedQuery(final String regionNamePath, final String key, final String value) {
try {
return (T) getQueryStore(regionNamePath).putIfAbsent(key, value);
} catch (UnsupportedOperationException use) {
@@ -482,7 +469,7 @@ public abstract class AbstractBaseController {
}
}
- protected void putPdxValues(final String regionNamePath, final Map<Object, PdxInstance> map) {
+ private void putPdxValues(final String regionNamePath, final Map<Object, PdxInstance> map) {
try {
getRegion(regionNamePath).putAll(map);
} catch (LowMemoryException lme) {
@@ -490,7 +477,7 @@ public abstract class AbstractBaseController {
}
}
- protected void putValues(final String regionNamePath, final Map<Object, Object> values) {
+ private void putValues(final String regionNamePath, final Map<Object, Object> values) {
getRegion(regionNamePath).putAll(values);
}
@@ -510,7 +497,7 @@ public abstract class AbstractBaseController {
}
@SuppressWarnings("unchecked")
- protected <T> T postValue(final String regionNamePath, final Object key, final Object value) {
+ <T> T postValue(final String regionNamePath, final Object key, final Object value) {
try {
return (T) getRegion(regionNamePath).putIfAbsent(key, value);
} catch (UnsupportedOperationException use) {
@@ -561,11 +548,11 @@ public abstract class AbstractBaseController {
return actualValue;
}
- protected String generateKey(final String existingKey) {
+ String generateKey(final String existingKey) {
return generateKey(existingKey, null);
}
- protected String generateKey(final String existingKey, final Object domainObject) {
+ private String generateKey(final String existingKey, final Object domainObject) {
Object domainObjectId = IdentifiableUtils.getId(domainObject);
String newKey;
@@ -597,7 +584,7 @@ public abstract class AbstractBaseController {
return newKey;
}
- protected String decode(final String value, final String encoding) {
+ private String decode(final String value, final String encoding) {
try {
return URLDecoder.decode(value, encoding);
} catch (UnsupportedEncodingException e) {
@@ -612,19 +599,17 @@ public abstract class AbstractBaseController {
String.format("The Region identified by name (%1$s) could not be found!", namePath)));
}
- protected void checkForKeyExist(String region, String key) {
+ private void checkForKeyExist(String region, String key) {
if (!getRegion(region).containsKey(key)) {
throw new ResourceNotFoundException(
String.format("Key (%1$s) does not exist for region (%2$s) in cache!", key, region));
}
}
- protected List<String> checkForMultipleKeysExist(String region, String... keys) {
+ List<String> checkForMultipleKeysExist(String region, String... keys) {
List<String> unknownKeys = new ArrayList<String>();
for (int index = 0; index < keys.length; index++) {
if (!getRegion(region).containsKey(keys[index])) {
- // throw new ResourceNotFoundException(String.format("Key [(%1$s)] does not exist for region
- // [(%2$s)] in cache!", key, region));
unknownKeys.add(keys[index]);
}
}
@@ -664,11 +649,11 @@ public abstract class AbstractBaseController {
return entries.values();
}
- protected void deleteValue(final String regionNamePath, final Object key) {
+ private void deleteValue(final String regionNamePath, final Object key) {
getRegion(regionNamePath).remove(key);
}
- protected void deleteValues(final String regionNamePath, final Object... keys) {
+ void deleteValues(final String regionNamePath, final Object... keys) {
// Check whether all keys exist in cache or not
for (final Object key : keys) {
checkForKeyExist(regionNamePath, key.toString());
@@ -679,7 +664,7 @@ public abstract class AbstractBaseController {
}
}
- protected void deleteValues(String regionNamePath) {
+ void deleteValues(String regionNamePath) {
try {
getRegion(regionNamePath).clear();
} catch (UnsupportedOperationException ue) {
@@ -694,7 +679,7 @@ public abstract class AbstractBaseController {
}
@SuppressWarnings("unchecked")
- protected <T> T introspectAndConvert(final T value) {
+ private <T> T introspectAndConvert(final T value) {
if (value instanceof Map) {
final Map rawDataBinding = (Map) value;
@@ -736,15 +721,15 @@ public abstract class AbstractBaseController {
return value;
}
- protected String convertErrorAsJson(String errorMessage) {
+ String convertErrorAsJson(String errorMessage) {
return ("{" + "\"message\"" + ":" + "\"" + errorMessage + "\"" + "}");
}
- protected String convertErrorAsJson(Throwable t) {
+ String convertErrorAsJson(Throwable t) {
return String.format("{\"message\" : \"%1$s\"}", t.getMessage());
}
- protected Map<?, ?> convertJsonToMap(final String jsonString) {
+ private Map<?, ?> convertJsonToMap(final String jsonString) {
Map<String, String> map = new HashMap<String, String>();
// convert JSON string to Map
@@ -762,11 +747,11 @@ public abstract class AbstractBaseController {
return map;
}
- protected Object jsonToObject(final String jsonString) {
+ private Object jsonToObject(final String jsonString) {
return introspectAndConvert(convertJsonToMap(jsonString));
}
- protected Object[] jsonToObjectArray(final String arguments) {
+ Object[] jsonToObjectArray(final String arguments) {
final JSONTypes jsonType = validateJsonAndFindType(arguments);
if (JSONTypes.JSON_ARRAY.equals(jsonType)) {
try {
@@ -787,8 +772,8 @@ public abstract class AbstractBaseController {
}
}
- public ResponseEntity<String> updateSingleKey(final String region, final String key,
- final String json, final String opValue) {
+ ResponseEntity<String> updateSingleKey(final String region, final String key, final String json,
+ final String opValue) {
final JSONTypes jsonType = validateJsonAndFindType(json);
@@ -822,7 +807,7 @@ public abstract class AbstractBaseController {
}
- public ResponseEntity<String> updateMultipleKeys(final String region, final String[] keys,
+ ResponseEntity<String> updateMultipleKeys(final String region, final String[] keys,
final String json) {
JSONArray jsonArr = null;
@@ -862,7 +847,7 @@ public abstract class AbstractBaseController {
return new ResponseEntity<String>(headers, HttpStatus.OK);
}
- public JSONTypes validateJsonAndFindType(String json) {
+ JSONTypes validateJsonAndFindType(String json) {
try {
Object jsonObj = new JSONTokener(json).nextValue();
@@ -927,17 +912,16 @@ public abstract class AbstractBaseController {
}
protected Set<DistributedMember> getMembers(final String... memberIdNames) {
-
ValidationUtils.returnValueThrowOnNull(memberIdNames,
new GemfireRestException("No member found to run function"));
- final Set<DistributedMember> targetedMembers =
- new HashSet<DistributedMember>(ArrayUtils.length(memberIdNames));
+ final Set<DistributedMember> targetedMembers = new HashSet<>(ArrayUtils.length(memberIdNames));
final List<String> memberIdNameList = Arrays.asList(memberIdNames);
- GemFireCacheImpl c = (GemFireCacheImpl) getCache();
- Set<DistributedMember> distMembers = c.getDistributedSystem().getAllOtherMembers();
+
+ InternalCache cache = getCache();
+ Set<DistributedMember> distMembers = cache.getDistributedSystem().getAllOtherMembers();
// Add the local node to list
- distMembers.add(c.getDistributedSystem().getDistributedMember());
+ distMembers.add(cache.getDistributedSystem().getDistributedMember());
for (DistributedMember member : distMembers) {
if (memberIdNameList.contains(member.getId())
|| memberIdNameList.contains(member.getName())) {
@@ -947,10 +931,10 @@ public abstract class AbstractBaseController {
return targetedMembers;
}
- protected Set<DistributedMember> getAllMembersInDS() {
- GemFireCacheImpl c = (GemFireCacheImpl) getCache();
- Set<DistributedMember> distMembers = c.getDistributedSystem().getAllOtherMembers();
- final Set<DistributedMember> targetedMembers = new HashSet<DistributedMember>();
+ Set<DistributedMember> getAllMembersInDS() {
+ InternalCache cache = getCache();
+ Set<DistributedMember> distMembers = cache.getDistributedSystem().getAllOtherMembers();
+ final Set<DistributedMember> targetedMembers = new HashSet<>();
// find valid data nodes, i.e non locator, non-admin, non-loner nodes
for (DistributedMember member : distMembers) {
@@ -960,7 +944,7 @@ public abstract class AbstractBaseController {
}
}
// Add the local node to list
- targetedMembers.add(c.getDistributedSystem().getDistributedMember());
+ targetedMembers.add(cache.getDistributedSystem().getDistributedMember());
return targetedMembers;
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/c03218b7/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/BaseControllerAdvice.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/BaseControllerAdvice.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/BaseControllerAdvice.java
index 8939542..751e6a0 100644
--- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/BaseControllerAdvice.java
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/BaseControllerAdvice.java
@@ -12,16 +12,11 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.rest.internal.web.controllers;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.rest.internal.web.exception.DataTypeNotSupportedException;
-import org.apache.geode.rest.internal.web.exception.GemfireRestException;
-import org.apache.geode.rest.internal.web.exception.MalformedJsonException;
-import org.apache.geode.rest.internal.web.exception.RegionNotFoundException;
-import org.apache.geode.rest.internal.web.exception.ResourceNotFoundException;
-import org.apache.geode.security.NotAuthorizedException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
import org.apache.logging.log4j.Logger;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.AccessDeniedException;
@@ -31,24 +26,26 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.rest.internal.web.exception.DataTypeNotSupportedException;
+import org.apache.geode.rest.internal.web.exception.GemfireRestException;
+import org.apache.geode.rest.internal.web.exception.MalformedJsonException;
+import org.apache.geode.rest.internal.web.exception.RegionNotFoundException;
+import org.apache.geode.rest.internal.web.exception.ResourceNotFoundException;
+import org.apache.geode.security.NotAuthorizedException;
/**
* The CrudControllerAdvice class handles exception thrown while serving the REST request
- * <p/>
- *
+ *
* @since GemFire 8.0
*/
-
@ControllerAdvice
@SuppressWarnings("unused")
public class BaseControllerAdvice extends AbstractBaseController {
private static final Logger logger = LogService.getLogger();
- protected static final String REST_API_VERSION = "/v1";
+ private static final String REST_API_VERSION = "/v1";
@Override
protected String getRestApiVersion() {
@@ -186,4 +183,3 @@ public class BaseControllerAdvice extends AbstractBaseController {
}
}
-
http://git-wip-us.apache.org/repos/asf/geode/blob/c03218b7/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/CommonCrudController.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/CommonCrudController.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/CommonCrudController.java
index 62ce860..0449a45 100644
--- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/CommonCrudController.java
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/CommonCrudController.java
@@ -14,9 +14,24 @@
*/
package org.apache.geode.rest.internal.web.controllers;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
+import org.apache.logging.log4j.Logger;
+import org.json.JSONException;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
import org.apache.geode.cache.LowMemoryException;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.execute.Execution;
@@ -29,20 +44,6 @@ import org.apache.geode.rest.internal.web.controllers.support.RestServersResultC
import org.apache.geode.rest.internal.web.exception.GemfireRestException;
import org.apache.geode.rest.internal.web.util.ArrayUtils;
import org.apache.geode.rest.internal.web.util.JSONUtils;
-import org.apache.logging.log4j.Logger;
-import org.json.JSONException;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
/**
* The CommonCrudController serves REST Requests related to listing regions, listing keys in region,
http://git-wip-us.apache.org/repos/asf/geode/blob/c03218b7/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/FunctionAccessController.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/FunctionAccessController.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/FunctionAccessController.java
index e9b61f4..e83d7b5 100644
--- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/FunctionAccessController.java
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/FunctionAccessController.java
@@ -12,24 +12,17 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.rest.internal.web.controllers;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-import org.apache.geode.cache.LowMemoryException;
-import org.apache.geode.cache.execute.Execution;
-import org.apache.geode.cache.execute.Function;
-import org.apache.geode.cache.execute.FunctionException;
-import org.apache.geode.cache.execute.FunctionService;
-import org.apache.geode.cache.execute.ResultCollector;
-import org.apache.geode.internal.cache.execute.NoResult;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.rest.internal.web.exception.GemfireRestException;
-import org.apache.geode.rest.internal.web.util.ArrayUtils;
-import org.apache.geode.rest.internal.web.util.JSONUtils;
import org.apache.logging.log4j.Logger;
import org.json.JSONException;
import org.springframework.http.HttpHeaders;
@@ -47,10 +40,17 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import org.apache.geode.cache.LowMemoryException;
+import org.apache.geode.cache.execute.Execution;
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionException;
+import org.apache.geode.cache.execute.FunctionService;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.internal.cache.execute.NoResult;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.rest.internal.web.exception.GemfireRestException;
+import org.apache.geode.rest.internal.web.util.ArrayUtils;
+import org.apache.geode.rest.internal.web.util.JSONUtils;
/**
* The FunctionsController class serving REST Requests related to the function execution
@@ -58,20 +58,18 @@ import java.util.Set;
* @see org.springframework.stereotype.Controller
* @since GemFire 8.0
*/
-
@Controller("functionController")
@Api(value = "functions", description = "Rest api for gemfire function execution")
@RequestMapping(FunctionAccessController.REST_API_VERSION + "/functions")
@SuppressWarnings("unused")
public class FunctionAccessController extends AbstractBaseController {
// Constant String value indicating the version of the REST API.
- protected static final String REST_API_VERSION = "/v1";
+ static final String REST_API_VERSION = "/v1";
private static final Logger logger = LogService.getLogger();
/**
* Gets the version of the REST API implemented by this @Controller.
- * <p>
- *
+ *
* @return a String indicating the REST API version.
*/
@Override
@@ -256,4 +254,3 @@ public class FunctionAccessController extends AbstractBaseController {
}
}
}
-
http://git-wip-us.apache.org/repos/asf/geode/blob/c03218b7/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/PdxBasedCrudController.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/PdxBasedCrudController.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/PdxBasedCrudController.java
index 3b08c5f..a6f10b1 100644
--- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/PdxBasedCrudController.java
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/PdxBasedCrudController.java
@@ -14,16 +14,14 @@
*/
package org.apache.geode.rest.internal.web.controllers;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.rest.internal.web.controllers.support.JSONTypes;
-import org.apache.geode.rest.internal.web.controllers.support.RegionData;
-import org.apache.geode.rest.internal.web.controllers.support.RegionEntryData;
-import org.apache.geode.rest.internal.web.exception.ResourceNotFoundException;
-import org.apache.geode.rest.internal.web.util.ArrayUtils;
import org.apache.logging.log4j.Logger;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@@ -38,19 +36,20 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.rest.internal.web.controllers.support.JSONTypes;
+import org.apache.geode.rest.internal.web.controllers.support.RegionData;
+import org.apache.geode.rest.internal.web.controllers.support.RegionEntryData;
+import org.apache.geode.rest.internal.web.exception.ResourceNotFoundException;
+import org.apache.geode.rest.internal.web.util.ArrayUtils;
/**
* The PdxBasedCrudController class serving REST Requests related to the REST CRUD operation on
* region
- * <p/>
- *
+ *
* @see org.springframework.stereotype.Controller
* @since GemFire 8.0
*/
-
@Controller("pdxCrudController")
@Api(value = "region", description = "region CRUD operations")
@RequestMapping(PdxBasedCrudController.REST_API_VERSION)
@@ -59,9 +58,9 @@ public class PdxBasedCrudController extends CommonCrudController {
private static final Logger logger = LogService.getLogger();
- protected static final String REST_API_VERSION = "/v1";
+ static final String REST_API_VERSION = "/v1";
- protected static final String DEFAULT_GETALL_RESULT_LIMIT = "50";
+ private static final String DEFAULT_GETALL_RESULT_LIMIT = "50";
@Override
protected String getRestApiVersion() {
@@ -76,7 +75,6 @@ public class PdxBasedCrudController extends CommonCrudController {
* @param json JSON document that is stored against the key
* @return JSON document
*/
-
@RequestMapping(method = RequestMethod.POST, value = "/{region}",
consumes = MediaType.APPLICATION_JSON_VALUE, produces = {MediaType.APPLICATION_JSON_VALUE})
@ApiOperation(value = "create entry", notes = "Create (put-if-absent) data in region",
http://git-wip-us.apache.org/repos/asf/geode/blob/c03218b7/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/QueryAccessController.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/QueryAccessController.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/QueryAccessController.java
index b00a7aa..8007491 100644
--- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/QueryAccessController.java
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/QueryAccessController.java
@@ -12,28 +12,14 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.rest.internal.web.controllers;
+import java.util.concurrent.ConcurrentHashMap;
+
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.query.FunctionDomainException;
-import org.apache.geode.cache.query.NameResolutionException;
-import org.apache.geode.cache.query.Query;
-import org.apache.geode.cache.query.QueryExecutionLowMemoryException;
-import org.apache.geode.cache.query.QueryExecutionTimeoutException;
-import org.apache.geode.cache.query.QueryInvalidException;
-import org.apache.geode.cache.query.QueryInvocationTargetException;
-import org.apache.geode.cache.query.TypeMismatchException;
-import org.apache.geode.cache.query.internal.DefaultQuery;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.rest.internal.web.exception.GemfireRestException;
-import org.apache.geode.rest.internal.web.exception.ResourceNotFoundException;
-import org.apache.geode.rest.internal.web.util.JSONUtils;
-import org.apache.geode.rest.internal.web.util.ValidationUtils;
import org.apache.logging.log4j.Logger;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@@ -49,17 +35,28 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
-import java.util.concurrent.ConcurrentHashMap;
-
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.query.FunctionDomainException;
+import org.apache.geode.cache.query.NameResolutionException;
+import org.apache.geode.cache.query.Query;
+import org.apache.geode.cache.query.QueryExecutionLowMemoryException;
+import org.apache.geode.cache.query.QueryExecutionTimeoutException;
+import org.apache.geode.cache.query.QueryInvalidException;
+import org.apache.geode.cache.query.QueryInvocationTargetException;
+import org.apache.geode.cache.query.TypeMismatchException;
+import org.apache.geode.cache.query.internal.DefaultQuery;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.rest.internal.web.exception.GemfireRestException;
+import org.apache.geode.rest.internal.web.exception.ResourceNotFoundException;
+import org.apache.geode.rest.internal.web.util.JSONUtils;
+import org.apache.geode.rest.internal.web.util.ValidationUtils;
/**
* The QueryingController class serves all HTTP REST requests related to the gemfire querying
- * <p/>
- *
+ *
* @see org.springframework.stereotype.Controller
* @since GemFire 8.0
*/
-
@Controller("queryController")
@Api(value = "queries", description = "Rest api for geode query execution",
produces = MediaType.APPLICATION_JSON_VALUE)
@@ -69,17 +66,16 @@ public class QueryAccessController extends AbstractBaseController {
private static final Logger logger = LogService.getLogger();
- protected static final String PARAMETERIZED_QUERIES_REGION = "__ParameterizedQueries__";
+ private static final String PARAMETERIZED_QUERIES_REGION = "__ParameterizedQueries__";
private final ConcurrentHashMap<String, DefaultQuery> compiledQueries = new ConcurrentHashMap<>();
// Constant String value indicating the version of the REST API.
- protected static final String REST_API_VERSION = "/v1";
+ static final String REST_API_VERSION = "/v1";
/**
* Gets the version of the REST API implemented by this @Controller.
- * <p/>
- *
+ *
* @return a String indicating the REST API version.
*/
@Override
@@ -324,7 +320,6 @@ public class QueryAccessController extends AbstractBaseController {
logger.debug("Updating a named, parametrized Query ({}) with ID ({})...", oqlStatement,
queryId);
-
// update the OQL statement with 'queryId' as the Key into the hidden, Parametrized Queries
// Region...
checkForQueryIdExist(PARAMETERIZED_QUERIES_REGION, queryId);
@@ -334,7 +329,6 @@ public class QueryAccessController extends AbstractBaseController {
return new ResponseEntity<>(HttpStatus.OK);
}
- // delete named, parametrized query
/**
* Delete named, parametrized Query
*
@@ -360,4 +354,3 @@ public class QueryAccessController extends AbstractBaseController {
}
}
-
http://git-wip-us.apache.org/repos/asf/geode/blob/c03218b7/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/support/CacheProvider.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/support/CacheProvider.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/support/CacheProvider.java
new file mode 100644
index 0000000..19d2755
--- /dev/null
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/support/CacheProvider.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.rest.internal.web.controllers.support;
+
+import org.apache.geode.internal.cache.InternalCache;
+
+public interface CacheProvider {
+
+ InternalCache getInternalCache();
+}
http://git-wip-us.apache.org/repos/asf/geode/blob/c03218b7/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/support/CacheProviderImpl.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/support/CacheProviderImpl.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/support/CacheProviderImpl.java
new file mode 100644
index 0000000..8c00923
--- /dev/null
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/support/CacheProviderImpl.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.rest.internal.web.controllers.support;
+
+import org.springframework.stereotype.Component;
+
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
+
+@Component("cacheProvider")
+public class CacheProviderImpl implements CacheProvider {
+
+ @Override
+ public InternalCache getInternalCache() {
+ return GemFireCacheImpl.getExisting();
+ }
+}