KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/db/maxdb/CmsBackupDriver.java,v $
3  * Date : $Date: 2005/09/11 13:27:06 $
4  * Version: $Revision: 1.1 $
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.maxdb;
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  * MaxDB/SapDB implementation of the backup driver methods.<p>
51  *
52  * @author Thomas Weckert
53  * @author Michael Emmerich
54  * @author Clovis Wichoski
55  * @author Fabiano Rech
56  *
57  * @version $Revision: 1.1 $
58  *
59  * @since 6.0.0
60  */

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

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

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