Project

General

Profile

« Previous | Next » 

Revision 5446

Reformatted code to fix indenting.

View differences:

ResourceHandler.java
251 251
            loadSessionData();
252 252

  
253 253
            if (resource != null) {
254
                resource = request.getServletPath().substring(1);
254
            	resource = request.getServletPath().substring(1);
255 255

  
256
                params = new Hashtable<String, String[]>();
257
                initParams();
256
            	params = new Hashtable<String, String[]>();
257
            	initParams();
258 258

  
259
                Timer timer = new Timer();
260
                handler = new MetacatHandler(timer);
259
            	Timer timer = new Timer();
260
            	handler = new MetacatHandler(timer);
261 261

  
262
                if (resource.equals(RESOURCE_SESSION) && 
263
                    httpVerb == POST && 
264
                    params.get(FUNCTION_KEYWORD) != null) {
265
                    //System.out.println("function_keyword: " + params.get(FUNCTION_KEYWORD)[0]);
266
                        if (params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_LOGIN)) {
267
                            login();
268
                            status = true;
269
                        } else if (params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_LOGOUT)) {
270
                            logout();
271
                            status = true;
272
                        } else if (params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_SET_ACCESS)) {
273
                            setaccess();
274
                            status = true;
275
                            //System.out.println("done setting access");
276
                        }
277
                    } else if (resource.equals(RESOURCE_META)) {
278
                        if(params != null && params.get(FUNCTION_KEYWORD) != null &&
279
                           params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_GENERATE_MISSING_SYSTEM_METADATA))
280
                        { //generate system metadata for any object that is
281
                          //a) not system metadata itself
282
                          //b) does not already have a system metadata id in the systemmetadata table
283
                          //c) not a BIN object (data)
284
                            generateMissingSystemMetadata();
285
                            status = true;
286
                        }
287
                        else
288
                        {
289
                            String objectId = request.getPathInfo();
290
                            if (objectId != null && objectId.length() > 1) 
291
                            {
292
                                objectId = request.getPathInfo().substring(1);
293
                            }
294
                            getSystemMetadataObject(objectId);
295
                            status = true;
296
                        }
297
                            
298
                    } else if (resource.equals(RESOURCE_OBJECTS)) {
299
                    logMetacat.debug("D1 Rest: Starting resource processing...");
300
                    loadSessionData();
262
            	if (resource.equals(RESOURCE_SESSION) && 
263
            			httpVerb == POST && 
264
            			params.get(FUNCTION_KEYWORD) != null) {
265
            		//System.out.println("function_keyword: " + params.get(FUNCTION_KEYWORD)[0]);
266
            		if (params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_LOGIN)) {
267
            			login();
268
            			status = true;
269
            		} else if (params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_LOGOUT)) {
270
            			logout();
271
            			status = true;
272
            		} else if (params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_SET_ACCESS)) {
273
            			setaccess();
274
            			status = true;
275
            			//System.out.println("done setting access");
276
            		}
277
            	} else if (resource.equals(RESOURCE_META)) {
278
            		if(params != null && params.get(FUNCTION_KEYWORD) != null &&
279
            				params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_GENERATE_MISSING_SYSTEM_METADATA))
280
            		{ //generate system metadata for any object that is
281
            			//a) not system metadata itself
282
            			//b) does not already have a system metadata id in the systemmetadata table
283
            			//c) not a BIN object (data)
284
            			generateMissingSystemMetadata();
285
            			status = true;
286
            		}
287
            		else
288
            		{
289
            			String objectId = request.getPathInfo();
290
            			if (objectId != null && objectId.length() > 1) 
291
            			{
292
            				objectId = request.getPathInfo().substring(1);
293
            			}
294
            			getSystemMetadataObject(objectId);
295
            			status = true;
296
            		}
301 297

  
302
                    String objectId = request.getPathInfo();
303
                    if (objectId != null && objectId.length() > 1) 
304
                    {
305
                        objectId = request.getPathInfo().substring(1);
306
                    }
307
                    else
308
                    {
309
                        objectId = null;
310
                    }
311
                    
312
                    logMetacat.debug("verb:" + httpVerb);
