![JAR search and dependency download from the Maven repository](/logo.png)
org.jivesoftware.openfire.vcard.DefaultVCardProvider Maven / Gradle / Ivy
The newest version!
/*
* Copyright (C) 2004-2008 Jive Software. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.openfire.vcard;
import java.io.StringReader;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.AlreadyExistsException;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.NotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Default implementation of the VCardProvider interface, which reads and writes data
* from the ofVCard database table.
*
* @author Gaston Dombiak
*/
public class DefaultVCardProvider implements VCardProvider {
private static final Logger Log = LoggerFactory.getLogger(DefaultVCardProvider.class);
private static final String LOAD_PROPERTIES =
"SELECT vcard FROM ofVCard WHERE username=?";
private static final String DELETE_PROPERTIES =
"DELETE FROM ofVCard WHERE username=?";
private static final String UPDATE_PROPERTIES =
"UPDATE ofVCard SET vcard=? WHERE username=?";
private static final String INSERT_PROPERTY =
"INSERT INTO ofVCard (username, vcard) VALUES (?, ?)";
private static final int POOL_SIZE = 10;
/**
* Pool of SAX Readers. SAXReader is not thread safe so we need to have a pool of readers.
*/
private BlockingQueue xmlReaders = new LinkedBlockingQueue<>(POOL_SIZE);
public DefaultVCardProvider() {
super();
// Initialize the pool of sax readers
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy