Project

General

Profile

« Previous | Next » 

Revision 7153

handle 'archive' rest calls
https://redmine.dataone.org/issues/2678

View differences:

src/edu/ucsb/nceas/metacat/restservice/MNResourceHandler.java
113 113
 * 		create() - POST /d1/mn/object/PID
114 114
 * 		update() - PUT /d1/mn/object/PID
115 115
 * 		delete() - DELETE /d1/mn/object/PID
116
 * 		archive() - PUT /d1/mn/archive/PID
117

  
116 118
 *    systemMetadataChanged() - POST /dirtySystemMetadata/PID
117 119
 * 	
118 120
 * 	MNReplication
......
258 260
                        getLog();
259 261
                        status = true;
260 262
                    }
263
                } else if (resource.startsWith(Constants.RESOURCE_ARCHIVE)) {
264
                    logMetacat.debug("Using resource " + Constants.RESOURCE_ARCHIVE);
265
                    // handle archive events
266
                    if (httpVerb == PUT) {
267
                        extra = parseTrailing(resource, Constants.RESOURCE_ARCHIVE);
268
                        archive(extra);
269
                        status = true;
270
                    }
261 271
                } else if (resource.startsWith(Constants.RESOURCE_CHECKSUM)) {
262 272
                    logMetacat.debug("Using resource 'checksum'");
263 273
                    // handle checksum requests
......
1157 1167
        MNodeService.getInstance(request).delete(session, id);
1158 1168
        TypeMarshaller.marshalTypeToOutputStream(id, out);
1159 1169
        
1160
    }    
1170
    }
1171
    
1172
    /**
1173
     * Archives the given pid
1174
     * @param pid
1175
     * @throws InvalidToken
1176
     * @throws ServiceFailure
1177
     * @throws NotAuthorized
1178
     * @throws NotFound
1179
     * @throws NotImplemented
1180
     * @throws IOException
1181
     * @throws JiBXException
1182
     */
1183
    private void archive(String pid) throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented, IOException, JiBXException {
1161 1184

  
1185
        OutputStream out = response.getOutputStream();
1186
        response.setStatus(200);
1187
        response.setContentType("text/xml");
1188

  
1189
        Identifier id = new Identifier();
1190
        id.setValue(pid);
1191

  
1192
        logMetacat.debug("Calling delete");
1193
        MNodeService.getInstance(request).archive(session, id);
1194
        
1195
        TypeMarshaller.marshalTypeToOutputStream(id, out);
1196
        
1197
    }
1198

  
1162 1199
	protected SynchronizationFailed collectSynchronizationFailed() throws IOException, ServiceFailure, InvalidRequest, JiBXException, InstantiationException, IllegalAccessException, ParserConfigurationException, SAXException  {
1163 1200
		
1164 1201
		// Read the incoming data from its Mime Multipart encoding

Also available in: Unified diff