Project

General

Profile

« Previous | Next » 

Revision 4680

Added by daigle almost 16 years ago

Added EML 2.1.0 test cases.

View differences:

test/edu/ucsb/nceas/metacattest/OnlineDataAccessTest.java
88 88
     * this function might have to modified
89 89
     */
90 90

  
91
    private String testEmlHeader =
91
    private String testEml_200_Header =
92 92
        "<?xml version=\"1.0\"?><eml:eml" +
93
        " xmlns:eml=\"eml://ecoinformatics.org/eml-2.0.0\"" +
94
        " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
95
        " packageId=\"eml.1.1\" system=\"knb\"" +
96
        " xsi:schemaLocation=\"eml://ecoinformatics.org/eml-2.0.0 eml.xsd\"" +
97
        " scope=\"system\">";
98
    
99
    private String testEml_201_Header =
100
        "<?xml version=\"1.0\"?><eml:eml" +
93 101
        " xmlns:eml=\"eml://ecoinformatics.org/eml-2.0.1\"" +
94 102
        " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
95 103
        " packageId=\"eml.1.1\" system=\"knb\"" +
96 104
        " xsi:schemaLocation=\"eml://ecoinformatics.org/eml-2.0.1 eml.xsd\"" +
97 105
        " scope=\"system\">";
106
    
107
    private String testEml_210_Header =
108
        "<?xml version=\"1.0\"?><eml:eml" +
109
        " xmlns:eml=\"eml://ecoinformatics.org/eml-2.1.0\"" +
110
        " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
111
        " packageId=\"eml.1.1\" system=\"knb\"" +
112
        " xsi:schemaLocation=\"eml://ecoinformatics.org/eml-2.1.0 eml.xsd\"" +
113
        " scope=\"system\">";
98 114

  
99 115
    private String testEmlCreatorBlock =
100 116
        "<creator scope=\"document\">                                       " +
......
180 196
     * This function is for eml-2.0.1 only. For other eml versions,
181 197
     * this function might have to modified
182 198
     */
