Skip to content

Commit 368764c

Browse files
author
Mark
committed
added ArangoCollection.drop(isSystem)
1 parent 710c445 commit 368764c

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ v4.1.8 (2017-02-xx)
44
* changed java.sql.Date serialization from VPack.date to VPack.string (ISO 8601)
55
* changed java.sql.Timestamp serialization from VPack.date to VPack.string (ISO 8601)
66
* added byte[] de-/serialization from/to VPack.string (Base64)
7+
* added ArangoCollection.drop(isSystem)
78

89
v4.1.7 (2017-01-26)
910
---------------------------

src/main/java/com/arangodb/ArangoCollection.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,21 @@ public CollectionPropertiesEntity count() throws ArangoDBException {
658658
* @throws ArangoDBException
659659
*/
660660
public void drop() throws ArangoDBException {
661-
executor.execute(dropRequest(), Void.class);
661+
executor.execute(dropRequest(null), Void.class);
662+
}
663+
664+
/**
665+
* Drops the collection
666+
*
667+
* @see <a href="https://docs.arangodb.com/current/HTTP/Collection/Creating.html#drops-collection">API
668+
* Documentation</a>
669+
* @param isSystem
670+
* Whether or not the collection to drop is a system collection. This parameter must be set to true in
671+
* order to drop a system collection.
672+
* @throws ArangoDBException
673+
*/
674+
public void drop(final boolean isSystem) throws ArangoDBException {
675+
executor.execute(dropRequest(isSystem), Void.class);
662676
}
663677

664678
/**

src/main/java/com/arangodb/internal/ArangoDBConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,6 @@ public class ArangoDBConstants {
109109
public static final String COMPLETE = "complete";
110110
public static final String DETAILS = "details";
111111
public static final String TYPE = "type";
112+
public static final String IS_SYSTEM = "isSystem";
112113

113114
}

src/main/java/com/arangodb/internal/InternalArangoCollection.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,9 @@ protected Request createFulltextIndexRequest(final Collection<String> fields, fi
535535
return request;
536536
}
537537

538-
protected Request dropRequest() {
539-
return new Request(db, RequestType.DELETE, executor.createPath(ArangoDBConstants.PATH_API_COLLECTION, name));
538+
protected Request dropRequest(final Boolean isSystem) {
539+
return new Request(db, RequestType.DELETE, executor.createPath(ArangoDBConstants.PATH_API_COLLECTION, name))
540+
.putQueryParam(ArangoDBConstants.IS_SYSTEM, isSystem);
540541
}
541542

542543
protected Request loadRequest() {

src/test/java/com/arangodb/ArangoDatabaseTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,35 @@ public void deleteCollection() {
104104
}
105105
}
106106

107+
@Test
108+
public void deleteSystemCollection() {
109+
final String name = "_system_test";
110+
db.createCollection(name, new CollectionCreateOptions().isSystem(true));
111+
db.collection(name).drop(true);
112+
try {
113+
db.collection(name).getInfo();
114+
fail();
115+
} catch (final ArangoDBException e) {
116+
}
117+
}
118+
119+
@Test
120+
public void deleteSystemCollectionFail() {
121+
final String name = "_system_test";
122+
db.createCollection(name, new CollectionCreateOptions().isSystem(true));
123+
try {
124+
db.collection(name).drop();
125+
fail();
126+
} catch (final ArangoDBException e) {
127+
}
128+
db.collection(name).drop(true);
129+
try {
130+
db.collection(name).getInfo();
131+
fail();
132+
} catch (final ArangoDBException e) {
133+
}
134+
}
135+
107136
@Test
108137
public void getIndex() {
109138
try {

0 commit comments

Comments
 (0)