Project

General

Profile

« Previous | Next » 

Revision 6891

View differences:

src/edu/ucsb/nceas/metacat/restservice/CNResourceHandler.java
41 41
import org.apache.commons.io.IOUtils;
42 42
import org.apache.log4j.Logger;
43 43
import org.dataone.client.ObjectFormatCache;
44
import org.dataone.mimemultipart.MultipartRequest;
45
import org.dataone.mimemultipart.MultipartRequestResolver;
46 44
import org.dataone.service.exceptions.BaseException;
47 45
import org.dataone.service.exceptions.IdentifierNotUnique;
48 46
import org.dataone.service.exceptions.InsufficientResources;
......
81 79
import org.xml.sax.SAXException;
82 80

  
83 81
import edu.ucsb.nceas.metacat.dataone.CNodeService;
84
import edu.ucsb.nceas.metacat.dataone.MNodeService;
85 82
import edu.ucsb.nceas.metacat.properties.PropertyService;
86 83
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
87 84

  
......
351 348
                    extra = parseTrailing(resource, Constants.RESOURCE_META_OBSOLETEDBY);
352 349
                    setObsoletedBy(extra);
353 350
                    status = true;
351
                } else if (resource.startsWith(Constants.RESOURCE_REPLICATION_DELETE_REPLICA)
352
                        && httpVerb == PUT) {
354 353

  
354
                    logMetacat.debug("Using resource: "
355
                            + Constants.RESOURCE_REPLICATION_DELETE_REPLICA);
356
                    // get the trailing pid
357
                    extra = parseTrailing(resource, Constants.RESOURCE_REPLICATION_DELETE_REPLICA);
358
                    setObsoletedBy(extra);
359
                    status = true;
355 360
                }
356 361

  
357 362
                if (!status) {
......
1189 1194
	    InvalidToken, IOException, InstantiationException,
1190 1195
	    IllegalAccessException, JiBXException, VersionMismatch {
1191 1196
	
1192
	boolean result = false;
1193
	long serialVersion = 0L;
1194
	String serialVersionStr = null;
1197
		boolean result = false;
1198
		long serialVersion = 0L;
1199
		String serialVersionStr = null;
1200
		
1201
		Identifier identifier = new Identifier();
1202
		identifier.setValue(pid);
1203
		
1204
		Identifier obsoletedByPid = null;
1205
		try {
1206
			String obsoletedByPidString = params.get("obsoletedByPid")[0];
1207
			obsoletedByPid = new Identifier();
1208
			obsoletedByPid.setValue(obsoletedByPidString);
1209
		} catch (NullPointerException e) {
1210
		    String msg = "The 'obsoletedByPid' must be provided as a parameter and was not.";
1211
		    logMetacat.error(msg);
1212
		    throw new InvalidRequest("4883", msg);
1213
		}
1214
		
1215
		// get the serialVersion
1216
		try {
1217
		    serialVersionStr = params.get("serialVersion")[0];
1218
		    serialVersion = new Long(serialVersionStr).longValue();
1219
		
1220
		} catch (NullPointerException e) {
1221
		    String msg = "The 'serialVersion' must be provided as a parameter and was not.";
1222
		    logMetacat.error(msg);
1223
		    throw new InvalidRequest("4883", msg);
1224
		
1225
		}
1226
		result = CNodeService.getInstance(request).setObsoletedBy(
1227
		        session, identifier, obsoletedByPid, serialVersion);
1228
		response.setStatus(200);
1229
		response.setContentType("text/xml");
1230
		return result;
1195 1231
	
1196
	Identifier identifier = new Identifier();
1197
	identifier.setValue(pid);
1198
	
1199
	Identifier obsoletedByPid = null;
1200
	try {
1201
		String obsoletedByPidString = params.get("obsoletedByPid")[0];
1202
		obsoletedByPid = new Identifier();
1203
		obsoletedByPid.setValue(obsoletedByPidString);
1204
	} catch (NullPointerException e) {
1205
	    String msg = "The 'obsoletedByPid' must be provided as a parameter and was not.";
1206
	    logMetacat.error(msg);
1207
	    throw new InvalidRequest("4883", msg);
1208 1232
	}
1209
	
1210
	// get the serialVersion
1211
	try {
1212
	    serialVersionStr = params.get("serialVersion")[0];
1213
	    serialVersion = new Long(serialVersionStr).longValue();
1214
	
1215
	} catch (NullPointerException e) {
1216
	    String msg = "The 'serialVersion' must be provided as a parameter and was not.";
1217
	    logMetacat.error(msg);
1218
	    throw new InvalidRequest("4883", msg);
1219
	
1233
    
1234
    public boolean deleteReplica(String pid) throws NotImplemented, NotFound,
1235
			NotAuthorized, ServiceFailure, InvalidRequest, InvalidToken,
1236
			IOException, InstantiationException, IllegalAccessException,
1237
			JiBXException, VersionMismatch {
1238

  
1239
		boolean result = false;
1240
		long serialVersion = 0L;
1241
		String serialVersionStr = null;
1242

  
1243
		Identifier identifier = new Identifier();
1244
		identifier.setValue(pid);
1245

  
1246
		NodeReference nodeId = null;
1247
		try {
1248
			String nodeIdString = params.get("nodeId")[0];
1249
			nodeId = new NodeReference();
1250
			nodeId.setValue(nodeIdString);
1251
		} catch (NullPointerException e) {
1252
			String msg = "The 'nodeId' must be provided as a parameter and was not.";
1253
			logMetacat.error(msg);
1254
			throw new InvalidRequest("4883", msg);
1255
		}
1256

  
1257
		// get the serialVersion
1258
		try {
1259
			serialVersionStr = params.get("serialVersion")[0];
1260
			serialVersion = new Long(serialVersionStr).longValue();
1261

  
1262
		} catch (NullPointerException e) {
1263
			String msg = "The 'serialVersion' must be provided as a parameter and was not.";
1264
			logMetacat.error(msg);
1265
			throw new InvalidRequest("4883", msg);
1266

  
1267
		}
1268
		result = CNodeService.getInstance(request).deleteReplicationMetadata(session, identifier, nodeId, serialVersion);
1269
		response.setStatus(200);
1270
		response.setContentType("text/xml");
1271
		return result;
1272

  
1220 1273
	}
1221
	result = CNodeService.getInstance(request).setObsoletedBy(
1222
	        session, identifier, obsoletedByPid, serialVersion);
1223
	response.setStatus(200);
1224
	response.setContentType("text/xml");
1225
	return result;
1226
	
1227
	}
1228 1274

  
1229 1275
    /**
1230 1276
     * Pass the request to set the replication status to CNodeService

Also available in: Unified diff