183
    private String getTestEmlDoc(String title, String inlineData1,
199
    private String get201TestEmlDoc(String title, String inlineData1,
184 200
                                 String inlineData2, String onlineUrl1,
185 201
                                 String onlineUrl2, String docAccessBlock,
186 202
                                 String inlineAccessBlock1,
......
189 205
                                 String onlineAccessBlock2) {
190 206

  
191 207
        String testDocument = "";
192
        testDocument = testDocument + testEmlHeader +
208
        testDocument = testDocument + testEml_201_Header +
193 209
            "<dataset scope=\"document\"><title>" + title + "</title>" +
194 210
            testEmlCreatorBlock;
195 211

  
......
253 269

  
254 270
        testDocument += "</eml:eml>";
255 271

  
256
        //System.out.println("Returning following document" + testDocument);
272
		debug("Returning following document: " + testDocument);
257 273
        return testDocument;
258 274
    }
275
    
276
    /**
277
	 * This function returns a valid eml document
278
	 */
279
    private String get210TestEmlDoc(String title, String inlineData1,
280
                                 String inlineData2, String onlineUrl1,
281
                                 String onlineUrl2, String docAccessBlock,
282
                                 String inlineAccessBlock1,
283
                                 String inlineAccessBlock2,
284
                                 String onlineAccessBlock1,
285
                                 String onlineAccessBlock2) {
259 286

  
287
    	String testDocument = testEml_210_Header;
288
		
289
		// the document level access block sits at the same level and 
290
		// before the dataset element.
291
		if (docAccessBlock != null) {
292
			testDocument += docAccessBlock;
293
		}
294
		
295
        testDocument += "<dataset scope=\"document\"><title>" + title + "</title>"
296
				+ testEmlCreatorBlock  + testEmlContactBlock 
297
				+ "<dataTable>" 
298
				+ "  <entityName>Test Data</entityName>"
299
				+ "  <physical>" 
300
				+ "    <objectName>2.1.0 test physical</objectName>"
301
				+ "    <size unit=\"bytes\">1</size>"
302
				+ "    <characterEncoding>ASCII</characterEncoding>"
303
				+ "    <dataFormat>"
304
				+ "      <textFormat>"
305
				+ "        <numHeaderLines>1</numHeaderLines>"
306
				+ "        <attributeOrientation>column</attributeOrientation>"
307
				+ "        <simpleDelimited>"
308
				+ "          <fieldDelimiter>,</fieldDelimiter>"
309
				+ "        </simpleDelimited>"
310
				+ "      </textFormat>"
311
				+ "    </dataFormat>";
312

  
313
		// The inline/online level access block sits at the same level as the 
314
        // inline element.
315
		if (inlineData1 != null) {
316
			testDocument += "<distribution><inline>" + inlineData1 + "</inline>";
317
			if (inlineAccessBlock1 != null) {
318
				testDocument += inlineAccessBlock1;
319
			}
320
			testDocument += "</distribution>";
321
		}
322
		if (inlineData2 != null) {
323
			testDocument += "<distribution><inline>" + inlineData2 + "</inline>";
324
			if (inlineAccessBlock2 != null) {
325
				testDocument += inlineAccessBlock2;
326
			}
327
			testDocument += "</distribution>";
328
		}
329
		if (onlineUrl1 != null) {
330
			testDocument = testDocument
331
					+ "<distribution><online><url function=\"download\">" + onlineUrl1
332
					+ "</url></online>";
333
			if (onlineAccessBlock1 != null) {
334
				testDocument += onlineAccessBlock1;
335
			}
336
			testDocument += "</distribution>";
337
		}
338
		if (onlineUrl2 != null) {
339
			testDocument = testDocument
340
					+ "<distribution><online><url function=\"download\">" + onlineUrl2
341
					+ "</url></online>";
342
			if (onlineAccessBlock2 != null) {
343
				testDocument += onlineAccessBlock2;
344
			}
345
			testDocument += "</distribution>";
346
		}
347
		testDocument += 
348
			  "  </physical>" 
349
			+ "  <attributeList>"
350
			+ "    <attribute>"
351
			+ "      <attributeName>rain</attributeName>"
352
			+ "      <attributeLabel>Surface Rainfall</attributeLabel>"
353
			+ "      <attributeDefinition>The amount of rainfall on the sampling unit."
354
			+ "      </attributeDefinition>"
355
			+ "      <storageType>float</storageType>"
356
			+ "      <storageType typeSystem=\"http://java.sun.com/docs/books/jls/second_edition/html\">double</storageType>"
357
			+ "      <measurementScale>"
358
			+ "        <interval>"
359
			+ "          <unit><standardUnit>millimeter</standardUnit></unit>"
360
			+ "          <precision>0.5</precision>"
361
			+ "          <numericDomain id=\"nd.1\">"
362
			+ "            <numberType>real</numberType>"
363
			+ "            <bounds>"
364
			+ "              <minimum exclusive=\"false\">0</minimum>"
365
			+ "            </bounds>"
366
			+ "          </numericDomain>"
367
			+ "        </interval>"
368
			+ "      </measurementScale>"
369
			+ "    </attribute>"
370
			+ "  </attributeList>"
371
			+ "</dataTable></dataset></eml:eml>";
372

  
373
		debug("Returning following document: " + testDocument);
374
		return testDocument;
375
	}
376

  
260 377
    /**
261 378
     * Constructor to build the test
262 379
     *
......
294 411
        TestSuite suite = new TestSuite();
295 412
        suite.addTest(new OnlineDataAccessTest("initialize"));
296 413

  
297
        suite.addTest(new OnlineDataAccessTest("onlineDataCasesTest_1"));
298
        suite.addTest(new OnlineDataAccessTest("onlineDataCasesTest_2"));
299
        suite.addTest(new OnlineDataAccessTest("onlineDataCasesTest_3"));
300
        suite.addTest(new OnlineDataAccessTest("onlineDataCasesTest_4"));
301
        suite.addTest(new OnlineDataAccessTest("onlineDataCasesTest_5"));
302
        suite.addTest(new OnlineDataAccessTest("onlineDataCasesTest_6"));
414
        suite.addTest(new OnlineDataAccessTest("onlineData201CasesTest_1"));
415
        suite.addTest(new OnlineDataAccessTest("onlineData210CasesTest_1"));
416
        suite.addTest(new OnlineDataAccessTest("onlineData201CasesTest_2"));
417
        suite.addTest(new OnlineDataAccessTest("onlineData210CasesTest_2"));
418
        suite.addTest(new OnlineDataAccessTest("onlineData201CasesTest_3"));
419
        suite.addTest(new OnlineDataAccessTest("onlineData210CasesTest_3"));
420
        suite.addTest(new OnlineDataAccessTest("onlineData201CasesTest_4"));
421
        suite.addTest(new OnlineDataAccessTest("onlineData210CasesTest_4"));
422
        suite.addTest(new OnlineDataAccessTest("onlineData201CasesTest_5"));
423
        suite.addTest(new OnlineDataAccessTest("onlineData201CasesTest_6"));
424
        suite.addTest(new OnlineDataAccessTest("onlineData210CasesTest_6"));
303 425

  
304 426
        return suite;
305 427
    }
......
315 437
    }
316 438

  
317 439

  
318
    /** *********
319
     * Checking the following cases:
440
    /**
441
     * Checking the following cases on 2.0.1 version documents:
320 442
     * when only online data is uploaded by a user and
321 443
     * -> he tries to read it  - success
322 444
     * -> he tries to add same docid again  - failure
......
325 447
     * -> he tries to delete it  - success
326 448
     * -> he tries to read it after deleteing - failure
327 449
     */
328
    public void onlineDataCasesTest_1() {
450
    public void onlineData201CasesTest_1() {
329 451
        try {
330
			debug("\nRunning: onlineDataCasesTest_1");
452
			debug("\nRunning: onlineData201CasesTest_1");
331 453

  
332 454
            // upload online data
333 455
            onlineDocid = generateDocid();
......
348 470

  
349 471
            // try to set the permissions for the uploaded document
350 472
            // the docid given is for the online document
351
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
473
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
352 474
                                         null, null,
353 475
                                         "ecogrid://knb/" + onlineDocid + ".1",
354 476
                                         null, getAccessBlock(anotheruser, true,
......
390 512
            fail("General exception:\n" + e.getMessage());
391 513
        }
392 514
    }
515
    
516
    /**
517
     * Checking the following cases on 2.1.0 version documents:
518
     * when only online data is uploaded by a user and
519
     * -> he tries to read it  - success
520
     * -> he tries to add same docid again  - failure
521
     * -> he tries to update it  - success
522
     * -> he tries to set permissions on it  - success
523
     * -> he tries to delete it  - success
524
     * -> he tries to read it after deleteing - failure
525
     */
526
    public void onlineData210CasesTest_1() {
527
        try {
528
			debug("\nRunning: onlineData210CasesTest_1");
393 529

  
530
            // upload online data
531
            onlineDocid = generateDocid();
532
            m.login(username, password);
533
            uploadDocid(onlineDocid + ".1",
534
                        onlinetestdatafile1, SUCCESS, false);
394 535

  
395
    /** *********
396
     * Checking the following cases:
536
            // try to read the data
537
            readDocid(onlineDocid + ".1", SUCCESS, false);
538

  
539
            // try to upload another data with same id
540
            uploadDocid(onlineDocid + ".1",
541
                        onlinetestdatafile2, FAILURE, false);
542

  
543
            // try to upload another data with updated id
544
            uploadDocid(onlineDocid + ".2",
545
                        onlinetestdatafile2, SUCCESS, false);
546

  
547
            // try to set the permissions for the uploaded document
548
            // the docid given is for the online document
549
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
550
                                         null, null,
551
                                         "ecogrid://knb/" + onlineDocid + ".1",
552
                                         null, getAccessBlock(anotheruser, true,
553
                true, false, false, false),
554
                                         null, null, null, null);
555
            newdocid = generateDocid();
556
            insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
557
            m.logout();
558

  
559
            // check if the permissions were set properly
560
            m.login(anotheruser, anotherpassword);
561
            readDocid(onlineDocid + ".1", SUCCESS, false);
562
            readDocid(onlineDocid + ".2", SUCCESS, false);
563
            m.logout();
564

  
565
            m.login(username, password);
566

  
567
            // delete the document - able to delete .1
568
            // but not able to delete .2 as no rules 
569
	    // written to access table when a document 
570
	    // is 'uploaded'
571
            deleteDocid(onlineDocid + ".1", SUCCESS, false);
572
            deleteDocid(onlineDocid + ".2", FAILURE, true);
573

  
574
            // try to read the documents now
575
            readDocid(onlineDocid + ".1", FAILURE, true);
576
            readDocid(onlineDocid + ".2", FAILURE, true);
577

  
578
            m.logout();
579

  
580
        }
581
        catch (MetacatAuthException mae) {
582
            fail("Authorization failed:\n" + mae.getMessage());
583
        }
584
        catch (MetacatInaccessibleException mie) {
585
            fail("Metacat Inaccessible:\n" + mie.getMessage());
586
        }
587
        catch (Exception e) {
588
            fail("General exception:\n" + e.getMessage());
589
        }
590
    }
591

  
592

  
593
    /**
594
     * Checking the following cases on 2.0.1 version documents:
397 595
     * when only online data is uploaded by a user and another user
398 596
     * -> tries to read it  - failure
399 597
     * -> tries to add same docid again  - failure
......
401 599
     * -> tries to set permissions on it  - failure
402 600
     * -> tries to delete it  - failure
403 601
     */
404
    public void onlineDataCasesTest_2() {
602
    public void onlineData201CasesTest_2() {
405 603
        try {
406
			debug("\nRunning: onlineDataCasesTest_2");
604
			debug("\nRunning: onlineData201CasesTest_2");
407 605

  
408 606
            // upload an online document
409 607
            onlineDocid = generateDocid();
......
432 630

  
433 631
            // try to set the permissions for the uploaded document
434 632
            // the docid given is for the online document
435
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
633
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
436 634
                                         null, null,
437 635
                                         "ecogrid://knb/" + onlineDocid + ".1",
438 636
                                         "ecogrid://knb/" + onlineDocid + ".2",
......
461 659
        }
462 660
    }
463 661

  
662
    /**
663
     * Checking the following cases on 2.1.0 version documents:
664
     * when only online data is uploaded by a user and another user
665
     * -> tries to read it  - failure
666
     * -> tries to add same docid again  - failure
667
     * -> tries to update it  - failure
668
     * -> tries to set permissions on it  - failure
669
     * -> tries to delete it  - failure
670
     */
671
    public void onlineData210CasesTest_2() {
672
        try {
673
			debug("\nRunning: onlineData201CasesTest_2");
464 674

  
465
    /** *********
466
     * Checking the following cases:
675
            // upload an online document
676
            onlineDocid = generateDocid();
677
            m.login(username, password);
678
            uploadDocid(onlineDocid + ".1",
679
                        onlinetestdatafile1, SUCCESS, false);
680

  
681
            uploadDocid(onlineDocid + ".2",
682
                        onlinetestdatafile2, SUCCESS, false);
683

  
684
            // login as another user
685
            m.logout();
686
            m.login(anotheruser, anotherpassword);
687

  
688
            // try to read the data
689
            readDocid(onlineDocid + ".2", FAILURE, true);
690

  
691
            // try to upload another document with same id
692
            uploadDocid(onlineDocid + ".2",
693
                        onlinetestdatafile2, FAILURE, false);
694

  
695
            // try to upload another document with updated id
696
            uploadDocid(onlineDocid + ".3",
697
                        onlinetestdatafile2, FAILURE, true);
698

  
699

  
700
            // try to set the permissions for the uploaded document
701
            // the docid given is for the online document
702
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
703
                                         null, null,
704
                                         "ecogrid://knb/" + onlineDocid + ".1",
705
                                         "ecogrid://knb/" + onlineDocid + ".2",
706
                                         getAccessBlock(anotheruser, true,
707
                                         true, false, false, false),
708
                                         null, null, null, null);
709
            newdocid = generateDocid();
710
            insertDocid(newdocid + ".1", testdocument, FAILURE, true);
711

  
712
            // delete the document - should not be able to delete .1
713
            // but should be able to delete .2
714
            deleteDocid(onlineDocid + ".1", FAILURE, true);
715
            deleteDocid(onlineDocid + ".2", FAILURE, true);
716

  
717
            m.logout();
718

  
719
        }
720
        catch (MetacatAuthException mae) {
721
            fail("Authorization failed:\n" + mae.getMessage());
722
        }
723
        catch (MetacatInaccessibleException mie) {
724
            fail("Metacat Inaccessible:\n" + mie.getMessage());
725
        }
726
        catch (Exception e) {
727
            fail("General exception:\n" + e.getMessage());
728
        }
729
    }
730

  
731
    /**
732
     * Checking the following cases on 2.0.1 version documents:
467 733
     * when only online data is uploaded by a user with the following different
468 734
     * access controls in another document
469 735
     *   1.read
......
476 742
     * -> tries to set permissions on it
477 743
     * -> tries to delete it
478 744
     */
479
    public void onlineDataCasesTest_3() {
745
    public void onlineData201CasesTest_3() {
480 746
        try {
481
			debug("\nRunning: onlineDataCasesTest_3");
747
			debug("\nRunning: onlineData201CasesTest_3");
482 748

  
483 749
            /////////Case 1./////////////////////
484 750
            // upload an online document - read only
......
487 753
            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
488 754

  
489 755
            // upload a document which gives read access to the online document
490
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
756
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
491 757
                                         null, null,
492 758
                                         "ecogrid://knb/" + onlineDocid + ".1",
493 759
                                         null, getAccessBlock(anotheruser, true,
......
509 775

  
510 776
            // try to set the permissions for the uploaded document
511 777
            // the docid given is for the online document
512
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
778
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
513 779
                                         null, null,
514 780
                                         "ecogrid://knb/" + onlineDocid + ".1",
515 781
                                         null, getAccessBlock(anotheruser, true,
......
529 795
            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
530 796

  
531 797
            // upload a document which gives read access to the online document
532
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Another insert",
798
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Another insert",
533 799
                                         null, null,
534 800
                                         "ecogrid://knb/" + onlineDocid + ".1",
535 801
                                         null, getAccessBlock(anotheruser, true,
......
551 817

  
552 818
            // try to set the permissions for the uploaded document
553 819
            // the docid given is for the online document
554
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Another insert",
820
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Another insert",
555 821
                                         null, null,
556 822
                                         "ecogrid://knb/" + onlineDocid + ".1",
557 823
                                         null, getAccessBlock(anotheruser, true,
......
571 837
            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
572 838

  
573 839
            // upload a document which gives read access to the online document
574
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Another insert",
840
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Another insert",
575 841
                                         null, null,
576 842
                                         "ecogrid://knb/" + onlineDocid + ".1",
577 843
                                         null, getAccessBlock(anotheruser, true,
......
593 859

  
594 860
            // try to set the permissions for the uploaded document
595 861
            // the docid given is for the online document
596
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
862
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
597 863
                                         null, null,
598 864
                                         "ecogrid://knb/" + onlineDocid + ".1",
599 865
                                         null, getAccessBlock(anotheruser, true,
......
615 881
            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
616 882

  
617 883
            // upload a document which gives read access to the online document
618
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
884
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
619 885
                                         null, null,
620 886
                                         "ecogrid://knb/" + onlineDocid + ".1",
621 887
                                         null, getAccessBlock(anotheruser, true,
......
637 903

  
638 904
            // try to set the permissions for the uploaded document
639 905
            // the docid given is for the online document
640
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
906
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
641 907
                                         null, null,
642 908
                                         "ecogrid://knb/" + onlineDocid + ".1",
643 909
                                         null, getAccessBlock(anotheruser, true,
......
664 930
        }
665 931
    }
666 932

  
933
    /**
934
     * Checking the following cases on 2.1.0 version documents:
935
     * when only online data is uploaded by a user with the following different
936
     * access controls in another document
937
     *   1.read
938
     *   2.write
939
     *   3.change permission
940
     *   4.all
941
     * And another user tries to do the following:
942
     * -> tries to read it
943
     * -> tries to update it
944
     * -> tries to set permissions on it
945
     * -> tries to delete it
946
     */
947
    public void onlineData210CasesTest_3() {
948
        try {
949
			debug("\nRunning: onlineData210CasesTest_3");
667 950

  
951
            /////////Case 1./////////////////////
952
            // upload an online document - read only
953
            onlineDocid = generateDocid();
954
            m.login(username, password);
955
            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
668 956

  
669
    /** *********
670
     * Checking the following cases:
957
            // upload a document which gives read access to the online document
958
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
959
                                         null, null,
960
                                         "ecogrid://knb/" + onlineDocid + ".1",
961
                                         null, getAccessBlock(anotheruser, true,
962
                true, false, false, false),
963
                                         null, null, null, null);
964
            newdocid = generateDocid();
965
            insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
966
            m.logout();
967

  
968
            // login as another user
969
            m.login(anotheruser, anotherpassword);
970

  
971
            // try to read the online data
972
            readDocid(onlineDocid + ".1", SUCCESS, false);
973

  
974
            // try to upload another data with updated id
975
            uploadDocid(onlineDocid + ".2",
976
                        onlinetestdatafile2, FAILURE, true);
977

  
978
            // try to set the permissions for the uploaded document
979
            // the docid given is for the online document
980
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
981
                                         null, null,
982
                                         "ecogrid://knb/" + onlineDocid + ".1",
983
                                         null, getAccessBlock(anotheruser, true,
984
                false, false, false, true),
985
                                         null, null, null, null);
986
            newdocid = generateDocid();
987
            insertDocid(newdocid + ".1", testdocument, FAILURE, true);
988

  
989
            // delete the document
990
            deleteDocid(onlineDocid + ".1", FAILURE, true);
991
            m.logout();
992

  
993
            /////////Case 2/////////////////////
994
            // upload an online document - write only
995
            onlineDocid = generateDocid();
996
            m.login(username, password);
997
            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
998

  
999
            // upload a document which gives read access to the online document
1000
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Another insert",
1001
                                         null, null,
1002
                                         "ecogrid://knb/" + onlineDocid + ".1",
1003
                                         null, getAccessBlock(anotheruser, true,
1004
                false, true, false, false),
1005
                                         null, null, null, null);
1006
            newdocid = generateDocid();
1007
            insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1008
            m.logout();
1009

  
1010
            // login as another user
1011
            m.login(anotheruser, anotherpassword);
1012

  
1013
            // try to read the online data
1014
            readDocid(onlineDocid + ".1", FAILURE, true);
1015

  
1016
            // try to upload another data with updated id
1017
            uploadDocid(onlineDocid + ".2",
1018
                        onlinetestdatafile2, SUCCESS, false);
1019

  
1020
            // try to set the permissions for the uploaded document
1021
            // the docid given is for the online document
1022
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Another insert",
1023
                                         null, null,
1024
                                         "ecogrid://knb/" + onlineDocid + ".1",
1025
                                         null, getAccessBlock(anotheruser, true,
1026
                                         false, false, false, true),
1027
                                         null, null, null, null);
1028
            newdocid = generateDocid();
1029
            insertDocid(newdocid + ".1", testdocument, FAILURE, true);
1030

  
1031
            // delete the document
1032
            deleteDocid(onlineDocid + ".2", FAILURE, true);
1033
            m.logout();
1034

  
1035
            /////////Case 3/////////////////////
1036
            // upload an online document - change permission only
1037
            onlineDocid = generateDocid();
1038
            m.login(username, password);
1039
            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
1040

  
1041
            // upload a document which gives read access to the online document
1042
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Another insert",
1043
                                         null, null,
1044
                                         "ecogrid://knb/" + onlineDocid + ".1",
1045
                                         null, getAccessBlock(anotheruser, true,
1046
                                         false, false, true, false),
1047
                                         null, null, null, null);
1048
            newdocid = generateDocid();
1049
            insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1050
            m.logout();
1051

  
1052
            // login as another user
1053
            m.login(anotheruser, anotherpassword);
1054

  
1055
            // try to read the online data
1056
            readDocid(onlineDocid + ".1", FAILURE, true);
1057

  
1058
            // try to upload another data with updated id
1059
            uploadDocid(onlineDocid + ".2",
1060
                          onlinetestdatafile2, FAILURE, true);
1061

  
1062
            // try to set the permissions for the uploaded document
1063
            // the docid given is for the online document
1064
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
1065
                                         null, null,
1066
                                         "ecogrid://knb/" + onlineDocid + ".1",
1067
                                         null, getAccessBlock(anotheruser, true,
1068
                                         false, false, false, true),
1069
                                         null, null, null, null);
1070
            newdocid = generateDocid();
1071
            // ERRRRRRRRRRRRRRRR
1072
            // User does not have permission to update of access rules for data
1073
            // insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1074

  
1075
            // delete the document
1076
            deleteDocid(onlineDocid + ".1", FAILURE, true);
1077
            m.logout();
1078

  
1079
            /////////Case 4/////////////////////
1080
            // upload an online document all
1081
            onlineDocid = generateDocid();
1082
            m.login(username, password);
1083
            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
1084

  
1085
            // upload a document which gives read access to the online document
1086
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
1087
                                         null, null,
1088
                                         "ecogrid://knb/" + onlineDocid + ".1",
1089
                                         null, getAccessBlock(anotheruser, true,
1090
                                         false, false, false, true),
1091
                                         null, null, null, null);
1092
            newdocid = generateDocid();
1093
            insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1094
            m.logout();
1095

  
1096
            // login as another user
1097
            m.login(anotheruser, anotherpassword);
1098

  
1099
            // try to read the online data
1100
            readDocid(onlineDocid + ".1", SUCCESS, false);
1101

  
1102
            // try to upload another data with updated id
1103
            uploadDocid(onlineDocid + ".2",
1104
                        onlinetestdatafile2, SUCCESS, false);
1105

  
1106
            // try to set the permissions for the uploaded document
1107
            // the docid given is for the online document
1108
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
1109
                                         null, null,
1110
                                         "ecogrid://knb/" + onlineDocid + ".1",
1111
                                         null, getAccessBlock(anotheruser, true,
1112
                                         true, false, false, false),
1113
                                         null, null, null, null);
1114
            newdocid = generateDocid();
1115
            insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1116

  
1117
            m.logout();
1118
            // delete the document
1119
            deleteDocid(onlineDocid + ".1", FAILURE, false);
1120

  
1121
            m.logout();
1122

  
1123
        }
1124
        catch (MetacatAuthException mae) {
1125
            fail("Authorization failed:\n" + mae.getMessage());
1126
        }
1127
        catch (MetacatInaccessibleException mie) {
1128
            fail("Metacat Inaccessible:\n" + mie.getMessage());
1129
        }
1130
        catch (Exception e) {
1131
            fail("General exception:\n" + e.getMessage());
1132
        }
1133
    }
1134

  
1135
    /**
1136
     * Checking the following cases on 2.0.1 version documents:
671 1137
     * when only online data is uploaded by a user with the following different
672 1138
     * access controls specified in addiotnal metadata in another document
673 1139
     *   1.read
......
680 1146
     * -> tries to set permissions on it
681 1147
     * -> tries to delete it
682 1148
     */
683
    public void onlineDataCasesTest_4() {
1149
    public void onlineData201CasesTest_4() {
684 1150
        try {
685
			debug("\nRunning: onlineDataCasesTest_4");
1151
			debug("\nRunning: onlineData201CasesTest_4");
686 1152

  
1153
//            /////////Case 1./////////////////////
1154
//            // upload an online document - read only
1155
//            onlineDocid = generateDocid();
1156
//            m.login(username, password);
1157
//            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
1158
//
1159
//            // upload a document which gives read access to the online document
1160
//            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
1161
//                                         null, null,
1162
//                                         "ecogrid://knb/" + onlineDocid + ".1",
1163
//                                         null, null, null, null,
1164
//                                         getAccessBlock(anotheruser, true,
1165
//                                         true, false, false, false), null);
1166
//            newdocid = generateDocid();
1167
//            insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1168
//            m.logout();
1169
//
1170
//            // login as another user
1171
//            m.login(anotheruser, anotherpassword);
1172
//
1173
//            // try to read the online data
1174
//            readDocid(onlineDocid + ".1", SUCCESS, false);
1175
//
1176
//            // try to upload another data with updated id
1177
//            uploadDocid(onlineDocid + ".2",
1178
//                        onlinetestdatafile2, FAILURE, true);
1179
//
1180
//            // try to set the permissions for the uploaded document
1181
//            // the docid given is for the online document
1182
//            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
1183
//                                         null, null,
1184
//                                         "ecogrid://knb/" + onlineDocid + ".1",
1185
//                                         null, null, null, null,
1186
//                                         getAccessBlock(anotheruser, true,
1187
//                                         false, false, false, true), null);
1188
//            newdocid = generateDocid();
1189
//            insertDocid(newdocid + ".1", testdocument, FAILURE, true);
1190
//
1191
//            // delete the document
1192
//            deleteDocid(onlineDocid + ".1", FAILURE, true);
1193
//            m.logout();
1194

  
1195
            /////////Case 2/////////////////////
1196
            // upload an online document - write only
1197
            onlineDocid = generateDocid();
1198
            m.login(username, password);
1199
            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
1200

  
1201
            // upload a document which gives read access to the online document
1202
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
1203
                                         null, null,
1204
                                         "ecogrid://knb/" + onlineDocid + ".1",
1205
                                         null, null, null, null,
1206
                                         getAccessBlock(anotheruser, true,
1207
                                         false, true, false, false), null);
1208
            newdocid = generateDocid();
1209
            insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1210
            m.logout();
1211

  
1212
            // login as another user
1213
            m.login(anotheruser, anotherpassword);
1214

  
1215
            // try to read the online data
1216
            readDocid(onlineDocid + ".1", FAILURE, true);
1217

  
1218
            // try to upload another data with updated id
1219
            uploadDocid(onlineDocid + ".2",
1220
                        onlinetestdatafile2, SUCCESS, false);
1221

  
1222
            // try to set the permissions for the uploaded document
1223
            // the docid given is for the online document
1224
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
1225
                                         null, null,
1226
                                         "ecogrid://knb/" + onlineDocid + ".1",
1227
                                         null, null, null, null,
1228
                                         getAccessBlock(anotheruser, true,
1229
                                         false, false, false, true), null);
1230
            newdocid = generateDocid();
1231
            insertDocid(newdocid + ".1", testdocument, FAILURE, true);
1232

  
1233
            // delete the document
1234
            deleteDocid(onlineDocid + ".2", FAILURE, true);
1235
            m.logout();
1236

  
1237
//            /////////Case 3/////////////////////
1238
//            // upload an online document - change permission only
1239
//            onlineDocid = generateDocid();
1240
//            m.login(username, password);
1241
//            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
1242
//
1243
//            // upload a document which gives read access to the online document
1244
//            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
1245
//                                         null, null,
1246
//                                         "ecogrid://knb/" + onlineDocid + ".1",
1247
//                                         null, null, null, null,
1248
//                                         getAccessBlock(anotheruser, true,
1249
//                                         false, false, true, false), null);
1250
//            newdocid = generateDocid();
1251
//            insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1252
//            m.logout();
1253
//
1254
//            // login as another user
1255
//            m.login(anotheruser, anotherpassword);
1256
//
1257
//            // try to read the online data
1258
//            readDocid(onlineDocid + ".1", FAILURE, true);
1259
//
1260
//            // try to upload another data with updated id
1261
//            uploadDocid(onlineDocid + ".2",
1262
//                        onlinetestdatafile2, FAILURE, true);
1263
//
1264
//            // try to set the permissions for the uploaded document
1265
//            // the docid given is for the online document
1266
//            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
1267
//                                         null, null,
1268
//                                         "ecogrid://knb/" + onlineDocid + ".1",
1269
//                                         null, null, null, null,
1270
//                                         getAccessBlock(anotheruser, true,
1271
//                                         false, false, false, true), null);
1272
//            newdocid = generateDocid();
1273
//            // ERRRRRRRRRRRRRRRR
1274
//            // User does not have permission to update of access rules for data
1275
//            // insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1276
//
1277
//            // delete the document
1278
//            deleteDocid(onlineDocid + ".1", FAILURE, true);
1279
//            m.logout();
1280
//
1281
//            /////////Case 4/////////////////////
1282
//            // upload an online document all
1283
//            onlineDocid = generateDocid();
1284
//            m.login(username, password);
1285
//            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
1286
//
1287
//            // upload a document which gives read access to the online document
1288
//            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
1289
//                                         null, null,
1290
//                                         "ecogrid://knb/" + onlineDocid + ".1",
1291
//                                         null, null, null, null,
1292
//                                         getAccessBlock(anotheruser, true,
1293
//                                         false, false, false, true), null);
1294
//            newdocid = generateDocid();
1295
//            insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1296
//            m.logout();
1297
//
1298
//            // login as another user
1299
//            m.login(anotheruser, anotherpassword);
1300
//
1301
//            // try to read the online data
1302
//            readDocid(onlineDocid + ".1", SUCCESS, false);
1303
//
1304
//            // try to upload another data with updated id
1305
//            uploadDocid(onlineDocid + ".2",
1306
//                        onlinetestdatafile2, SUCCESS, false);
1307
//
1308
//            // try to set the permissions for the uploaded document
1309
//            // the docid given is for the online document
1310
//            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
1311
//                                         null, null,
1312
//                                         "ecogrid://knb/" + onlineDocid + ".1",
1313
//                                         null, null, null, null,
1314
//                                         getAccessBlock(anotheruser, true,
1315
//                                         true, false, false, false), null);
1316
//            newdocid = generateDocid();
1317
//            insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1318
//
1319
//            m.logout();
1320
//            // delete the document
1321
//            deleteDocid(onlineDocid + ".1", FAILURE, false);
1322
//
1323
//            m.logout();
1324

  
1325
        }
1326
        catch (MetacatAuthException mae) {
1327
            fail("Authorization failed:\n" + mae.getMessage());
1328
        }
1329
        catch (MetacatInaccessibleException mie) {
1330
            fail("Metacat Inaccessible:\n" + mie.getMessage());
1331
        }
1332
        catch (Exception e) {
1333
            fail("General exception:\n" + e.getMessage());
1334
        }
1335
    }
1336
    
1337
    /**
1338
     * Checking the following cases on 2.1.0 version documents:
1339
     * when only online data is uploaded by a user with the following different
1340
     * access controls specified in addiotnal metadata in another document
1341
     *   1.read
1342
     *   2.write
1343
     *   3.change permission
1344
     *   4.all
1345
     * And another user tries to do the following:
1346
     * -> tries to read it
1347
     * -> tries to update it
1348
     * -> tries to set permissions on it
1349
     * -> tries to delete it
1350
     */
1351
    public void onlineData210CasesTest_4() {
1352
        try {
1353
			debug("\nRunning: onlineData210CasesTest_4");
1354

  
687 1355
            /////////Case 1./////////////////////
688 1356
            // upload an online document - read only
689 1357
            onlineDocid = generateDocid();
......
691 1359
            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
692 1360

  
693 1361
            // upload a document which gives read access to the online document
694
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
1362
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
695 1363
                                         null, null,
696 1364
                                         "ecogrid://knb/" + onlineDocid + ".1",
697 1365
                                         null, null, null, null,
......
713 1381

  
714 1382
            // try to set the permissions for the uploaded document
715 1383
            // the docid given is for the online document
716
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
1384
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
717 1385
                                         null, null,
718 1386
                                         "ecogrid://knb/" + onlineDocid + ".1",
719 1387
                                         null, null, null, null,
......
733 1401
            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
734 1402

  
735 1403
            // upload a document which gives read access to the online document
736
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
1404
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
737 1405
                                         null, null,
738 1406
                                         "ecogrid://knb/" + onlineDocid + ".1",
739 1407
                                         null, null, null, null,
......
755 1423

  
756 1424
            // try to set the permissions for the uploaded document
757 1425
            // the docid given is for the online document
758
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
1426
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
759 1427
                                         null, null,
760 1428
                                         "ecogrid://knb/" + onlineDocid + ".1",
761 1429
                                         null, null, null, null,
......
775 1443
            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
776 1444

  
777 1445
            // upload a document which gives read access to the online document
778
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
1446
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
779 1447
                                         null, null,
780 1448
                                         "ecogrid://knb/" + onlineDocid + ".1",
781 1449
                                         null, null, null, null,
......
797 1465

  
798 1466
            // try to set the permissions for the uploaded document
799 1467
            // the docid given is for the online document
800
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
1468
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
801 1469
                                         null, null,
802 1470
                                         "ecogrid://knb/" + onlineDocid + ".1",
803 1471
                                         null, null, null, null,
......
819 1487
            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
820 1488

  
821 1489
            // upload a document which gives read access to the online document
822
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
1490
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
823 1491
                                         null, null,
824 1492
                                         "ecogrid://knb/" + onlineDocid + ".1",
825 1493
                                         null, null, null, null,
......
841 1509

  
842 1510
            // try to set the permissions for the uploaded document
843 1511
            // the docid given is for the online document
844
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
1512
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
845 1513
                                         null, null,
846 1514
                                         "ecogrid://knb/" + onlineDocid + ".1",
847 1515
                                         null, null, null, null,
......
868 1536
        }
869 1537
    }
870 1538

  
871
    /** *********
872
     * Checking the following cases:
1539
    /**
1540
     * Checking the following cases on 2.0.1 version documents:
873 1541
     * -> when online data with document refering to it is uploaded with
874 1542
     *    rules in additional metadata for an wrong entity id which
875 1543
     *    doesnt exist
......
877 1545
     *    rules in additional metadata for an entity which doesnt
878 1546
     *    exist - wrong url
879 1547
     */
880
    public void onlineDataCasesTest_5() {
1548
    public void onlineData201CasesTest_5() {
881 1549
        try {       	
882
			debug("\nRunning: onlineDataCasesTest_5");
1550
			debug("\nRunning: onlineData201CasesTest_5");
883 1551

  
884 1552
            // upload online data
885 1553
            onlineDocid = generateDocid();
886 1554
            m.login(username, password);
887 1555

  
888 1556
            /////////Case 1
889
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", null, null,
1557
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert", null, null,
890 1558
                                         "ecogrid://knb/" + onlineDocid + ".1",
891 1559
                                         null, null, null, null, null,
892 1560
                                         getAccessBlock(anotheruser, true,
......
895 1563
            insertDocid(newdocid + ".1", testdocument, FAILURE, false);
896 1564

  
897 1565
            /////////Case 2
898
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", null, null,
1566
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert", null, null,
899 1567
                                         "ecogrid://knb/" + onlineDocid + ".1",
900 1568
                                         null, null, null, null,
901 1569
                                         getAccessBlock(anotheruser, true,
......
916 1584
            fail("General exception:\n" + e.getMessage());
917 1585
        }
918 1586
    }
1587
   
1588
// MCD - Removed this test.  Access does not use additional metadata in 2.0.1  
1589
//    /**
1590
//     * Checking the following cases on 2.1.0 version documents:
1591
//     * -> when online data with document refering to it is uploaded with
1592
//     *    rules in additional metadata for an wrong entity id which
1593
//     *    doesnt exist
1594
//     * -> when online data with document refering to it is uploaded with
1595
//     *    rules in additional metadata for an entity which doesnt
1596
//     *    exist - wrong url
1597
//     */
1598
//    public void onlineData210CasesTest_5() {
1599
//        try {       	
1600
//			debug("\nRunning: onlineData210CasesTest_5");
1601
//
1602
//            // upload online data
1603
//            onlineDocid = generateDocid();
1604
//            m.login(username, password);
1605
//
1606
//            /////////Case 1
1607
//            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert", null, null,
1608
//                                         "ecogrid://knb/" + onlineDocid + ".1",
1609
//                                         null, null, null, null, null,
1610
//                                         getAccessBlock(anotheruser, true,
1611
//                                         true, false, false, false));
1612
//            newdocid = generateDocid();
1613
//            insertDocid(newdocid + ".1", testdocument, FAILURE, false);
1614
//
1615
//            /////////Case 2
1616
//            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert", null, null,
1617
//                                         "ecogrid://knb/" + onlineDocid + ".1",
1618
//                                         null, null, null, null,
1619
//                                         getAccessBlock(anotheruser, true,
1620
//                                         true, false, false, false), null);
1621
//            newdocid = generateDocid();
1622
//
1623
//            insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1624
//            m.logout();
1625
//
1626
//        }
1627
//        catch (MetacatAuthException mae) {
1628
//            fail("Authorization failed:\n" + mae.getMessage());
1629
//        }
1630
//        catch (MetacatInaccessibleException mie) {
1631
//            fail("Metacat Inaccessible:\n" + mie.getMessage());
1632
//        }
1633
//        catch (Exception e) {
1634
//            fail("General exception:\n" + e.getMessage());
1635
//        }
1636
//    }
919 1637

  
920 1638

  
921
    /** *********
922
     * Checking the following cases:
1639
    /**
1640
     * Checking the following cases on 2.0.1 version documents:
923 1641
     * -> when a document is added with no online data - it is updated (has
924 1642
     *    access)  - then data is added - and a url to it is added and docid
925 1643
     *    is updated - then the access is updated in document
......
928 1646
     * -> when online data with document refering to it is uploaded with read
929 1647
     *    access for document and no access for docid and vice versa
930 1648
     */
931
    public void onlineDataCasesTest_6() {
1649
    public void onlineData201CasesTest_6() {
932 1650
        try {
933
			debug("\nRunning: onlineDataCasesTest_6");
1651
			debug("\nRunning: onlineData201CasesTest_6");
934 1652
            // insert a document
935 1653
            m.login(username, password);
936
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
1654
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
937 1655
                                         null, null, null,
938 1656
                                         null, getAccessBlock(anotheruser, true,
939 1657
                                         true, false, false, false), null, null,
......
945 1663

  
946 1664
            // update document
947 1665
            m.login(username, password);
948
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing update",
1666
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing update",
949 1667
                                         null, null, null,
950 1668
                                         null, getAccessBlock(anotheruser, true,
951 1669
                                         true, false, false, false), null, null,
......
967 1685

  
968 1686
            // upload data and update the document
969 1687
            m.login(username, password);
970
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing update",
1688
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing update",
971 1689
                                         null, null,
972 1690
                                         "ecogrid://knb/" + onlineDocid + ".1",
973 1691
                                         null, getAccessBlock(anotheruser, true,
......
978 1696

  
979 1697
            // set read for document - no read for data
980 1698
            m.login(username, password);
981
            testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert",
1699
            testdocument = get201TestEmlDoc("OnlineDataAccessTest: Doing insert",
982 1700
                                         null, null,
983 1701
                                         "ecogrid://knb/" + onlineDocid + ".1",
984 1702
                                         null, getAccessBlock(anotheruser, true,
......
997 1715

  
998 1716
            // set read for document - no read for data
999 1717
            m.login(username, password);
1000
            testdocument = getTestEmlDoc("Doing update", null, null,
1718
            testdocument = get201TestEmlDoc("Doing update", null, null,
1001 1719
                                         "ecogrid://knb/" + onlineDocid + ".1",
1002 1720
                                         null, getAccessBlock(anotheruser, false,
1003 1721
                                         false, false, false, true), null, null,
......
1023 1741
        }
1024 1742
    }
1025 1743

  
1744
    /**
1745
     * Checking the following cases on 2.1.0 version documents:
1746
     * -> when a document is added with no online data - it is updated (has
1747
     *    access)  - then data is added - and a url to it is added and docid
1748
     *    is updated - then the access is updated in document
1749
     *    does it result in rules being applied on the data
1750
     *    (Andrea Chadden was having problem is a similar case)
1751
     * -> when online data with document refering to it is uploaded with read
1752
     *    access for document and no access for docid and vice versa
1753
     */
1754
    public void onlineData210CasesTest_6() {
1755
        try {
1756
			debug("\nRunning: onlineData210CasesTest_6");
1757
            // insert a document
1758
            m.login(username, password);
1759
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
1760
                                         null, null, null,
1761
                                         null, getAccessBlock(anotheruser, true,
1762
                                         true, false, false, false), null, null,
1763
                                         null, null);
1764
            newdocid = generateDocid();
1765
            insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1766
            m.logout();
1026 1767

  
1768

  
1769
            // update document
1770
            m.login(username, password);
1771
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing update",
1772
                                         null, null, null,
1773
                                         null, getAccessBlock(anotheruser, true,
1774
                                         true, false, false, false), null, null,
1775
                                         null, null);
1776
            updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
1777
            m.logout();
1778

  
1779

  
1780
            // upload data and update the document
1781
            onlineDocid = generateDocid();
1782
            m.login(username, password);
1783
            uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false);
1784
            m.logout();
1785

  
1786
            // try to read the online data
1787
            m.login(anotheruser, anotherpassword);
1788
            readDocid(onlineDocid + ".1", FAILURE, true);
1789
            m.logout();
1790

  
1791
            // upload data and update the document
1792
            m.login(username, password);
1793
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing update",
1794
                                         null, null,
1795
                                         "ecogrid://knb/" + onlineDocid + ".1",
1796
                                         null, getAccessBlock(anotheruser, true,
1797
                                         true, false, false, false), null, null,
1798
                                         null, null);
1799
            updateDocid(newdocid + ".3", testdocument, SUCCESS, false);
1800
            m.logout();
1801

  
1802
            // set read for document - no read for data
1803
            m.login(username, password);
1804
            testdocument = get210TestEmlDoc("OnlineDataAccessTest: Doing insert",
1805
                                         null, null,
1806
                                         "ecogrid://knb/" + onlineDocid + ".1",
1807
                                         null, getAccessBlock(anotheruser, true,
1808
                                         true, false, false, false), null, null,
1809
                                         getAccessBlock(anotheruser, false,
1810
                                         false, false, false, true), null);
1811
            updateDocid(newdocid + ".4", testdocument, SUCCESS, false);
1812
            m.logout();
1813

  
1814
            // try to read the online data
1815
            m.login(anotheruser, anotherpassword);
1816
            readDocid(newdocid + ".4", SUCCESS, false);
1817
            readDocid(onlineDocid + ".1", FAILURE, true);
1818
            m.logout();
1819

  
1820

  
1821
            // set no read for document - read for data
1822
            m.login(username, password);
1823
            testdocument = get210TestEmlDoc("Doing update", null, null,
1824
                                         "ecogrid://knb/" + onlineDocid + ".1",
1825
                                         null, getAccessBlock(anotheruser, false,
1826
                                         false, false, false, true), null, null,
1827
                                         getAccessBlock(anotheruser, true,
1828
                                         true, false, false, false), null);
1829
            updateDocid(newdocid + ".5", testdocument, SUCCESS, false);
1830
            m.logout();
1831

  
1832
            // try to read the online data
1833
            m.login(anotheruser, anotherpassword);
1834
            readDocid(newdocid + ".5", FAILURE, true);
1835
            readDocid(onlineDocid + ".1", SUCCESS, false);
1836
            m.logout();
1837
        }
1838
        catch (MetacatAuthException mae) {
1839
            fail("Authorization failed:\n" + mae.getMessage());
1840
        }
1841
        catch (MetacatInaccessibleException mie) {
1842
            fail("Metacat Inaccessible:\n" + mie.getMessage());
1843
        }
1844
        catch (Exception e) {
1845
            fail("General exception:\n" + e.getMessage());
1846
        }
1847
    }
1848

  
1849

  
1027 1850
    /**
1028 1851
     * Insert a document into metacat. The expected result is passed as result
1029 1852
     */

Also available in: Unified diff