public static Properties initialize ( URI uri , Configuration conf ) throws IOException , ConfigurationParseException { String host = Utils . getHost ( uri ) ; Properties props = new Properties ( ) ; if ( ! Utils . validSchema ( uri ) ) { props . setProperty ( SWIFT_AUTH_METHOD_PROPERTY , PUBLIC_ACCESS ) ; } else { final String container = Utils . getContainerName ( host ) ; final String service = Utils . getServiceName ( host ) ; final String [ ] prefix = new String [ ] { SWIFT_SERVICE_PREFIX + service } ; final String prefix2D = SWIFT2D_SERVICE_PREFIX + service ; props . setProperty ( SWIFT_CONTAINER_PROPERTY , container ) ; Utils . updateProperty ( conf , prefix2D , prefix , AUTH_URL , props , SWIFT_AUTH_PROPERTY , true ) ; Utils . updateProperty ( conf , prefix2D , prefix , USERNAME , props , SWIFT_USERNAME_PROPERTY , true ) ; Utils . updateProperty ( conf , prefix2D , prefix , PASSWORD , props , SWIFT_PASSWORD_PROPERTY , true ) ; Utils . updateProperty ( conf , prefix2D , prefix , BUFFER_DIR , props , BUFFER_DIR_PROPERTY , false ) ; Utils . updateProperty ( conf , prefix2D , prefix , NON_STREAMING_UPLOAD , props , NON_STREAMING_UPLOAD_PROPERTY , false ) ; Utils . updateProperty ( conf , prefix2D , prefix , AUTH_METHOD , props , SWIFT_AUTH_METHOD_PROPERTY , false ) ; Utils . updateProperty ( conf , prefix2D , prefix , BLOCK_SIZE , props , SWIFT_BLOCK_SIZE_PROPERTY , false ) ; Utils . updateProperty ( conf , prefix2D , prefix , FMODE_DELETE_TEMP_DATA , props , FMODE_AUTOMATIC_DELETE_PROPERTY , false ) ; Utils . updateProperty ( conf , prefix2D , prefix , PUBLIC , props , SWIFT_PUBLIC_PROPERTY , false ) ; String authMethod = props . getProperty ( SWIFT_AUTH_METHOD_PROPERTY , KEYSTONE_V3_AUTH ) ; props . setProperty ( SWIFT_AUTH_METHOD_PROPERTY , authMethod ) ; if ( authMethod . equals ( KEYSTONE_V3_AUTH ) ) { Utils . updateProperty ( conf , prefix2D , prefix , TENANT , props , SWIFT_TENANT_PROPERTY , false ) ; Utils . updateProperty ( conf , prefix2D , prefix , REGION , props , SWIFT_REGION_PROPERTY , true ) ; props . setProperty ( SWIFT_PROJECT_ID_PROPERTY , props . getProperty ( SWIFT_TENANT_PROPERTY ) ) ; props . setProperty ( SWIFT_USER_ID_PROPERTY , props . getProperty ( SWIFT_USERNAME_PROPERTY ) ) ; } else if ( authMethod . equals ( "basic" ) ) { Utils . updateProperty ( conf , prefix2D , prefix , REGION , props , SWIFT_REGION_PROPERTY , false ) ; Utils . updateProperty ( conf , prefix2D , prefix , TENANT , props , SWIFT_TENANT_PROPERTY , false ) ; } else { Utils . updateProperty ( conf , prefix2D , prefix , REGION , props , SWIFT_REGION_PROPERTY , false ) ; Utils . updateProperty ( conf , prefix2D , prefix , TENANT , props , SWIFT_TENANT_PROPERTY , true ) ; } } return props ; }
Parse configuration properties from the core - site . xml and initialize Swift configuration