From fc1fbb634a965056a52133b8977ed25e81fb8bd3 Mon Sep 17 00:00:00 2001 From: "devender.mishra" Date: Tue, 27 Dec 2016 16:18:36 +0530 Subject: [PATCH] Parameterize config file --- src/main/java/com/jcs_java_sdk/Compute.java | 4 +- src/main/java/com/jcs_java_sdk/Config.java | 41 ++++++++------------- 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/jcs_java_sdk/Compute.java b/src/main/java/com/jcs_java_sdk/Compute.java index 10065ef..1d2b5db 100644 --- a/src/main/java/com/jcs_java_sdk/Compute.java +++ b/src/main/java/com/jcs_java_sdk/Compute.java @@ -107,7 +107,7 @@ public class Compute private KeyPair keyPair; private Snapshot snapshot; private Volume volume; - public Compute() + public Compute(String endpoint, String access_key, String secret_key) { info = new HttpVar(); image = new Image(); @@ -117,7 +117,7 @@ public Compute() volume = new Volume(); try { - new Config(); + new Config(endpoint, access_key, secret_key); } catch (IOException e) { diff --git a/src/main/java/com/jcs_java_sdk/Config.java b/src/main/java/com/jcs_java_sdk/Config.java index 97ae2ea..83d3d68 100644 --- a/src/main/java/com/jcs_java_sdk/Config.java +++ b/src/main/java/com/jcs_java_sdk/Config.java @@ -35,37 +35,26 @@ public class Config { static String accessKey; static String secretKey; static HashMap endPoints; - public Config() throws IOException + public Config(String compute_endpoint, String access_key, String secret_key) throws IOException { - secure = false; - debug = false; - - //Get Access Key and Secret Key from file - InputStream inputStream = getClass().getClassLoader().getResourceAsStream("config.properties"); - Properties prop = new Properties(); - - if(inputStream != null) - { - prop.load(inputStream); - }else - { - throw new FileNotFoundException("Property File Not Found"); - } - - accessKey = prop.getProperty("accessKey"); - secretKey = prop.getProperty("secretKey"); - secure = Boolean.parseBoolean(prop.getProperty("secure")); - debug = Boolean.parseBoolean(prop.getProperty("debug")); - + secure = true; + debug = false; + accessKey = access_key; + secretKey = secret_key; //Set up endpoints endPoints = new HashMap(); - endPoints.put("compute","https://compute.ind-west-1.staging.jiocloudservices.com"); - endPoints.put("vpc", "https://vpc.ind-west-1.jiocloudservices.com"); - endPoints.put("dss", "https://dss.ind-west-1.jiocloudservices.com"); - endPoints.put("iam", "https://iam.ind-west-1.jiocloudservices.com"); - endPoints.put("rds", "https://rds.ind-west-1.jiocloudservices.com"); + endPoints.put("compute", compute_endpoint); } + public void setSecure(boolean sec) + { + secure=sec; + } + public void setDebug(boolean deb) + { + debug = deb; + } + public static boolean isSecure() { return secure; }