298
            	} else if (resource.equals(RESOURCE_OBJECTS)) {
299
            		logMetacat.debug("D1 Rest: Starting resource processing...");
300
            		loadSessionData();
313 301

  
314
                    if (httpVerb == GET) {
315
                        getObject(objectId);
316
                        status = true;
317
                    } else if (httpVerb == POST) {
318
                        putObject(objectId, FUNCTION_NAME_INSERT);
319
                        status = true;
320
                    } else if (httpVerb == PUT) {
321
                        putObject(objectId, FUNCTION_NAME_UPDATE);
322
                        status = true;
323
                    } else if (httpVerb == DELETE) {
324
                        deleteObject(objectId);
325
                        status = true;
326
                    }
302
            		String objectId = request.getPathInfo();
303
            		if (objectId != null && objectId.length() > 1) 
304
            		{
305
            			objectId = request.getPathInfo().substring(1);
306
            		}
307
            		else
308
            		{
309
            			objectId = null;
310
            		}
327 311

  
328
                } else if (resource.equals(RESOURCE_IDENTIFIER)) {
312
            		logMetacat.debug("verb:" + httpVerb);
329 313

  
330
                    String identifierId = request.getPathInfo();
331
                    if (identifierId != null && identifierId.length() > 1)
332
                        identifierId = request.getPathInfo().substring(1); //trim the slash
314
            		if (httpVerb == GET) {
315
            			getObject(objectId);
316
            			status = true;
317
            		} else if (httpVerb == POST) {
318
            			putObject(objectId, FUNCTION_NAME_INSERT);
319
            			status = true;
320
            		} else if (httpVerb == PUT) {
321
            			putObject(objectId, FUNCTION_NAME_UPDATE);
322
            			status = true;
323
            		} else if (httpVerb == DELETE) {
324
            			deleteObject(objectId);
325
            			status = true;
326
            		}
333 327

  
334
                    if (httpVerb == GET) {
335
                        String op = params.get(FUNCTION_KEYWORD)[0];
336
                        if (op.equals(FUNCTION_NAME_ISREGISTERED)) {
337
                            isRegistered(identifierId);
338
                            status = true;
339
                        } else if (op.equals(FUNCTION_NAME_GETALLDOCS)) {
340
                            getAllDocIds();
341
                            status = true;
342
                        } else if (op.equals(FUNCTION_NAME_GETNEXTREV)) {
343
                            getNextRevision(identifierId);
344
                            status = true;
345
                        } else if (op.equals(FUNCTION_NAME_GETNEXTOBJ)) {
346
                            getNextObject();
347
                            status = true;
348
                        } 
328
            	} else if (resource.equals(RESOURCE_IDENTIFIER)) {
349 329

  
350
                    } else if (httpVerb == PUT) {
351
                        //Earthgrid API > Identifier Service > addLSID Function 
352
                        printError(
353
                                "This method is not supported by metacat.  To "
354
                                        + "add a new LSID, add a document to metacat.",
355
                                response);
356
                        status = true;
357
                    }
330
            		String identifierId = request.getPathInfo();
331
            		if (identifierId != null && identifierId.length() > 1)
332
            			identifierId = request.getPathInfo().substring(1); //trim the slash
358 333

  
359
                } else if (resource.equals(RESOURCE_LOG)) {
360
                    //handle log events
361
                    if(httpVerb == GET)
362
                    {
363
                        getLog();
364
                        status = true;
365
                    }
366
                    else
367
                    {
368
                        printError("POST, PUT, DELETE is not supported for logs.", response);
369
                        status = true;
370
                    }
371
                    
372
                }
373
                
374
                if (!status)
375
                    printError("Incorrect parameters!", response);
334
            		if (httpVerb == GET) {
335
            			String op = params.get(FUNCTION_KEYWORD)[0];
336
            			if (op.equals(FUNCTION_NAME_ISREGISTERED)) {
337
            				isRegistered(identifierId);
338
            				status = true;
339
            			} else if (op.equals(FUNCTION_NAME_GETALLDOCS)) {
340
            				getAllDocIds();
341
            				status = true;
342
            			} else if (op.equals(FUNCTION_NAME_GETNEXTREV)) {
343
            				getNextRevision(identifierId);
344
            				status = true;
345
            			} else if (op.equals(FUNCTION_NAME_GETNEXTOBJ)) {
346
            				getNextObject();
347
            				status = true;
348
            			} 
349

  
350
            		} else if (httpVerb == PUT) {
351
            			//Earthgrid API > Identifier Service > addLSID Function 
352
            			printError(
353
            					"This method is not supported by metacat.  To "
354
            					+ "add a new LSID, add a document to metacat.",
355
            					response);
356
            			status = true;
357
            		}
358

  
359
            	} else if (resource.equals(RESOURCE_LOG)) {
360
            		//handle log events
361
            		if(httpVerb == GET)
362
            		{
363
            			getLog();
364
            			status = true;
365
            		}
366
            		else
367
            		{
368
            			printError("POST, PUT, DELETE is not supported for logs.", response);
369
            			status = true;
370
            		}
371

  
372
            	}
373

  
374
            	if (!status)
375
            		printError("Incorrect parameters!", response);
376 376
            } else {
377
                printError("Incorrect resource!", response);
377
            	printError("Incorrect resource!", response);
378 378
            }
379 379
        } catch (Exception e) {
380
            logMetacat.error(e.getMessage());
381
            e.printStackTrace();
380
        	logMetacat.error(e.getMessage());
381
        	e.printStackTrace();
382 382
        }
383 383
    }
384 384
    

Also available in: Unified diff