Project

General

Profile

« Previous | Next » 

Revision 5414

Added by berkley over 14 years ago

fixed listObject bugs, added params to the listObjects rest interface, consolidated the date format passed in params

View differences:

test/edu/ucsb/nceas/metacat/dataone/CrudServiceTest.java
87 87
	public static Test suite() 
88 88
	{
89 89
		TestSuite suite = new TestSuite();
90
		/*suite.addTest(new CrudServiceTest("initialize"));
90
		suite.addTest(new CrudServiceTest("initialize"));
91 91
		suite.addTest(new CrudServiceTest("testSingletonAccessor"));
92 92
		suite.addTest(new CrudServiceTest("testCreateAndGet"));
93 93
		suite.addTest(new CrudServiceTest("testGetSystemMetadata"));
94
		suite.addTest(new CrudServiceTest("testUpdate"));*/
94
		suite.addTest(new CrudServiceTest("testUpdate"));
95 95
		suite.addTest(new CrudServiceTest("testListObjects"));
96
		/*suite.addTest(new CrudServiceTest("testAccessControl"));
96
		suite.addTest(new CrudServiceTest("testAccessControl"));
97 97
		suite.addTest(new CrudServiceTest("testGenerateMissingSystemMetadata"));
98 98
		suite.addTest(new CrudServiceTest("testGetLogRecords"));
99 99
		suite.addTest(new CrudServiceTest("testChecksumError"));
100
		suite.addTest(new CrudServiceTest("testPublicAccess"));*/
100
		suite.addTest(new CrudServiceTest("testPublicAccess"));
101 101
		return suite;
102 102
	}
103 103
	
src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java
211 211
    private static final String FUNCTION_NAME_UPDATE = "update";
212 212
    private static final String FUNCTION_NAME_GENERATE_MISSING_SYSTEM_METADATA = "generatemissingsystemmetadata";
213 213

  
214
    private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'");
215
    
214 216
    private ServletContext servletContext;
215 217
    private Logger logMetacat;
216 218
    private MetacatHandler handler;
......
402 404
            SimpleDateFormat sdf = new SimpleDateFormat();
403 405
            if(fromDateS != null)
404 406
            {
405
                fromDate = new Date(new Long(fromDateS).longValue());//sdf.parse(fromDateS, new ParsePosition(0));
407
                //fromDate = new Date(new Long(fromDateS).longValue());//sdf.parse(fromDateS, new ParsePosition(0));
408
                fromDate = dateFormat.parse(fromDateS);
406 409
            }
407 410
            if(toDateS != null)
408 411
            {
409
                toDate = new Date(new Long(toDateS).longValue());//sdf.parse(toDateS, new ParsePosition(0));
412
                //toDate = new Date(new Long(toDateS).longValue());//sdf.parse(toDateS, new ParsePosition(0));
413
                toDate = dateFormat.parse(toDateS);
410 414
            }
411 415
            if(eventS != null)
412 416
            {
......
633 637
                { //parse the params and make the crud call
634 638
                    String name = (String) paramlist.nextElement();
635 639
                    String[] value = (String[])request.getParameterValues(name);
636
                    for(int i=0; i<value.length; i++)
640
                    /*for(int i=0; i<value.length; i++)
637 641
                    {
638 642
                        System.out.println("name: " + name + " value: " + value[i]);
639
                    }
643
                    }*/
640 644
                    if(name.equals("startTime") && value != null)
641 645
                    {
642 646
                        try
643 647
                        {
644
                          startTime = DateFormat.getDateTimeInstance().parse(value[0]);
648
                          startTime = dateFormat.parse(value[0]);
645 649
                        }
646 650
                        catch(Exception e)
647 651
                        {  //if we can't parse it, just don't use the startTime param
......
653 657
                    {
654 658
                        try
655 659
                        {
656
                          endTime = DateFormat.getDateTimeInstance().parse(value[0]);
660
                          endTime = dateFormat.parse(value[0]);
657 661
                        }
658 662
                        catch(Exception e)
659 663
                        {  //if we can't parse it, just don't use the endTime param
......
696 700
                StringReader sr = new StringReader(ol.toString());                
697 701
                out = response.getOutputStream();                
698 702
                // Serialize and write it to the output stream
703
                System.out.println("list size: " + ol.sizeObjectInfoList());
704
                
699 705
                try {
700 706
                    serializeServiceType(ObjectList.class, ol, out);
701 707
                } catch (JiBXException e) {
......
705 711
        } catch (BaseException e) {
706 712
                serializeException(e, out);
707 713
        } catch (IOException e) {
708
            ServiceFailure sf = new ServiceFailure("1030", e.getMessage());
714
            e.printStackTrace();
715
            ServiceFailure sf = new ServiceFailure("1030", 
716
                    "Error in ResourceHandler.getObject: " + e.getMessage());
709 717
            serializeException(sf, out);
710 718
        }
711 719
    }
......
734 742
        } catch (BaseException e) {
735 743
                serializeException(e, out);
736 744
        } catch (IOException e) {
737
            ServiceFailure sf = new ServiceFailure("1030", e.getMessage());
745
            ServiceFailure sf = new ServiceFailure("1030", 
746
                    "Error in ResourceHandler.getSystemMetadataObject: " + e.getMessage());
738 747
            serializeException(sf, out);
739 748
        } finally {
740 749
            IOUtils.closeQuietly(out);
src/edu/ucsb/nceas/metacat/dataone/CrudService.java
608 608
                  info.setSize(new Long(size.trim()).longValue());
609 609
              }
610 610
              //add the ObjectInfo to the ObjectList
611
              ol.addObjectInfo(info);
611
              if(info.getIdentifier().getValue() != null)
612
              { //id can be null from tests.  should not happen in production.
613
                  ol.addObjectInfo(info);
614
              }
612 615
          }
613 616
      }
614 617
      catch(Exception e)

Also available in: Unified diff