Skip to content

Commit 5e5ec09

Browse files
committed
UY-1572: CR-1374: Rename "export" and "import" endpoints to "db-dump"
- Update REST API paths and documentation to use "/db-dump" for both export and import operations. - Adapt scripts and unit tests to reflect the new endpoint naming. - Adjust example requests and other references for consistency.
1 parent 5d050b1 commit 5e5ec09

4 files changed

Lines changed: 15 additions & 19 deletions

File tree

.claude/skills/unity-server/scripts/tstserver.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ cmd_verify() {
104104
fi
105105

106106
echo "Verifying server health..."
107-
if curl -sk -o /dev/null -w "%{http_code}" -u "$AUTH" "$REST_ADMIN_URL/export?systemConfig=false&directorySchema=false&users=false&auditLogs=false&signupRequests=false&idpStatistics=false" | grep -q "200"; then
107+
if curl -sk -o /dev/null -w "%{http_code}" -u "$AUTH" "$REST_ADMIN_URL/db-dump?systemConfig=false&directorySchema=false&users=false&auditLogs=false&signupRequests=false&idpStatistics=false" | grep -q "200"; then
108108
echo "Server is healthy and responding at $SERVER_URL"
109109
else
110110
echo "Server is running but REST Admin API is not responding yet"
@@ -119,7 +119,7 @@ cmd_backup() {
119119
local params="$*"
120120

121121
echo "Exporting backup to $output..."
122-
local url="$REST_ADMIN_URL/export"
122+
local url="$REST_ADMIN_URL/db-dump"
123123
if [ -n "$params" ]; then
124124
url="$url?$params"
125125
fi
@@ -142,7 +142,7 @@ cmd_restore() {
142142

143143
echo "Restoring from $input..."
144144
# Import may cause connection reset as server restarts endpoints — treat both as success
145-
curl -sk -u "$AUTH" -X POST "$REST_ADMIN_URL/import" \
145+
curl -sk -u "$AUTH" -X POST "$REST_ADMIN_URL/db-dump" \
146146
-H "Content-Type: application/json" \
147147
-d @"$input" || true
148148
echo "Restore request sent. Server endpoints may restart."

documentation/src/main/rest-api/rest-api-v1.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ Example input:
16701670

16711671
=== Export database backup
16721672

1673-
+@Path("/export")+ +
1673+
+@Path("/db-dump")+ +
16741674
+@QueryParam("systemConfig")+ +
16751675
+@QueryParam("directorySchema")+ +
16761676
+@QueryParam("users")+ +
@@ -1690,8 +1690,6 @@ Parameters:
16901690
- +signupRequests+ (boolean, default: true) -- include pending registration requests
16911691
- +idpStatistics+ (boolean, default: true) -- include IdP usage statistics
16921692

1693-
Requires +maintenance+ authorization capability (System Manager role).
1694-
16951693
Example response headers:
16961694

16971695
----
@@ -1702,21 +1700,19 @@ Content-Type: application/json
17021700

17031701
=== Import database backup
17041702

1705-
+@Path("/import")+ +
1703+
+@Path("/db-dump")+ +
17061704
+@POST+ +
17071705

17081706
Imports (restores) the database from a JSON dump provided as the raw request body. The request body must be a valid Unity database dump in JSON format (as produced by the export endpoint). Older dump formats are automatically migrated during import.
17091707

1710-
Requires +maintenance+ authorization capability (System Manager role).
1711-
17121708
CAUTION: The import operation restarts internal server endpoints. The calling REST endpoint may be destroyed before the HTTP response is sent, causing the client to receive a connection reset instead of an HTTP 200. Clients should treat both a 200 response and a connection reset as a successful import.
17131709

17141710
NOTE: Uploads exceeding the server's configured file size limit are rejected with HTTP 413 (Request Entity Too Large). When no static limit is configured, the limit is calculated dynamically as 70% of available JVM heap memory.
17151711

17161712
Example request:
17171713

17181714
----
1719-
POST /rest-admin/v1/import HTTP/1.1
1715+
POST /rest-admin/v1/db-dump HTTP/1.1
17201716
Content-Type: application/json
17211717

17221718
{...database dump JSON content...}

rest-admin/src/main/java/pl/edu/icm/unity/restadm/BackupRestoreRESTAdmin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class BackupRestoreRESTAdmin implements RESTAdminHandler
6161
}
6262

6363
@GET
64-
@Path("/export")
64+
@Path("/db-dump")
6565
public Response export(
6666
@QueryParam("systemConfig") @DefaultValue("true") boolean systemConfig,
6767
@QueryParam("directorySchema") @DefaultValue("true") boolean directorySchema,
@@ -108,7 +108,7 @@ private String createTimestampedFilename()
108108
}
109109

110110
@POST
111-
@Path("/import")
111+
@Path("/db-dump")
112112
@Consumes(MediaType.APPLICATION_JSON)
113113
public Response importBackup(InputStream inputStream,
114114
@HeaderParam("Content-Length") long contentLength) throws EngineException

rest-admin/src/test/java/pl/edu/icm/unity/restadm/TestBackupRestore.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class TestBackupRestore extends RESTAdminTestBase
2828
public void shouldReturnExportDumpWithDefaultCategories() throws Exception
2929
{
3030
// given
31-
HttpGet export = new HttpGet("/restadm/v1/export");
31+
HttpGet export = new HttpGet("/restadm/v1/db-dump");
3232

3333
// when
3434
try (ClassicHttpResponse response = client.executeOpen(host, export, getClientContext(host)))
@@ -51,7 +51,7 @@ public void shouldRespectCategorySelection() throws Exception
5151
{
5252
// given
5353
HttpGet export = new HttpGet(
54-
"/restadm/v1/export?directorySchema=false&users=false"
54+
"/restadm/v1/db-dump?directorySchema=false&users=false"
5555
+ "&auditLogs=false&signupRequests=false&idpStatistics=false");
5656

5757
// when
@@ -69,7 +69,7 @@ public void shouldReturnDumpWhenAllCategoriesExplicitlyEnabled() throws Exceptio
6969
{
7070
// given
7171
HttpGet export = new HttpGet(
72-
"/restadm/v1/export?systemConfig=true&directorySchema=true&users=true"
72+
"/restadm/v1/db-dump?systemConfig=true&directorySchema=true&users=true"
7373
+ "&auditLogs=true&signupRequests=true&idpStatistics=true");
7474

7575
// when
@@ -86,7 +86,7 @@ public void shouldReturnDumpWhenAllCategoriesExplicitlyEnabled() throws Exceptio
8686
public void shouldImportDatabaseFromExportedDump() throws Exception
8787
{
8888
// given -- first export to get a valid dump
89-
HttpGet export = new HttpGet("/restadm/v1/export");
89+
HttpGet export = new HttpGet("/restadm/v1/db-dump");
9090
String dumpContent;
9191
try (ClassicHttpResponse exportResponse = client.executeOpen(host, export, getClientContext(host)))
9292
{
@@ -96,7 +96,7 @@ public void shouldImportDatabaseFromExportedDump() throws Exception
9696
}
9797

9898
// when -- import the exported dump back
99-
HttpPost importRequest = new HttpPost("/restadm/v1/import");
99+
HttpPost importRequest = new HttpPost("/restadm/v1/db-dump");
100100
importRequest.setEntity(new StringEntity(dumpContent, ContentType.APPLICATION_JSON));
101101
try (ClassicHttpResponse importResponse = client.executeOpen(host, importRequest, getClientContext(host)))
102102
{
@@ -118,7 +118,7 @@ public void shouldRejectExportForNonPrivilegedUserWith403() throws Exception
118118
{
119119
// given
120120
HttpClientContext unprivilegedContext = createNonPrivilegedUserContext();
121-
HttpGet export = new HttpGet("/restadm/v1/export");
121+
HttpGet export = new HttpGet("/restadm/v1/db-dump");
122122

123123
// when
124124
try (ClassicHttpResponse response = client.executeOpen(host, export, unprivilegedContext))
@@ -133,7 +133,7 @@ public void shouldRejectImportForNonPrivilegedUserWith403() throws Exception
133133
{
134134
// given
135135
HttpClientContext unprivilegedContext = createNonPrivilegedUserContext();
136-
HttpPost importRequest = new HttpPost("/restadm/v1/import");
136+
HttpPost importRequest = new HttpPost("/restadm/v1/db-dump");
137137
importRequest.setEntity(new StringEntity("{}", ContentType.APPLICATION_JSON));
138138

139139
// when

0 commit comments

Comments
 (0)