KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > db > mysql > CmsBackupDriver


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/db/mysql/CmsBackupDriver.java,v $
3  * Date : $Date: 2005/06/23 11:11:38 $
4  * Version: $Revision: 1.28 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.db.mysql;
33
34 import org.opencms.db.CmsDbContext;
35 import org.opencms.db.CmsDbSqlException;
36 import org.opencms.db.CmsDbUtil;
37 import org.opencms.db.generic.CmsSqlManager;
38 import org.opencms.file.CmsBackupProject;
39 import org.opencms.file.CmsDataAccessException;
40 import org.opencms.util.CmsUUID;
41
42 import java.sql.Connection JavaDoc;
43 import java.sql.PreparedStatement JavaDoc;
44 import java.sql.ResultSet JavaDoc;
45 import java.sql.SQLException JavaDoc;
46 import java.util.ArrayList JavaDoc;
47 import java.util.List JavaDoc;
48
49 /**
50  * MySQL implementation of the backup driver methods.<p>
51  *
52  * @author Thomas Weckert
53  * @author Michael Emmerich
54  *
55  * @version $Revision: 1.28 $
56  *
57  * @since 6.0.0
58  */

59 public class CmsBackupDriver extends org.opencms.db.generic.CmsBackupDriver {
60
61     /**
62      * @see org.opencms.db.I_CmsBackupDriver#initSqlManager(String)
63      */

64     public org.opencms.db.generic.CmsSqlManager initSqlManager(String JavaDoc classname) {
65
66         return CmsSqlManager.getInstance(classname);
67     }
68
69     /**
70      * @see org.opencms.db.I_CmsBackupDriver#readBackupProjects(org.opencms.db.CmsDbContext)
71      */

72     public List JavaDoc readBackupProjects(CmsDbContext dbc) throws CmsDataAccessException {
73
74         List JavaDoc projects = new ArrayList JavaDoc();
75         ResultSet JavaDoc res = null;
76         PreparedStatement JavaDoc stmt = null;
77         Connection JavaDoc conn = null;
78
79         try {
80             // create the statement
81
conn = m_sqlManager.getConnection(dbc);
82             stmt = m_sqlManager.getPreparedStatement(conn, "C_PROJECTS_READLAST_BACKUP");
83             stmt.setInt(1, 300);
84             res = stmt.executeQuery();
85             while (res.next()) {
86                 List JavaDoc resources = m_driverManager.getBackupDriver().readBackupProjectResources(
87                     dbc,
88                     res.getInt("PUBLISH_TAG"));
89                 projects.add(new CmsBackupProject(
90                     res.getInt("PUBLISH_TAG"),
91                     res.getInt("PROJECT_ID"),
92                     res.getString("PROJECT_NAME"),
93                     res.getString("PROJECT_DESCRIPTION"),
94                     res.getInt("TASK_ID"),
95                     new CmsUUID(res.getString("USER_ID")),
96                     new CmsUUID(res.getString("GROUP_ID")),
97                     new CmsUUID(res.getString("MANAGERGROUP_ID")),
98                     res.getLong("DATE_CREATED"),
99                     res.getInt("PROJECT_TYPE"),
100                     CmsDbUtil.getTimestamp(res, "PROJECT_PUBLISHDATE"),
101                     new CmsUUID(res.getString("PROJECT_PUBLISHED_BY")),
102                     res.getString("PROJECT_PUBLISHED_BY_NAME"),
103                     res.getString("USER_NAME"),
104                     res.getString("GROUP_NAME"),
105                     res.getString("MANAGERGROUP_NAME"),
106                     resources));
107             }
108         } catch (SQLException JavaDoc e) {
109             throw new CmsDbSqlException(org.opencms.db.generic.Messages.get().container(
110                 org.opencms.db.generic.Messages.ERR_GENERIC_SQL_1,
111                 CmsDbSqlException.getErrorQuery(stmt)), e);
112         } finally {
113             m_sqlManager.closeAll(dbc, conn, stmt, res);
114         }
115         return (projects);
116     }
117 }
118
Popular Tags