Package org.archive.accesscontrol.model

Examples of org.archive.accesscontrol.model.Rule


public class RuleTest extends TestCase {
    Rule rule;
   
    public void testBasicMatching() {
        rule = new Rule();
        rule.setSurt("(org,archive,)/");     
        assertTrue("exact surt match", rule.matches("(org,archive,)/"));
        assertTrue("prefix surt match", rule.matches("(org,archive,)/foobar/fishing.html?foo=bar"));
        assertFalse("surt non-match", rule.matches("(org,example,)/blah"));
        assertTrue("capture date always match", rule.matches("(org,archive,)/", new GregorianCalendar(2007, 4, 12).getTime()));
View Full Code Here


        assertFalse("capture and retrieval date, surt non-match", rule.matches("(org,example,)/", new GregorianCalendar(2007, 4, 12).getTime(), new GregorianCalendar(2007, 4, 12).getTime()));
       
    }
   
    public void testCaptureDateMatching() {
        rule = new Rule();
        rule.setSurt("(org,archive,)/")
       
        rule.setCaptureStart(new GregorianCalendar(2007, 1, 12).getTime());
        assertTrue("start-bounded capture date match", rule.matches("(org,archive,)/", new GregorianCalendar(2007, 4, 12).getTime()));
        assertFalse("start-bounded capture date non-match", rule.matches("(org,archive,)/", new GregorianCalendar(2005, 4, 12).getTime()));
View Full Code Here

        assertFalse("capture date too early", rule.matches("(org,archive,)/", new GregorianCalendar(2005, 1, 11).getTime()));
        assertFalse("capture date too late", rule.matches("(org,archive,)/", new GregorianCalendar(2008, 9, 11).getTime()));      
    }
   
    public void testRetrievalDateMatching() {
        rule = new Rule();
        rule.setSurt("(org,archive,)/")
       
        rule.setRetrievalStart(new GregorianCalendar(2007, 1, 12).getTime());
        assertTrue("start-bounded retrieval date match", rule.matches("(org,archive,)/", null, new GregorianCalendar(2007, 4, 12).getTime()));
        assertFalse("start-bounded retrieval date non-match", rule.matches("(org,archive,)/", null, new GregorianCalendar(2005, 4, 12).getTime()));
View Full Code Here

        assertFalse("retrieval date too early", rule.matches("(org,archive,)/", null, new GregorianCalendar(2005, 1, 11).getTime()));   
        assertFalse("retrieval date too late", rule.matches("(org,archive,)/", null, new GregorianCalendar(2008, 9, 11).getTime()));
    }
   
    public void testEmbargoPeriodMatching() {
        rule = new Rule();
        rule.setSurt("(org,archive,)/");
       
        rule.setSecondsSinceCapture(60 * 60 * 24 * 5); // embargo period of 5 days
        assertFalse("under embargo, so non-match", rule.matches("(org,archive,)/", new GregorianCalendar(2007, 4, 10).getTime(), new GregorianCalendar(2007, 4, 12).getTime()));
        assertTrue("outside embargo, so match", rule.matches("(org,archive,)/", new GregorianCalendar(2007, 4, 10).getTime(), new GregorianCalendar(2007, 4, 25).getTime()));
View Full Code Here

        assertFalse("under embargo, so non-match", rule.matches("(org,archive,)/", new GregorianCalendar(2007, 4, 10).getTime(), new GregorianCalendar(2007, 4, 12).getTime()));
        assertTrue("outside embargo, so match", rule.matches("(org,archive,)/", new GregorianCalendar(2007, 4, 10).getTime(), new GregorianCalendar(2007, 4, 25).getTime()));
    }
   
    public void testBlankGroupMatching() {
      rule = new Rule();
      rule.setSurt("(");
      rule.setWho("");
      assertTrue(rule.matches("(org,",null, null, "blah"));
    }
View Full Code Here

public class RuleSetTest extends TestCase {
    private RuleSet ruleset;
   
    public void testSimple() {
        ruleset = new RuleSet();
        ruleset.add(new Rule("robots", "("));
        ruleset.add(new Rule("allow", "(org,archive,"));
        ruleset.add(new Rule("block", "(org,archive,)/secret/"));
        ruleset.add(new Rule("allow", "(org,archive,)/secret/public/"));
       
        for (Rule rule: ruleset) {
            System.out.println(rule.getSurt());
        }
    
View Full Code Here

       
    }

    public void testSimplePrecedence() {
        ruleset = new RuleSet();
        ruleset.add(new Rule("robots", "("));
        ruleset.add(new Rule("allow", "("));
        ruleset.add(new Rule("block", "(org,archive,)/secret/"));
        ruleset.add(new Rule("allow", "(org,archive,)/secret/public/"));
        ruleset.add(new Rule("block", "(org,archive,)/secret/public/"));
    
        assertEquals("allow", ruleset.getMatchingRule("(org", new Date(), new Date(), null).getPolicy());
        assertEquals("allow", ruleset.getMatchingRule("(org,archive,)/", new Date(), new Date(), null).getPolicy());
        assertEquals("allow", ruleset.getMatchingRule("(org,archive,)/fishing.html", new Date(), new Date(), null).getPolicy());
        assertEquals("block", ruleset.getMatchingRule("(org,archive,)/secret/", new Date(), new Date(), null).getPolicy());
View Full Code Here

        assertEquals("allow", ruleset.getMatchingRule("(org,archive,)/secret/public/feeding.html", new Date(), new Date(), null).getPolicy());
    }

    public void testEmbargo() {
        ruleset = new RuleSet();
        ruleset.add(new Rule("robots", "("));
        ruleset.add(new Rule("allow", "(org,archive,"));
        ruleset.add(new Rule("block", "(org,archive,)/classified/"));
        ruleset.add(new Rule("allow", "(org,archive,)/classified/", 60 * 60 * 24 * 90));
       
        Date captureDate = new GregorianCalendar(2007, 8, 1).getTime();
        Date preReleaseDate = new GregorianCalendar(2007, 8, 15).getTime();
        Date postReleaseDate = new GregorianCalendar(2009, 8, 15).getTime();
       
View Full Code Here

        assertEquals("allow", ruleset.getMatchingRule("(org,archive,)/classified/index.html", captureDate, postReleaseDate, null).getPolicy());
    }
   
    public void testGroup() {
        ruleset = new RuleSet();
        ruleset.add(new Rule("robots", "("));
        ruleset.add(new Rule("allow", "(org,archive,", "archivists"));
        ruleset.add(new Rule("block", "(org,archive,)/classified/"));
        ruleset.add(new Rule("allow", "(org,archive,)/classified/", "admins"));
       
        assertEquals("robots", ruleset.getMatchingRule("(org,archive,www,)/index.html", new Date(), new Date(), "dinosaurs").getPolicy());
        assertEquals("allow", ruleset.getMatchingRule("(org,archive,www,)/index.html", new Date(), new Date(), "archivists").getPolicy());
        assertEquals("allow", ruleset.getMatchingRule("(org,archive,)/classified/presto", new Date(), new Date(), "admins").getPolicy());
        assertEquals("block", ruleset.getMatchingRule("(org,archive,)/classified/presto", new Date(), new Date(), "public").getPolicy());
View Full Code Here

     *
     * @param id
     * @return
     */
    public ModelAndView getRule(long id) {
        Rule rule = ruleDao.getRule(id);

        if (rule == null) {
            return new ModelAndView(view, "object", new SimpleError("Rule "
                    + id + " does not exist.", 404));
        }
View Full Code Here

TOP

Related Classes of org.archive.accesscontrol.model.Rule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.