Project

General

Profile

« Previous | Next » 

Revision 6793

Add collectReplicationStatus() to CNResourcHandler to return the BaseException or it's subclass, if any, provided in the the call to setReplicationStatus. The exception will be reported on the CN.

View differences:

src/edu/ucsb/nceas/metacat/restservice/D1ResourceHandler.java
61 61

  
62 62
import edu.ucsb.nceas.metacat.MetacatHandler;
63 63
import edu.ucsb.nceas.metacat.properties.PropertyService;
64
import edu.ucsb.nceas.utilities.Log;
64 65
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
65 66
/**
66 67
 * 
......
168 169
    }
169 170

  
170 171
    /**
172
     * Parse the BaseException information for replication status failures if any
173
     * 
174
     * @return failure  the BaseException failure, one of it's subclasses, or null
175
     * @throws ServiceFailure
176
     * @throws InvalidRequest
177
     * @throws JiBXException 
178
     * @throws IllegalAccessException 
179
     * @throws InstantiationException 
180
     * @throws IOException 
181
     */
182
    protected BaseException collectReplicationStatus() 
183
        throws ServiceFailure, InvalidRequest, IOException, 
184
        InstantiationException, IllegalAccessException, JiBXException {
185
        
186
        BaseException failure = null;
187
        File tmpDir = getTempDirectory();
188
        MultipartRequest mr = null;
189
        Map<String, File> mmFileParts = null;
190
        File exceptionFile = null;
191
        InputStream exceptionFileStream = null;
192

  
193
        // Read the incoming data from its Mime Multipart encoding
194
        logMetacat.debug("Parsing BaseException from the mime multipart entity");
195

  
196
        // handle MMP inputs
197
        MultipartRequestResolver mrr = 
198
            new MultipartRequestResolver(tmpDir.getAbsolutePath(),1000000000, 0);
199

  
200
        try {
201
            mr = mrr.resolveMultipart(request);
202
            logMetacat.debug("Resolved the replication status BaseException multipart request.");
203
            
204
        } catch (IOException e) {
205
            throw new ServiceFailure("4700", "Couldn't resolve the multipart request: " +
206
                e.getMessage());
207
            
208
        } catch (FileUploadException e) {
209
            throw new ServiceFailure("4700", "Couldn't resolve the multipart request: " +
210
                e.getMessage());
211
            
212
        } catch (Exception e) {
213
            throw new ServiceFailure("4700", "Couldn't resolve the multipart request: " +
214
                e.getMessage());
215
            
216
        }
217

  
218
        // get the map of file parts
219
        mmFileParts = mr.getMultipartFiles();
220
        
221
        if ( mmFileParts == null || mmFileParts.keySet() == null) {
222
            logMetacat.debug("BaseException for setReplicationStatus is null");            
223
        }
224
        
225
        multipartparams = mr.getMultipartParameters();
226
        exceptionFile = mmFileParts.get("failure");
227
        
228
        if ( exceptionFile != null ) {
229
            
230
            // deserialize the ReplicationPolicy
231
            exceptionFileStream = new FileInputStream(exceptionFile);
232
            failure = TypeMarshaller.unmarshalTypeFromStream(BaseException.class, exceptionFileStream);
233
                
234
        }
235
        
236
        
237
        return failure;
238
        
239
    }
240
    
241
    /**
171 242
     * Parse the replication policy document out of the mime-multipart form data
172 243
     * 
173 244
     * @return policy  the encoded policy
......
206 277
            
207 278
        } catch (FileUploadException e) {
208 279
            throw new ServiceFailure("4882", "Couldn't resolve the multipart request: " +
209
                    e.getMessage());
280
                e.getMessage());
210 281
            
211 282
        } catch (Exception e) {
212 283
            throw new ServiceFailure("4882", "Couldn't resolve the multipart request: " +
213
                    e.getMessage());
284
                e.getMessage());
214 285
            
215 286
        }
216 287
        

Also available in: Unified diff