Package org.jets3t.service.model.LifecycleConfig

Examples of org.jets3t.service.model.LifecycleConfig.Rule


        }

        // Rule section

        public void startRule() {
            latestRule = config.new Rule();
        }
View Full Code Here


            LifecycleConfig config = s3Service.getLifecycleConfig(bucketName);
            assertNull(config);

            // Create Rule with Expiration by Days
            LifecycleConfig newConfig = new LifecycleConfig();
            Rule newRule = newConfig.newRule("rule-1", "/nothing", Boolean.TRUE);
            Expiration expiration = newRule.newExpiration();
            expiration.setDays(7);

            // Apply initial Rule
            s3Service.setLifecycleConfig(bucketName, newConfig);
            config = s3Service.getLifecycleConfig(bucketName);
            assertNotNull(config);
            assertEquals(1, config.getRules().size());
            Rule rule = config.getRules().get(0);
            assertEquals("rule-1", rule.getId());
            assertEquals("/nothing", rule.getPrefix());
            assertTrue(rule.getEnabled());
            assertEquals(new Integer(7), rule.getExpiration().getDays());
            assertNull(rule.getExpiration().getDate());
            assertNull(rule.getTransition());

            // Change Expiration to be by Date
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-ddZ");
            rule.getExpiration().setDate(sdf.parse("2020-01-01+0000"));
            s3Service.setLifecycleConfig(bucketName, config);
            config = s3Service.getLifecycleConfig(bucketName);
            rule = config.getRules().get(0);
            assertNull(rule.getExpiration().getDays());
            assertEquals(sdf.parse("2020-01-01+0000"), rule.getExpiration().getDate());

            // Add Transition by Date
            Transition transition = rule.newTransition()// Default's to GLACIER storage class
            transition.setDate(sdf.parse("2016-01-01+0000"));
            s3Service.setLifecycleConfig(bucketName, config);
            config = s3Service.getLifecycleConfig(bucketName);
            rule = config.getRules().get(0);
            assertEquals(sdf.parse("2016-01-01+0000"), rule.getTransition().getDate());
            assertNull(rule.getTransition().getDays());
            assertEquals(LifecycleConfig.STORAGE_CLASS_GLACIER,
                rule.getTransition().getStorageClass());

            // Change Transition to be by Days (Expiration must use same time-keeping mechanism)
            rule.getTransition().setDays(3);
            rule.getExpiration().setDays(7);
            s3Service.setLifecycleConfig(bucketName, config);
            config = s3Service.getLifecycleConfig(bucketName);
            rule = config.getRules().get(0);
            assertEquals(new Integer(3), rule.getTransition().getDays());
            assertEquals(new Integer(7), rule.getExpiration().getDays());

            // Add additional Rule
            Rule secondRule = config.newRule("second-rule", "/second", Boolean.FALSE);
            secondRule.newExpiration().setDays(100);
            s3Service.setLifecycleConfig(bucketName, config);
            config = s3Service.getLifecycleConfig(bucketName);
            assertEquals(2, config.getRules().size());
            rule = config.getRules().get(1);
            assertEquals("second-rule", rule.getId());
View Full Code Here

TOP

Related Classes of org.jets3t.service.model.LifecycleConfig.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.