Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /openpsa/addons/funambol/src/java/org/openpsa/sync4j/OpenPSAComponent.java

openpsa
Discussion topic

Back to topic list

CVS update: /openpsa/addons/funambol/src/java/org/openpsa/sync4j/OpenPSAComponent.java

Author juhana
Full name Juhana Hirvilahti
Date 2007-03-02 05:49:04 PST
Message User: juhana
Date: 2007-03-02 05:49:04-0800
Log:
 Cleaning up

File Changes:

Directory: /openpsa/addons/funa​mbol/src/java/org/op​enpsa/sync4j/
====================​====================​====================​====

File [changed]: OpenPSAComponent.java
Url: http://openpsa.tigri​s.org/source/browse/​openpsa/addons/funam​bol/src/java/org/ope​npsa/sync4j/OpenPSAC​omponent.java?r1=1.2​5&r2=1.26
Delta lines: +1 -1
-------------------
--- OpenPSAComponent.java 2007-02-23 06:14:24-0800 1.25
+++ OpenPSAComponent.java 2007-03-02 05:49:01-0800 1.26
@@ -1 +1 @@
-/*
 * Copyright 2006 Jukka Zitting <jz at yukatan dot fi>
 * Copyright 2006 Nemein Oy <info at nemein dot com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */
package org.openpsa.sync4j;

import java.security.MessageDigest;
import java.security.NoSuch​AlgorithmException;
import java.security.Principal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import sync4j.framework.eng​ine.source.SyncSourc​eException;

import com.mysql.jdbc.jdbc2​.optional.MysqlDataS​ource;

public abstract class OpenPSAComponent {

    private static final Logger logger =
        LoggerFactory.getLog​ger(OpenPSAComponent​.class);

    private String hostname = "localhost";

    private String database = "midgard";

    private String username = "midgard";

    private String password = "midgard";

    private String sitegroup;

    private Connection connection;

    //------------------​--------------------​-------------< getters & setters >

    public String getHostname() {
        return hostname;
    }

    public void setHostname(String hostname) {
        this.hostname = hostname;
    }

    public String getDatabase() {
        return database;
    }

