Project

General

Profile

« Previous | Next » 

Revision 6890

use PUT /obsoletedBy/{pid} for CNCore.setObsoletedBy per our discussion today

View differences:

src/edu/ucsb/nceas/metacat/restservice/CNResourceHandler.java
342 342
                        listChecksumAlgorithms();
343 343
                        status = true;
344 344
                    }
345
                } else if (resource.startsWith(Constants.RESOURCE_META_OBSOLETEDBY)
346
                        && httpVerb == PUT) {
347

  
348
                    logMetacat.debug("Using resource: "
349
                            + Constants.RESOURCE_META_OBSOLETEDBY);
350
                    // get the trailing pid
351
                    extra = parseTrailing(resource, Constants.RESOURCE_META_OBSOLETEDBY);
352
                    setObsoletedBy(extra);
353
                    status = true;
354

  
345 355
                }
346 356

  
347 357
                if (!status) {
......
1173 1183
        return result;
1174 1184

  
1175 1185
    }
1186
    
1187
    public boolean setObsoletedBy(String pid) throws NotImplemented,
1188
	    NotFound, NotAuthorized, ServiceFailure, InvalidRequest,
1189
	    InvalidToken, IOException, InstantiationException,
1190
	    IllegalAccessException, JiBXException, VersionMismatch {
1191
	
1192
	boolean result = false;
1193
	long serialVersion = 0L;
1194
	String serialVersionStr = null;
1195
	
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
	}
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
	
1220
	}
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
	}
1176 1228

  
1177 1229
    /**
1178 1230
     * Pass the request to set the replication status to CNodeService

Also available in: Unified diff