Skip to content

Commit dfca620

Browse files
Add tenant prefix to user and fabric names
1 parent c2bbac8 commit dfca620

13 files changed

+172
-156
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>co.macrometa</groupId>
55
<artifactId>c84j</artifactId>
6-
<version>1.1.24</version>
6+
<version>1.1.25-SNAPSHOT</version>
77
<inceptionYear>2019</inceptionYear>
88
<packaging>jar</packaging>
99

@@ -334,7 +334,7 @@
334334
<url>https://github.com/Macrometacorp/C84j.git</url>
335335
<connection>scm:git:git@github.com:Macrometacorp/C84j.git</connection>
336336
<developerConnection>scm:git:git@github.com:Macrometacorp/C84j.git</developerConnection>
337-
<tag>c84j-1.1.21</tag>
337+
<tag>c84j-1.1.25</tag>
338338
</scm>
339339

340340
<organization>

src/main/java/com/c8db/C8ApiKeys.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,30 @@ public interface C8ApiKeys extends C8SerializationAccessor {
2828
* @param keyId key id of a stream. ApiKey has the next structure: tenant.keyId.hash
2929
* @return result map of GeoFabrics' names with access levels for GeoFabric, collections and streams.
3030
*/
31-
Map<String, GeoFabricPermissions> getResourcesAccess(final String keyId);
31+
Map<String, GeoFabricPermissions> getResourcesPermissions(final String keyId);
3232

3333
/**
3434
* Get the GeoFabric access level
3535
* @param keyId key id of a stream. ApiKey has the next structure: tenant.keyId.hash
3636
* @return result of access level.
3737
*/
38-
Permissions getGeoFabricAccess(final String keyId);
38+
Permissions getGeoFabricPermissions(final String keyId);
3939

4040
/**
4141
* Get access level for streams
4242
* @param keyId key id of a stream. ApiKey has the next structure: tenant.keyId.hash
4343
* @param full Return the full set of access levels for all streams. If set to false, return the read-only streams.
4444
* @return result map of streams with access levels.
4545
*/
46-
Map<String, Permissions> getStreamsAccess(final String keyId, final boolean full);
46+
Map<String, Permissions> getStreamsPermissions(final String keyId, final boolean full);
4747

4848
/**
4949
* Get the stream access level
5050
* @param keyId key id of a stream. ApiKey has the next structure: tenant.keyId.hash
5151
* @param stream stream name
5252
* @return result of access level.
5353
*/
54-
Permissions getStreamAccess(final String keyId, final String stream);
54+
Permissions getStreamPermissions(final String keyId, final String stream);
5555

5656
// TODO: Implement other required apikeys features.
5757

src/main/java/com/c8db/C8DB.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -970,41 +970,6 @@ public synchronized C8DB build() {
970970
*/
971971
void grantDefaultCollectionAccess(String user, Permissions permissions) throws C8DBException;
972972

973-
/**
974-
* Get access level for all resources such as the GeoFabric as well as access level for collections and streams.
975-
*
976-
* @param user The name of the user
977-
* @return result map of GeoFabrics' names with access levels for GeoFabric, collections and streams.
978-
*/
979-
Map<String, GeoFabricPermissions> getResourcesAccess(final String user);
980-
981-
/**
982-
* Get access level for streams
983-
*
984-
* @param user The name of the user
985-
* @param full Return the full set of access levels for all streams. If set to false, return the read-only streams.
986-
* @return result map of streams with access levels.
987-
*/
988-
Map<String, Permissions> getStreamsAccess(final String user, final String fabric, final boolean full);
989-
990-
/**
991-
* Get the stream access level
992-
*
993-
* @param user The name of the user
994-
* @param stream The stream name
995-
* @return result of access level.
996-
*/
997-
Permissions getStreamAccess(final String user, final String fabric, final String stream);
998-
999-
/**
1000-
* Get the GeoFabric access level
1001-
*
1002-
* @param user The name of the user
1003-
* @param fabric The fabric of the user
1004-
* @return result of access level.
1005-
*/
1006-
Permissions getGeoFabricAccess(final String user, String fabric);
1007-
1008973
/**
1009974
* Generic Execute. Use this method to execute custom FOXX services.
1010975
*

src/main/java/com/c8db/C8Database.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.c8db.entity.CollectionEntity;
1212
import com.c8db.entity.DatabaseEntity;
1313
import com.c8db.entity.EdgeDefinition;
14+
import com.c8db.entity.GeoFabricPermissions;
1415
import com.c8db.entity.GraphEntity;
1516
import com.c8db.entity.IndexEntity;
1617
import com.c8db.entity.Permissions;
@@ -240,6 +241,41 @@ public interface C8Database extends C8SerializationAccessor {
240241
*/
241242
Permissions getPermissions(String user) throws C8DBException;
242243

244+
/**
245+
* Get access level for all resources such as the GeoFabric as well as access level for collections and streams.
246+
*
247+
* @param user The name of the user
248+
* @return result map of GeoFabrics' names with access levels for GeoFabric, collections and streams.
249+
*/
250+
Map<String, GeoFabricPermissions> getResourcesPermissions(final String user);
251+
252+
/**
253+
* Get access level for streams
254+
*
255+
* @param user The name of the user
256+
* @param full Return the full set of access levels for all streams. If set to false, return the read-only streams.
257+
* @return result map of streams with access levels.
258+
*/
259+
Map<String, Permissions> getStreamsPermissions(final String user, final String fabric, final boolean full);
260+
261+
/**
262+
* Get the GeoFabric access level
263+
*
264+
* @param user The name of the user
265+
* @param fabric The fabric of the user
266+
* @return result of access level.
267+
*/
268+
Permissions getGeoFabricPermissions(final String user, String fabric);
269+
270+
/**
271+
* Get the stream access level
272+
*
273+
* @param user The name of the user
274+
* @param stream The stream name
275+
* @return result of access level.
276+
*/
277+
Permissions getStreamPermissions(final String user, final String fabric, final String stream);
278+
243279
/**
244280
* Performs a database query using the given {@code query} and {@code bindVars},
245281
* then returns a new {@code C8Cursor} instance for the result list.

src/main/java/com/c8db/internal/C8ApiKeysImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ public ApiKeyEntity validateApiKey(String apikey) {
2424
}
2525

2626
@Override
27-
public Map<String, GeoFabricPermissions> getResourcesAccess(final String keyId) {
27+
public Map<String, GeoFabricPermissions> getResourcesPermissions(final String keyId) {
2828
return executor.execute(geoFabricsAccessLevelRequest(keyId, true), gatResourcesAccessResponseDeserializer());
2929
}
3030

3131
@Override
32-
public Permissions getGeoFabricAccess(String keyId) {
32+
public Permissions getGeoFabricPermissions(String keyId) {
3333
return executor.execute(geoFabricAccessLevelRequest(keyId), streamAccessLevelResponseDeserializer());
3434
}
3535

3636
@Override
37-
public Map<String, Permissions> getStreamsAccess(String keyId, boolean full) {
37+
public Map<String, Permissions> getStreamsPermissions(String keyId, boolean full) {
3838
return executor.execute(streamsAccessLevelRequest(keyId, full), listAccessesResponseDeserializer());
3939
}
4040

4141
@Override
42-
public Permissions getStreamAccess(String keyId, String stream) {
42+
public Permissions getStreamPermissions(String keyId, String stream) {
4343
return executor.execute(streamAccessLevelRequest(keyId, stream), streamAccessLevelResponseDeserializer());
4444
}
4545
}

src/main/java/com/c8db/internal/C8DBImpl.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -247,30 +247,6 @@ public void grantDefaultCollectionAccess(final String user, final Permissions pe
247247
executor.execute(updateUserDefaultCollectionAccessRequest(user, permissions), Void.class);
248248
}
249249

250-
@Override
251-
public Map<String, GeoFabricPermissions> getResourcesAccess(final String user) {
252-
return executor.execute(getAccessibleGeoFabricsForRequest(db().tenant(), db().name(), user, true),
253-
resourcesAccessesResponseDeserializer());
254-
}
255-
256-
@Override
257-
public Map<String, Permissions> getStreamsAccess(final String user, final String fabric, final boolean full)
258-
throws C8DBException {
259-
return executor.execute(getUserStreamsAccessRequest(user, fabric, full), listAccessesResponseDeserializer());
260-
}
261-
262-
@Override
263-
public Permissions getStreamAccess(final String user, final String fabric, final String stream)
264-
throws C8DBException {
265-
return executor.execute(getUserStreamAccessRequest(user, fabric, stream), accessResponseDeserializer());
266-
}
267-
268-
@Override
269-
public Permissions getGeoFabricAccess(final String user, final String fabric)
270-
throws C8DBException {
271-
return executor.execute(getUserAccessRequest(user, fabric), accessResponseDeserializer());
272-
}
273-
274250
@Override
275251
public Response execute(final Request request) throws C8DBException {
276252
return executor.execute(request, new ResponseDeserializer<Response>() {

src/main/java/com/c8db/internal/C8DatabaseImpl.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.c8db.entity.CursorEntity;
2828
import com.c8db.entity.DatabaseEntity;
2929
import com.c8db.entity.EdgeDefinition;
30+
import com.c8db.entity.GeoFabricPermissions;
3031
import com.c8db.entity.GraphEntity;
3132
import com.c8db.entity.IndexEntity;
3233
import com.c8db.entity.Permissions;
@@ -173,6 +174,30 @@ public Permissions getPermissions(final String user) throws C8DBException {
173174
return executor.execute(getPermissionsRequest(user), getPermissionsResponseDeserialzer());
174175
}
175176

177+
@Override
178+
public Map<String, GeoFabricPermissions> getResourcesPermissions(final String user) {
179+
return executor.execute(getResourcesRequest(user, true),
180+
resourcesPermissionsResponseDeserializer());
181+
}
182+
183+
@Override
184+
public Map<String, Permissions> getStreamsPermissions(final String user, final String fabric, final boolean full)
185+
throws C8DBException {
186+
return executor.execute(getUserStreamsAccessRequest(user, fabric, full), listPermissionsResponseDeserializer());
187+
}
188+
189+
@Override
190+
public Permissions getGeoFabricPermissions(final String user, final String fabric)
191+
throws C8DBException {
192+
return executor.execute(getUserPermissionsRequest(user, fabric), permissionsResponseDeserializer());
193+
}
194+
195+
@Override
196+
public Permissions getStreamPermissions(final String user, final String fabric, final String stream)
197+
throws C8DBException {
198+
return executor.execute(getUserStreamPermissionsRequest(user, fabric, stream), permissionsResponseDeserializer());
199+
}
200+
176201
@Override
177202
public <T> C8Cursor<T> query(final String query, final Map<String, Object> bindVars,
178203
final C8qlQueryOptions options, final Class<T> type) throws C8DBException {

src/main/java/com/c8db/internal/C8RequestParam.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ private C8RequestParam() {
2828
public static final String SYSTEM = "_system";
2929
public static final String DEMO_TENANT = "demo";
3030
public static final String DATABASE = "database";
31+
public static final String COLLECTION = "collection";
3132
public static final String STREAM = "stream";
3233
public static final String WAIT_FOR_SYNC = "waitForSync";
3334
public static final String IF_NONE_MATCH = "If-None-Match";

src/main/java/com/c8db/internal/InternalC8ApiKeys.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import java.util.Map;
2222

23+
import static com.c8db.internal.InternalC8Database.QUERY_PARAM_FULL;
24+
2325
/**
2426
* Internal request/response related functions.
2527
*/
@@ -54,30 +56,30 @@ protected Request validateApiKeyRequest(final String apikey) {
5456
}
5557

5658
protected Request geoFabricsAccessLevelRequest(final String keyId, boolean full) {
57-
final Request request = request(db.tenant(), db.name(), RequestType.GET, PATH_API_KEY, keyId,
58-
C8RequestParam.DATABASE);
59-
request.putQueryParam("full", full);
59+
final Request request = request(null, null, RequestType.GET, PATH_API_KEY,
60+
String.join("." ,db.tenant(), keyId), C8RequestParam.DATABASE);
61+
request.putQueryParam(QUERY_PARAM_FULL, full);
6062
return request;
6163
}
6264

6365
protected Request geoFabricAccessLevelRequest(final String keyId) {
64-
final Request request = request(db.tenant(), db.name(), RequestType.GET, PATH_API_KEY, keyId,
65-
C8RequestParam.DATABASE, db.name());
66+
final Request request = request(null, null, RequestType.GET, PATH_API_KEY,
67+
String.join("." ,db.tenant(), keyId), C8RequestParam.DATABASE, String.join("." ,db.tenant(), db.name()));
6668
return request;
6769
}
6870

6971
protected Request streamsAccessLevelRequest(final String keyId, final boolean full) {
70-
final Request request = request(db.tenant(), db.name(), RequestType.GET, PATH_API_KEY, keyId,
71-
C8RequestParam.DATABASE, db.name(), C8RequestParam.STREAM);
72+
final Request request = request(null, null, RequestType.GET, PATH_API_KEY,
73+
String.join("." ,db.tenant(), keyId), C8RequestParam.DATABASE, String.join("." ,db.tenant(), db.name()), C8RequestParam.STREAM);
7274
if (full) {
73-
request.putQueryParam("full", true);
75+
request.putQueryParam(QUERY_PARAM_FULL, true);
7476
}
7577
return request;
7678
}
7779

7880
protected Request streamAccessLevelRequest(final String keyId, final String stream) {
79-
final Request request = request(db.tenant(), db.name(), RequestType.GET, PATH_API_KEY, keyId,
80-
C8RequestParam.DATABASE, db.name(), C8RequestParam.STREAM, stream);
81+
final Request request = request(db.tenant(), db.name(), RequestType.GET, PATH_API_KEY,
82+
String.join("." ,db.tenant(), keyId), C8RequestParam.DATABASE, String.join("." ,db.tenant(), db.name()), C8RequestParam.STREAM, stream);
8183
return request;
8284
}
8385

0 commit comments

Comments
 (0)