    public void setDatabase(String database) {
        this.database = database;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSitegroup() {
        return sitegroup;
    }

    public void setSitegroup(String sitegroup) {
        this.sitegroup = sitegroup;
    }

    //------------------​--------------------​--------------------​-< protected >

    protected void connect() throws SQLException {
        MysqlDataSource source = new MysqlDataSource();
        source.setServerName(hostname);
        source.setDatabaseNa​me(database);
        source.setUser(username);
        source.setPassword(password);
        connection = source.getConnection();
    }

    protected void close() throws SQLException {
        connection.close();
    }

    protected PreparedStatement prepare(String sql) throws SQLException {
        return connection.prepareSt​atement(sql);
    }

    protected PreparedStatement prepare(String sql, int flags) throws SQLException {
        return connection.prepareSt​atement(sql, flags);
    }

    protected int getSitegroupID() throws SQLException {
        if (sitegroup == null || sitegroup.length() == 0) {
            return 0;
        } else {
            String sql = "SELECT id FROM sitegroup WHERE name = ?";
            PreparedStatement ps = connection.prepareSt​atement(sql);
            try {
                ps.setString(1, sitegroup);
                ResultSet rs = ps.executeQuery();
                try {
                    if (rs.next()) {
                        return rs.getInt(1);
                    } else {
                        throw new SQLException("Bad sitegroup: " + sitegroup);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                ps.close();
            }
        }
    }

    protected Date getRevised(String table, int id) throws SQLException {
        String sql = "SELECT changed FROM repligard WHERE realm = ? AND id = ?";
        PreparedStatement ps = prepare(sql);
        try {
            ps.setString(1, table);
            ps.setInt(2, id);
            ResultSet rs = ps.executeQuery();
            try {
                Date revised = null;
                if (rs.next()) {
                    revised = rs.getDate(1);
                }
                if (revised != null) {
                    return revised;
                } else {
                    return new Date();
                }
            } finally {
                rs.close();
            }
        } finally {
            ps.close();
        }
    }

    protected MidgardUser getUser(Principal principal)
            throws SyncSourceException {
        logger.debug("getUser({})", principal);
        String name = principal.getName();

        // Skip the Sync4J device prefix
        int p = name.indexOf('/');
        if (p != -1) {
            name = name.substring(p + 1);
        }

        int q = name.lastIndexOf('@');
        if (q == -1) {
            throw new SyncSourceException(
                    "Invalid principal: " + principal.getName());
        }

        try {
            String sql =
                "SELECT p.id, r.guid, s.id, p.created,"
                + " NULLIF(r.changed,'0000-00-00'), NULLIF(r.updated,'0000-00-00')"
                + " FROM person AS p, sitegroup AS s, repligard AS r"
                + " WHERE p.sitegroup = s.id AND r.sitegroup = s.id"
                + " AND r.realm = 'person' AND r.id = p.id"
                + " AND p.username = ? AND s.name = ?";
            PreparedStatement ps = connection.prepareSt​atement(sql);
            try {
                ps.setString(1, name.substring(0, q));
                ps.setString(2, name.substring(q + 1));
                ResultSet rs = ps.executeQuery();
                try {
                    if (rs.next()) {
                        MidgardUser user = new MidgardUser();
                        user.setTable("person");
                        user.setId(rs.getInt(1));
                        user.setGuid(rs.getString(2));
                        user.setSitegroup(rs​.getInt(3));
                        user.setCreated(rs.g​etTimestamp(4));
                        Date c = rs.getTimestamp(5);
                        if (c == null) {
                            c = user.getCreated();
                        }
                        Date u = rs.getTimestamp(6);
                        if (u == null || u.before(c)) {
                            user.setUpdated(c);
                        } else {
                            user.setUpdated(u);
                        }
                        user.setUsername(nam​e.substring(0, q));
                        return user;
                    } else {
                        throw new SyncSourceException(
                                "Principal not found: " + principal.getName());
                    }
                } finally {
                    rs.close();
                }
            } finally {
                ps.close();
            }
        } catch (SQLException e) {
            throw new SyncSourceException("Database error: " + e.getMessage(), e);
        }
    }

    protected int locate(MidgardUser user, String table, String guid)
            throws SyncSourceException {
        logger.debug("locate({}, {})", table, guid);
        try {
            String sql = "SELECT id FROM repligard"
                + " WHERE sitegroup = ? AND realm = ? AND guid = ?";
            PreparedStatement ps = connection.prepareSt​atement(sql);
            try {
                ps.setInt(1, user.getSitegroup());
                ps.setString(2, table);
                ps.setString(3, guid);
                ResultSet rs = ps.executeQuery();
                try {
                    if (rs.next()) {
                        return rs.getInt(1);
                    } else {
                        return 0;
                    }
                } finally {
                    rs.close();
                }
            } finally {
                ps.close();
            }
        } catch (SQLException e) {
            throw new SyncSourceException("Database error: " + e.getMessage(), e);
        }
    }

    private String makeGuid(String table, int id) throws NoSuchAlgorithmException {
        MessageDigest digest = MessageDigest.getIns​tance("MD5");
        digest.update(String​.valueOf(Math.random​()).getBytes());
        digest.update(String​.valueOf(System.curr​entTimeMillis()).get​Bytes());
        digest.update(table.​getBytes());
        digest.update(String​.valueOf(id).getByte​s());
        byte[] bytes = digest.digest();
        StringBuffer buffer = new StringBuffer();
        char[] hex = "0123456789abcdef".t​oCharArray();
        for (int i = 0; i < bytes.length; i++) {
            buffer.append(hex[(bytes[i] >> 4) & 0x0f]);
            buffer.append(hex[bytes[i] & 0x0f]);
        }
        return buffer.toString();
    }

    protected String create(MidgardUser user, String table, int id, Date time)
            throws SyncSourceException {
        logger.debug("create({}, {}, id)", user, table);
        try {
            PreparedStatement update = connection.prepareStatement(
                    "INSERT INTO repligard"
                    + " (action, typename, object_action, author, realm, id, guid, sitegroup, updated, changed)"
                    + " VALUES ('create', 'org_openpsa_event', 0, ?, ?, ?, ?, ?, ?, ?)");
            try {
                String guid = makeGuid(table, id);
                update.setInt(1, user.getId());
                update.setString(2, table);
                update.setInt(3, id);
                update.setString(4, guid);
                update.setInt(5, user.getSitegroup());
                update.setTimestamp(6, new Timestamp(time.getTime()));
                update.setTimestamp(7, new Timestamp(time.getTime()));
                update.executeUpdate();
                return guid;
            } finally {
                update.close();
            }
        } catch (Exception e) {
            throw new SyncSourceException("Database error: " + e.getMessage(), e);
        }
    }

    protected String update(MidgardUser user, String table, int id, Date time)
            throws SyncSourceException {
        logger.debug("update({}, {}, id)", user, table);
        try {
            int rv;
            String sql =
                "UPDATE repligard SET updated = ?, changed = ?,"
                + " object_action=4, author = ? WHERE realm = ? AND id = ?";
            PreparedStatement update = connection.prepareSt​atement(sql);
            try {
                update.setTimestamp(1, new Timestamp(time.getTime()));
                update.setTimestamp(2, new Timestamp(time.getTime()));
                update.setInt(3, user.getId());
                update.setString(4, table);
                update.setInt(5, id);
                rv = update.executeUpdate();
            } finally {
                update.close();
            }

            if (rv > 0) {
                sql = "SELECT guid FROM repligard WHERE realm = ? AND id = ?";
                PreparedStatement select = connection.prepareSt​atement(sql);
                try {
                    select.setString(1, table);
                    select.setInt(2, id);
                    ResultSet rs = select.executeQuery();
                    try {
                        if (rs.next()) {
                            return rs.getString(1);
                        } else {
                            throw new SyncSourceException(
                                    "Repligard entry not found: " + table + "(" + id +")");
                        }
                    } finally {
                        rs.close();
                    }
                } finally {
                    select.close();
                }
            } else {
                sql = "INSERT INTO repligard"
                    + " (action, typename, object_action, author, realm, id, sitegroup, guid, updated, changed)"
                    + " VALUES ('update' ,'org_openpsa_event', 0, ?, ?, ?, ?, ?, ?, ?)";
                PreparedStatement create = connection.prepareSt​atement(sql);
                try {
                    String guid = makeGuid(table, id);
                    create.setInt(1, user.getId());
                    create.setString(2, table);
                    create.setInt(3, id);
                    create.setInt(4, user.getSitegroup());
                    create.setString(5, guid);
                    create.setTimestamp(6, new Timestamp(time.getTime()));
                    create.setTimestamp(7, new Timestamp(time.getTime()));
                    create.executeUpdate();
                    return guid;
                } finally {
                    update.close();
                }
            }
        } catch (Exception e) {
            throw new SyncSourceException("Database error: " + e.getMessage(), e);
        }
    }

    protected void delete(MidgardUser user, String table, int id, Date time)
            throws SyncSourceException {
        try {
               // Setting metadata_deleted to 0
               PreparedStatement delete = connection.prepareStatement(
                       "UPDATE " + table + " SET metadata_deleted=? WHERE id=?");
            
               /* We no longer actually delete anythin
            PreparedStatement delete = connection.prepareStatement(
                    "DELETE FROM " + table + " WHERE id = ?");
            */
            try {
                   delete.setInt(1, 1);
                delete.setInt(2, id);
                delete.executeUpdate();
            } finally {
                delete.close();
            }

            PreparedStatement update = connection.prepareStatement(
                    "UPDATE repligard SET updated = ?, changed = ?,"
                    + " object_action=1, author = ? WHERE realm = ? AND id = ?");
            try {
                update.setTimestamp(1, new Timestamp(time.getTime()));
                update.setTimestamp(2, new Timestamp(time.getTime()));
                update.setInt(3, user.getId());
                update.setString(4, table);
                update.setInt(5, id);
                update.executeUpdate();
            } finally {
                update.close();
            }
        } catch (SQLException e) {
            throw new SyncSourceException("Database error: " + e.getMessage(), e);
        }
    }

}
\ No newline at end of file
+/*
 * Copyright 2006 Jukka Zitting <jz at yukatan dot fi>
 * Copyright 2006 Nemein Oy <info at nemein dot com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */
package org.openpsa.sync4j;

import java.security.MessageDigest;
import java.security.NoSuch​AlgorithmException;
import java.security.Principal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import sync4j.framework.eng​ine.source.SyncSourc​eException;

import com.mysql.jdbc.jdbc2​.optional.MysqlDataS​ource;

public abstract class OpenPSAComponent {

    private static final Logger logger =
        LoggerFactory.getLog​ger(OpenPSAComponent​.class);

    private String hostname = "localhost";

    private String database = "midgard";

    private String username = "midgard";

    private String password = "midgard";

    private String sitegroup;

    private Connection connection;

    //------------------​--------------------​-------------< getters & setters >

    public String getHostname() {
        return hostname;
    }

    public void setHostname(String hostname) {
        this.hostname = hostname;
    }

    public String getDatabase() {
        return database;
    }

    public void setDatabase(String database) {
        this.database = database;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSitegroup() {
        return sitegroup;
    }

    public void setSitegroup(String sitegroup) {
        this.sitegroup = sitegroup;
    }

    //------------------​--------------------​--------------------​-< protected >

    protected void connect() throws SQLException {
        MysqlDataSource source = new MysqlDataSource();
        source.setServerName(hostname);
        source.setDatabaseNa​me(database);
        source.setUser(username);
        source.setPassword(password);
        connection = source.getConnection();
    }

    protected void close() throws SQLException {
        connection.close();
    }

    protected PreparedStatement prepare(String sql) throws SQLException {
        return connection.prepareSt​atement(sql);
    }

    protected PreparedStatement prepare(String sql, int flags) throws SQLException {
        return connection.prepareSt​atement(sql, flags);
    }

    protected int getSitegroupID() throws SQLException {
        if (sitegroup == null || sitegroup.length() == 0) {
            return 0;
        } else {
            String sql = "SELECT id FROM sitegroup WHERE name = ?";
            PreparedStatement ps = connection.prepareSt​atement(sql);
            try {
                ps.setString(1, sitegroup);
                ResultSet rs = ps.executeQuery();
                try {
                    if (rs.next()) {
                        return rs.getInt(1);
                    } else {
                        throw new SQLException("Bad sitegroup: " + sitegroup);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                ps.close();
            }
        }
    }

    protected Date getRevised(String table, int id) throws SQLException {
        String sql = "SELECT changed FROM repligard WHERE realm = ? AND id = ?";
        PreparedStatement ps = prepare(sql);
        try {
            ps.setString(1, table);
            ps.setInt(2, id);
            ResultSet rs = ps.executeQuery();
            try {
                Date revised = null;
                if (rs.next()) {
                    revised = rs.getDate(1);
                }
                if (revised != null) {
                    return revised;
                } else {
                    return new Date();
                }
            } finally {
                rs.close();
            }
        } finally {
            ps.close();
        }
    }

    protected MidgardUser getUser(Principal principal)
            throws SyncSourceException {
        logger.debug("getUser({})", principal);
        String name = principal.getName();

        // Skip the Sync4J device prefix
        int p = name.indexOf('/');
        if (p != -1) {
            name = name.substring(p + 1);
        }

        int q = name.lastIndexOf('@');
        if (q == -1) {
            throw new SyncSourceException(
                    "Invalid principal: " + principal.getName());
        }

        try {
            String sql =
                "SELECT p.id, r.guid, s.id, p.created,"
                + " NULLIF(r.changed,'0000-00-00'), NULLIF(r.updated,'0000-00-00')"
                + " FROM person AS p, sitegroup AS s, repligard AS r"
                + " WHERE p.sitegroup = s.id AND r.sitegroup = s.id"
                + " AND r.realm = 'person' AND r.id = p.id"
                + " AND p.username = ? AND s.name = ?";
            PreparedStatement ps = connection.prepareSt​atement(sql);
            try {
                ps.setString(1, name.substring(0, q));
                ps.setString(2, name.substring(q + 1));
                ResultSet rs = ps.executeQuery();
                try {
                    if (rs.next()) {
                        MidgardUser user = new MidgardUser();
                        user.setTable("person");
                        user.setId(rs.getInt(1));
                        user.setGuid(rs.getString(2));
                        user.setSitegroup(rs​.getInt(3));
                        user.setCreated(rs.g​etTimestamp(4));
                        Date c = rs.getTimestamp(5);
                        if (c == null) {
                            c = user.getCreated();
                        }
                        Date u = rs.getTimestamp(6);
                        if (u == null || u.before(c)) {
                            user.setUpdated(c);
                        } else {
                            user.setUpdated(u);
                        }
                        user.setUsername(nam​e.substring(0, q));
                        return user;
                    } else {
                        throw new SyncSourceException(
                                "Principal not found: " + principal.getName());
                    }
                } finally {
                    rs.close();
                }
            } finally {
                ps.close();
            }
        } catch (SQLException e) {
            throw new SyncSourceException("Database error: " + e.getMessage(), e);
        }
    }

    protected int locate(MidgardUser user, String table, String guid)
            throws SyncSourceException {
        logger.debug("locate({}, {})", table, guid);
        try {
            String sql = "SELECT id FROM repligard"
                + " WHERE sitegroup = ? AND realm = ? AND guid = ?";
            PreparedStatement ps = connection.prepareSt​atement(sql);
            try {
                ps.setInt(1, user.getSitegroup());
                ps.setString(2, table);
                ps.setString(3, guid);
                ResultSet rs = ps.executeQuery();
                try {
                    if (rs.next()) {
                        return rs.getInt(1);
                    } else {
                        return 0;
                    }
                } finally {
                    rs.close();
                }
            } finally {
                ps.close();
            }
        } catch (SQLException e) {
            throw new SyncSourceException("Database error: " + e.getMessage(), e);
        }
    }

    private String makeGuid(String table, int id) throws NoSuchAlgorithmException {
        MessageDigest digest = MessageDigest.getIns​tance("MD5");
        digest.update(String​.valueOf(Math.random​()).getBytes());
        digest.update(String​.valueOf(System.curr​entTimeMillis()).get​Bytes());
        digest.update(table.​getBytes());
        digest.update(String​.valueOf(id).getByte​s());
        byte[] bytes = digest.digest();
        StringBuffer buffer = new StringBuffer();
        char[] hex = "0123456789abcdef".t​oCharArray();
        for (int i = 0; i < bytes.length; i++) {
            buffer.append(hex[(bytes[i] >> 4) & 0x0f]);
            buffer.append(hex[bytes[i] & 0x0f]);
        }
        return buffer.toString();
    }

    protected String create(MidgardUser user, String table, int id, Date time)
            throws SyncSourceException {
        logger.debug("create({}, {}, id)", user, table);
        try {
            PreparedStatement update = connection.prepareStatement(
                    "INSERT INTO repligard"
                    + " (action, typename, object_action, author, realm, id, guid, sitegroup, updated, changed)"
                    + " VALUES ('create', 'org_openpsa_event', 0, ?, ?, ?, ?, ?, ?, ?)");
            try {
                String guid = makeGuid(table, id);
                update.setInt(1, user.getId());
                update.setString(2, table);
                update.setInt(3, id);
                update.setString(4, guid);
                update.setInt(5, user.getSitegroup());
                update.setTimestamp(6, new Timestamp(time.getTime()));
                update.setTimestamp(7, new Timestamp(time.getTime()));
                update.executeUpdate();
                return guid;
            } finally {
                update.close();
            }
        } catch (Exception e) {
            throw new SyncSourceException("Database error: " + e.getMessage(), e);
        }
    }

    protected String update(MidgardUser user, String table, int id, Date time)
            throws SyncSourceException {
        logger.debug("update({}, {}, id)", user, table);
        try {
            int rv;
            String sql =
                "UPDATE repligard SET updated = ?, changed = ?,"
                + " object_action=4, author = ? WHERE realm = ? AND id = ?";
            PreparedStatement update = connection.prepareSt​atement(sql);
            try {
                update.setTimestamp(1, new Timestamp(time.getTime()));
                update.setTimestamp(2, new Timestamp(time.getTime()));
                update.setInt(3, user.getId());
                update.setString(4, table);
                update.setInt(5, id);
                rv = update.executeUpdate();
            } finally {
                update.close();
            }

            if (rv > 0) {
                sql = "SELECT guid FROM repligard WHERE realm = ? AND id = ?";
                PreparedStatement select = connection.prepareSt​atement(sql);
                try {
                    select.setString(1, table);
                    select.setInt(2, id);
                    ResultSet rs = select.executeQuery();
                    try {
                        if (rs.next()) {
                            return rs.getString(1);
                        } else {
                            throw new SyncSourceException(
                                    "Repligard entry not found: " + table + "(" + id +")");
                        }
                    } finally {
                        rs.close();
                    }
                } finally {
                    select.close();
                }
            } else {
                sql = "INSERT INTO repligard"
                    + " (action, typename, object_action, author, realm, id, sitegroup, guid, updated, changed)"
                    + " VALUES ('update' ,'org_openpsa_event', 0, ?, ?, ?, ?, ?, ?, ?)";
                PreparedStatement create = connection.prepareSt​atement(sql);
                try {
                    String guid = makeGuid(table, id);
                    create.setInt(1, user.getId());
                    create.setString(2, table);
                    create.setInt(3, id);
                    create.setInt(4, user.getSitegroup());
                    create.setString(5, guid);
                    create.setTimestamp(6, new Timestamp(time.getTime()));
                    create.setTimestamp(7, new Timestamp(time.getTime()));
                    create.executeUpdate();
                    return guid;
                } finally {
                    update.close();
                }
            }
        } catch (Exception e) {
            throw new SyncSourceException("Database error: " + e.getMessage(), e);
        }
    }

    protected void delete(MidgardUser user, String table, int id, Date time)
            throws SyncSourceException {
        try {
               // Setting metadata_deleted to 0 == "deleting"
               PreparedStatement delete = connection.prepareStatement(
                       "UPDATE " + table + " SET metadata_deleted=? WHERE id=?");
            
               /* We no longer actually delete anythin
            PreparedStatement delete = connection.prepareStatement(
                    "DELETE FROM " + table + " WHERE id = ?");
            */
            try {
                   delete.setInt(1, 1);
                delete.setInt(2, id);
                delete.executeUpdate();
            } finally {
                delete.close();
            }

            PreparedStatement update = connection.prepareStatement(
                    "UPDATE repligard SET updated = ?, changed = ?,"
                    + " object_action=1, author = ? WHERE realm = ? AND id = ?");
            try {
                update.setTimestamp(1, new Timestamp(time.getTime()));
                update.setTimestamp(2, new Timestamp(time.getTime()));
                update.setInt(3, user.getId());
                update.setString(4, table);
                update.setInt(5, id);
                update.executeUpdate();
            } finally {
                update.close();
            }
        } catch (SQLException e) {
            throw new SyncSourceException("Database error: " + e.getMessage(), e);
        }
    }

}
\ No newline at end of file

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /openpsa/addons/funambol/src/java/org/openpsa/sync4j/OpenPSAComponent.java juhana Juhana Hirvilahti 2007-03-02 05:49:04 PST
Messages per page: