1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 package org.apache.geronimo.ews.ws4j2ee.utils;
32
33 import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationConstants;
34
35 import java.io.File;
36 import java.io.FileInputStream;
37 import java.io.FileNotFoundException;
38 import java.io.FileOutputStream;
39 import java.io.IOException;
40 import java.util.Properties;
41
42 /***
43 * @author hemapani@opensource.lk
44 */
45
46 public class PropertyStore {
47
48 private Properties properties;
49
50 private File file;
51
52 public PropertyStore() throws Exception {
53 File baseDir = new File(".");
54 String path = baseDir.getCanonicalPath();
55 if (path.indexOf("geronimo")!=-1) {
56 File file2 = new File("./modules/axis/");
57 if(file2.exists()) {
58 path = new File("./modules/axis/").getAbsolutePath();
59 }
60 }
61 file = new File(path, "target/" + GenerationConstants.WS4J2EE_PROPERTY_FILE);
62 file.getParentFile().mkdirs();
63 FileInputStream in = null;
64 System.out.println(file.getAbsolutePath() + " created .. ");
65 try {
66 properties = new Properties();
67 if (file.exists()) {
68 in = new FileInputStream(file);
69 properties.load(in);
70 }
71 } catch (FileNotFoundException e) {
72 } catch (IOException e) {
73 } finally {
74 try {
75 if (in != null) {
76 in.close();
77 }
78 } catch (Exception e) {
79 }
80 }
81 }
82
83 public void store(String repository) {
84 properties.setProperty(GenerationConstants.MAVEN_LOCAL_REPOSITARY, repository);
85 FileOutputStream out = null;
86 try {
87 out = new FileOutputStream(file);
88 properties.store(out, "repository Location");
89 } catch (FileNotFoundException e) {
90 } catch (IOException e) {
91 } finally {
92 try {
93 if (out != null) {
94 out.close();
95 }
96 } catch (Exception e) {
97 }
98 }
99 }
100
101 public static void main(String[] args) {
102 try {
103 PropertyStore store = new PropertyStore();
104 store.store(args[0]);
105 } catch (Exception e) {
106 }
107 }
108
109 }
110