Project

General

Profile

« Previous | Next » 

Revision 5630

Added by berkley about 14 years ago

fixed a couple bugs with dates and fixed a major bug where metacat was reading the entire document from the database everytime a DocumentImpl instance was created even though it didn't need to

View differences:

test/edu/ucsb/nceas/metacat/dataone/CrudServiceTest.java
100 100
		suite.addTest(new CrudServiceTest("testUpdate"));
101 101
		suite.addTest(new CrudServiceTest("testListObjects"));
102 102
		suite.addTest(new CrudServiceTest("testAccessControl"));
103
		suite.addTest(new CrudServiceTest("testGenerateMissingSystemMetadata"));
103
		//suite.addTest(new CrudServiceTest("testGenerateMissingSystemMetadata"));
104 104
		suite.addTest(new CrudServiceTest("testGetLogRecords"));
105 105
		suite.addTest(new CrudServiceTest("testChecksumError"));
106 106
		suite.addTest(new CrudServiceTest("testPublicAccess"));
......
260 260
	    printTestHeader("testChecksumError");
261 261
	    try
262 262
	    {
263
	        Date d1 = new Date();
263
	        Date d1 = new Date(new Date().getTime() - 5000);
264 264
	        CrudService cs = CrudService.getInstance();
265 265
	        AuthToken token = getToken();
266 266
	        ObjectFormat of1 = ObjectFormat.convert("eml://ecoinformatics.org/eml-2.1.0");
267 267
	        //create docs at different times
268 268

  
269 269
	        Identifier id = new Identifier();
270
	        String docid = generateDocumentId();
270
	        String docid = "test." + new Date().getTime();
271 271
	        id.setValue(docid);
272 272

  
273 273
	        //create the system metadata then run the create method
......
277 277
	        assertFalse(sm.getChecksum().getValue().startsWith("MD5"));
278 278
	        //create the doc
279 279
	        Identifier idC = cs.create(token, id, sbis, sm);
280
	        makeDocPublic(token, id, true);
280 281
	        assertTrue(idC.getValue().equals(id.getValue()));
281 282
	        SystemMetadata smC = getSystemMetadata(token, idC);
282 283
	        assertFalse(smC.getChecksum().getValue().startsWith("MD5"));
283 284
	        
284
	        Date d2 = new Date();
285
	        Date d2 = new Date(new Date().getTime() + 5000);
286
	        
285 287
	        ObjectList ol = cs.listObjects(token, d1, d2, of1);
286 288
	        assertTrue(ol.sizeObjectInfoList() > 0);
287 289
	        ObjectInfo oi = ol.getObjectInfo(0);
lib/metacat.properties
142 142

  
143 143
######## Authentication and LDAP ##############################################
144 144

  
145
auth.class=edu.ucsb.nceas.metacat.AuthLdap
145
#auth.class=edu.ucsb.nceas.metacat.AuthLdap
146 146
# Use AuthStub to test and guarantee authentication
147
## auth.class=edu.ucsb.nceas.metacat.AuthStub
147
auth.class=edu.ucsb.nceas.metacat.AuthStub
148 148
auth.timeoutMinutes=180
149 149
# auth.administrators=uid=jones,o=NCEAS,dc=ecoinformatics,dc=org
150 150
auth.administrators=
......
453 453
# Instead,  the system will use backed up configuration values.  If you 
454 454
# haven't ever configured the app (no backup files) the system will take 
455 455
# you through the configuration.
456
dev.runConfiguration=true
456
dev.runConfiguration=false
457 457

  
458 458

  
459 459
############# DataONE Section #######################################
src/edu/ucsb/nceas/metacat/MetacatHandler.java
977 977
            // to the id.
978 978
            docid = appendRev(docid);
979 979
            
980
            DocumentImpl doc = new DocumentImpl(docid);
980
            DocumentImpl doc = new DocumentImpl(docid, false);
981 981
            
982 982
            //check the permission for read
983 983
            if (!DocumentImpl.hasReadPermission(user, groups, docid)) {
......
1236 1236
            
1237 1237
            // this is metacat doc (data file or metadata doc)
1238 1238
            try {
1239
                DocumentImpl doc = new DocumentImpl(docid);
1239
                DocumentImpl doc = new DocumentImpl(docid, false);
1240 1240
                
1241 1241
                //check the permission for read
1242 1242
                if (!DocumentImpl.hasReadPermission(user, groups, docid)) {
......
1697 1697
                docid = params.get("docid")[0];
1698 1698
                
1699 1699
                // Get the document indicated from the db
1700
                DocumentImpl xmldoc = new DocumentImpl(docid);
1700
                DocumentImpl xmldoc = new DocumentImpl(docid, false);
1701 1701
                valtext = xmldoc.toString();
1702 1702
                
1703 1703
            } catch (NullPointerException npe) {
src/edu/ucsb/nceas/metacat/dataone/CrudService.java
107 107
    /**
108 108
     * singleton accessor
109 109
     */
110
    public static CrudService getInstance()
110
    public static CrudService getInstance() 
111 111
    {
112 112
      if(crudService == null)
113 113
      {
......
618 618
                  });
619 619
          params.put("anyfield", new String[] {PropertyService.getProperty("crudService.listObjects.anyfield")});
620 620
          
621
          /*System.out.println("query is: metacatUrl: " + metacatUrl + " user: " + sessionData.getUserName() +
622
                  " sessionid: " + sessionData.getId() + " params: ");
623
          String url = metacatUrl + "/metacat?action=query&sessionid=" + sessionData.getId();
621 624
          Enumeration keys = params.keys();
622 625
          while(keys.hasMoreElements())
623 626
          {
......
626 629
              for(int i=0; i<parr.length; i++)
627 630
              {
628 631
                  System.out.println("param " + key + ": " + parr[i]);
632
                  url += "&" + key + "=" + parr[i] ;
629 633
              }
630 634
          }
631
          
632
          //params.put("returndoctype", new String[] {"http://dataone.org/service/types/SystemMetadata/0.1"});
633
          //params.put("qformat", new String[] {"xml"});
634
          //params.put("returnfield", new String[] {"size", "originMemberNode", 
635
          //        "identifier", "objectFormat", "dateSysMetadataModified", "checksum", "checksum/@algorithm"});
636
          //params.put("anyfield", new String[] {"%"});
637
          
638
          System.out.println("query is: metacatUrl: " + metacatUrl + " user: " + sessionData.getUserName() +
639
             " sessionid: " + sessionData.getId() + " params: " + params.toString());
635
          System.out.println("query url: " + url);
636
          */
640 637
          String username = "public";
641 638
          String[] groups = null;
642 639
          String sessionid = "";
......
663 660
          for(int i=0; i<docs.size(); i++)
664 661
          {
665 662
              Document d = (Document)docs.get(i);
663
              
666 664
              ObjectFormat returnedObjectFormat = ObjectFormat.convert(d.getField("objectFormat"));
667 665
              
668 666
              if(returnedObjectFormat != null && 
......
706 704
              /*System.out.println("====================================");
707 705
              System.out.println("doc number " + i);
708 706
              System.out.println("docid: " + d.docid);
707
              System.out.println("guid: " + d.getField("identifier").trim());
708
              System.out.println("dateSMM: " + dateSMM);
709 709
              System.out.println("dateSysMetadataModified: " + dateSysMetadataModified);
710 710
              System.out.println("startTime: " + startTime);
711 711
              System.out.println("endtime: " + endTime);*/
......
781 781
              //System.out.println("processing doc " + d.docid);
782 782
              
783 783
              String dateSMM = d.getField("dateSysMetadataModified");
784
              //System.out.println("dateSMM: " + dateSMM);
785
              //System.out.println("parsed date: " + parseDate(dateSMM));
784 786
              Date dateSysMetadataModified = null;
785 787
              if(dateSMM != null)
786 788
              {
......
1038 1040
            throws InvalidToken, ServiceFailure, NotAuthorized, InvalidRequest, 
1039 1041
            NotImplemented 
1040 1042
    {
1041
        System.out.println("=================== Getting log records ===================");
1043
        /*System.out.println("=================== Getting log records ===================");
1042 1044
        System.out.println("Current server time is: " + new Date());
1043 1045
        if(fromDate != null)
1044 1046
        {
......
1047 1049
        if(toDate != null)
1048 1050
        {
1049 1051
          System.out.println("query end time is " + toDate);
1050
        }
1052
        }*/
1051 1053
        Log log = new Log();
1052 1054
        Vector<LogEntry> logs = new Vector<LogEntry>();
1053 1055
        IdentifierManager im = IdentifierManager.getInstance();
1054 1056
        EventLog el = EventLog.getInstance();
1055 1057
        if(fromDate == null)
1056 1058
        {
1057
            System.out.println("setting fromdate from null");
1059
            //System.out.println("setting fromdate from null");
1058 1060
            fromDate = new Date(1);
1059 1061
        }
1060 1062
        if(toDate == null)
1061 1063
        {
1062
            System.out.println("setting todate from null");
1064
            //System.out.println("setting todate from null");
1063 1065
            toDate = new Date();
1064 1066
        }
1065 1067
        
1066
        System.out.println("fromDate: " + fromDate);
1067
        System.out.println("toDate: " + toDate);
1068
        //System.out.println("fromDate: " + fromDate);
1069
        //System.out.println("toDate: " + toDate);
1068 1070
        
1069 1071
        String report = el.getReport(null, null, null, null, 
1070 1072
                new java.sql.Timestamp(fromDate.getTime()), 
......
1305 1307
                    new Integer(milliseconds).intValue());*/
1306 1308
            
1307 1309
            //d = DateFormat.getDateTimeInstance().parse(date + " " + time);
1308
            Calendar c = Calendar.getInstance(/*TimeZone.getTimeZone("GMT-0")*/TimeZone.getDefault());
1310
            Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT-0")/*TimeZone.getDefault()*/);
1309 1311
            c.set(new Integer(year).intValue(), new Integer(month).intValue() - 1, 
1310 1312
                  new Integer(day).intValue(), new Integer(hour).intValue(), 
1311 1313
                  new Integer(minute).intValue(), new Integer(seconds).intValue());
......
1535 1537
        try
1536 1538
        {
1537 1539
            String smId = IdentifierManager.getInstance().getSystemMetadataLocalId(sm.getIdentifier().getValue());
1540
            System.out.println("setting date modified to " + new Date());
1538 1541
            sm.setDateSysMetadataModified(new Date());
1539 1542
            String xml = new String(serializeSystemMetadata(sm).toByteArray());
1540 1543
            String localId = updateDocument(xml, sm.getIdentifier(), null, sessionData, true);
build.properties
18 18
# install ant target uses this to determine where to drop 
19 19
# the war file in an installation.  Test classes will use
20 20
# this value to find metacat.properties
21
app.deploy.dir=/tmp
21
app.deploy.dir=/Users/berkley/tools/tomcat/webapps
22 22

  
23 23
# CVS access to retrieve latest EML, seek and utilities 
24 24
cvsroot=:ext:${env.USER}@cvs.ecoinformatics.org:/cvs

Also available in: Unified diff