Skip to content

Commit

Permalink
Delete metadata / Add a parameter to not create backup file. This wil…
Browse files Browse the repository at this point in the history
…l allow to avoid failure if 2 records with same UUID are inserted using CSW #609
  • Loading branch information
François Prunayre committed Aug 8, 2014
1 parent 54eb065 commit c04383a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions core/src/main/java/org/fao/geonet/constants/Params.java
Expand Up @@ -27,6 +27,7 @@
* Constants for service parameters (elements and attributes).
*/
public final class Params {
public static final String BACKUP_FILE = "backup_file";
public static final String ACCESS = "access";
public static final String BTN = "btn";
public static final String RECURSE = "recurse";
Expand Down
Expand Up @@ -28,7 +28,9 @@
import jeeves.server.UserSession;
import jeeves.server.context.ServiceContext;
import org.fao.geonet.GeonetContext;
import org.fao.geonet.Util;
import org.fao.geonet.constants.Geonet;
import org.fao.geonet.constants.Params;
import org.fao.geonet.domain.Metadata;
import org.fao.geonet.domain.MetadataType;
import org.fao.geonet.kernel.AccessManager;
Expand Down Expand Up @@ -68,6 +70,7 @@ public Element serviceSpecificExec(Element params, ServiceContext context) throw
Set<Integer> metadata = new HashSet<Integer>();
Set<Integer> notFound = new HashSet<Integer>();
Set<Integer> notOwner = new HashSet<Integer>();
boolean backupFile = Util.getParam(params, Params.BACKUP_FILE, true);

if(context.isDebugEnabled())
context.debug("Get selected metadata");
Expand All @@ -94,7 +97,7 @@ public Element serviceSpecificExec(Element params, ServiceContext context) throw
} else {

//--- backup metadata in 'removed' folder
if (info.getDataInfo().getType() != MetadataType.SUB_TEMPLATE) {
if (backupFile && info.getDataInfo().getType() != MetadataType.SUB_TEMPLATE) {
backupFile(context, id, info.getUuid(), MEFLib.doExport(context, info.getUuid(), "full", false, true, false));
}

Expand Down
Expand Up @@ -24,6 +24,8 @@
package org.fao.geonet.services.metadata;

import jeeves.constants.Jeeves;
import org.fao.geonet.Util;
import org.fao.geonet.constants.Params;
import org.fao.geonet.domain.Metadata;
import org.fao.geonet.domain.MetadataType;
import org.fao.geonet.exceptions.OperationNotAllowedEx;
Expand Down Expand Up @@ -60,6 +62,7 @@ public Element serviceSpecificExec(Element params, ServiceContext context) throw
DataManager dataMan = gc.getBean(DataManager.class);
AccessManager accessMan = gc.getBean(AccessManager.class);

boolean backupFile = Util.getParam(params, Params.BACKUP_FILE, true);
String id = Utils.getIdentifierFromParameters(params, context);

// If send a non existing uuid, Utils.getIdentifierFromParameters returns null
Expand All @@ -80,7 +83,7 @@ public Element serviceSpecificExec(Element params, ServiceContext context) throw
//-----------------------------------------------------------------------
//--- backup metadata in 'removed' folder

if (metadata.getDataInfo().getType() != MetadataType.SUB_TEMPLATE)
if (metadata.getDataInfo().getType() != MetadataType.SUB_TEMPLATE && backupFile)
backupFile(context, id, metadata.getUuid(), MEFLib.doExport(context, metadata.getUuid(), "full", false, true, false));

//-----------------------------------------------------------------------
Expand Down

0 comments on commit c04383a

Please sign in to comment.