This project has retired. For details please refer to its
Attic page.
BusinessLifeCycleManagerImplReplacement xref
1 package org.apache.ws.scout.registry.qa;
2
3 import java.net.URL;
4 import java.sql.Connection;
5 import java.sql.DriverManager;
6 import java.sql.Statement;
7 import java.util.Properties;
8
9 import org.apache.ws.scout.model.uddi.v2.BusinessDetail;
10 import org.apache.ws.scout.model.uddi.v2.BusinessEntity;
11
12 import org.apache.ws.scout.model.uddi.v2.PublisherAssertion;
13 import org.apache.ws.scout.model.uddi.v2.PublisherAssertions;
14
15 import org.aspectj.lang.annotation.After;
16 import org.aspectj.lang.annotation.Aspect;
17 import org.aspectj.lang.annotation.Before;
18
19 @Aspect
20 public class BusinessLifeCycleManagerImplReplacement {
21 private static final String JUDDI_PROPERTIES_FILE = "juddi.properties";
22
23 private static final String JDBC_DRIVER = "juddi.jdbcDriver";
24 private static final String JDBC_URL = "juddi.jdbcUrl";
25 private static final String JDBC_USER = "juddi.jdbcUsername";
26 private static final String JDBC_PASSWORD = "juddi.jdbcPassword";
27
28 private Connection conn;
29
30
31
32 @Before(" call(boolean equalsIgnoreCase(String)) "
33 + "&& within(org.apache.ws.scout.registry.BusinessLifeCycleManagerImpl)")
34 public void beforeSaveOrgCall() throws Exception {
35 System.out.println("Clearing the AUTH_TOKEN table...");
36 dbinit();
37 clearAuthTokens();
38 dbclose();
39 }
40
41 public void dbinit () throws Exception {
42 URL url = this.getClass().getClassLoader().getResource(JUDDI_PROPERTIES_FILE);
43 Properties prop = new Properties();
44 prop.load(url.openStream());
45
46 String jdbcURL = System.getProperty(JDBC_URL, prop.getProperty(JDBC_URL));
47 String jdbcDriver = System.getProperty(JDBC_DRIVER, prop.getProperty(JDBC_DRIVER));
48 String jdbcUser = System.getProperty(JDBC_USER, prop.getProperty(JDBC_USER));
49 String jdbcPass = System.getProperty(JDBC_PASSWORD, prop.getProperty(JDBC_PASSWORD));
50
51 Class.forName(jdbcDriver);
52 conn = DriverManager.getConnection(jdbcURL, jdbcUser, jdbcPass);
53 }
54
55 public void dbclose() throws Exception {
56 if (conn != null) {
57 conn.close();
58 conn = null;
59 }
60 }
61
62 public void clearAuthTokens() throws Exception {
63 String delQuery = "delete from AUTH_TOKEN";
64 Statement st = conn.createStatement();
65 st.executeUpdate(delQuery);
66 }
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 }