1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.upgrade.v4_3_0.util;
16  
17  import com.liferay.portal.kernel.dao.jdbc.DataAccess;
18  
19  import java.sql.Connection;
20  import java.sql.PreparedStatement;
21  import java.sql.ResultSet;
22  
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  /**
27   * <a href="WebIdUtil.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class WebIdUtil {
32  
33      public static String[] getWebIds() throws Exception {
34          if (_webIds != null) {
35              return _webIds;
36          }
37  
38          List<String> webIds = new ArrayList<String>();
39  
40          Connection con = null;
41          PreparedStatement ps = null;
42          ResultSet rs = null;
43  
44          try {
45              con = DataAccess.getConnection();
46  
47              ps = con.prepareStatement(_GET_WEB_IDS);
48  
49              rs = ps.executeQuery();
50  
51              while (rs.next()) {
52                  String companyId = rs.getString("companyId");
53  
54                  webIds.add(companyId);
55              }
56          }
57          finally {
58              DataAccess.cleanUp(con, ps, rs);
59          }
60  
61          _webIds = webIds.toArray(new String[webIds.size()]);
62  
63          return _webIds;
64      }
65  
66      private static final String _GET_WEB_IDS = "select companyId from Company";
67  
68      private static String[] _webIds;
69  
70  }