Skip to content

Commit 17b4ed4

Browse files
author
WANGF
committed
Change default of withBackup to allow null and default with setting value.
1 parent 4ed8e7d commit 17b4ed4

5 files changed

Lines changed: 17 additions & 6 deletions

File tree

core/src/main/java/org/fao/geonet/kernel/setting/Settings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public class Settings {
144144
public static final String METADATA_HISTORY_ENABLED = "metadata/history/enabled";
145145
public static final String METADATA_HISTORY_ACCESS_LEVEL = "metadata/history/accesslevel";
146146
public static final String METADATA_PUBLISHED_DELETE_USERPROFILE = "metadata/delete/profilePublishedMetadata";
147+
public static final String METADATA_DELETE_ENABLEBACKUP = "metadata/delete/enablebackup";
147148
public static final String METADATA_PUBLISH_USERPROFILE = "metadata/publication/profilePublishMetadata";
148149
public static final String METADATA_UNPUBLISH_USERPROFILE = "metadata/publication/profileUnpublishMetadata";
149150
public static final String METADATA_BACKUPARCHIVE_ENABLE = "metadata/backuparchive/enable";

core/src/test/resources/org/fao/geonet/api/Messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ api.metadata.share.ErrorUserNotAllowedToPublish=User not allowed to publish the
246246
api.metadata.share.strategy.groupOwnerOnly=You need to be administrator, or reviewer of the metadata group.
247247
api.metadata.share.strategy.reviewerInGroup=You need to be administrator, or reviewer of the metadata group or reviewer with edit privilege on the metadata.
248248
api.metadata.status.errorSetStatusNotAllowed=Only the owner of the metadata can set the status of this record. User is not the owner of the metadata.
249+
api.metadata.delete.errorWithBackupParamMismatch=The setting metadata/delete/enablebackup: '%s' mismatched the API parameter withBackup '%s'.
249250

250251
feedback_subject_userFeedback=User feedback
251252

services/src/main/java/org/fao/geonet/api/records/MetadataInsertDeleteApi.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,18 @@ public class MetadataInsertDeleteApi {
215215
@ResponseStatus(HttpStatus.NO_CONTENT)
216216
public void deleteRecord(
217217
@Parameter(description = API_PARAM_RECORD_UUID, required = true) @PathVariable String metadataUuid,
218-
@Parameter(description = API_PARAM_BACKUP_FIRST, required = false) @RequestParam(required = false, defaultValue = "true") boolean withBackup,
218+
@Parameter(description = API_PARAM_BACKUP_FIRST, required = false) @RequestParam(required = false) Boolean withBackup,
219219
HttpServletRequest request) throws Exception {
220+
boolean isMdDeleteBackupEnable = settingManager.getValueAsBool(Settings.METADATA_DELETE_ENABLEBACKUP);
221+
if (withBackup == null) {
222+
Log.info(LOGGER, String.format("withBackup paramter is missing. Will use setting of metadata/delete/enablebackup '%s' during the deletion process", isMdDeleteBackupEnable));
223+
withBackup = isMdDeleteBackupEnable;
224+
} else if (withBackup != isMdDeleteBackupEnable) {
225+
ResourceBundle messages = ApiUtils.getMessagesResourceBundle(request.getLocales());
226+
throw new IllegalArgumentException(
227+
String.format(messages.getString("api.metadata.delete.errorWithBackupParamMismatch"), isMdDeleteBackupEnable, withBackup));
228+
}
229+
220230
AbstractMetadata metadata = ApiUtils.canEditRecord(metadataUuid, request);
221231
ServiceContext context = ApiUtils.createServiceContext(request);
222232
Store store = context.getBean("resourceStore", Store.class);

web-ui/src/main/resources/catalog/components/catalog/CatalogService.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@
6161
* Delete a metadata from catalog
6262
*
6363
* @param {string} id Internal id of the metadata
64-
* @param {string} backupMetadata flag to enable backup during the delete process
6564
* @return {HttpPromise} Future object
6665
*/
67-
remove: function (id, backupMetadata) {
68-
return $http.delete("../api/records/" + id, {params: {withBackup: backupMetadata}});
66+
remove: function (id) {
67+
return $http.delete("../api/records/" + id);
6968
},
7069

7170
/**

web-ui/src/main/resources/catalog/components/metadataactions/MetadataActionService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@
268268
this.deleteMd = function (md, bucket) {
269269
var deferred = $q.defer();
270270
if (md) {
271-
gnMetadataManager.remove(md.id, gnConfig["metadata.delete.enablebackup"]).then(
271+
gnMetadataManager.remove(md.id).then(
272272
function (data) {
273273
$timeout(function () {
274274
$rootScope.$broadcast("search");
@@ -308,7 +308,7 @@
308308
};
309309

310310
this.cancelWorkingCopy = function (md) {
311-
return gnMetadataManager.remove(md.id, gnConfig["metadata.delete.enablebackup"]);
311+
return gnMetadataManager.remove(md.id);
312312
};
313313

314314
this.getMetadataIdToEdit = function (md) {

0 commit comments

Comments
 (0)