Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* TeleStax, Open Source Cloud Communications
* Copyright 2011-2014, Telestax Inc and individual contributors
* by the @authors tag.
*
* This program is free software: you can redistribute it and/or modify
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation; either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see
*
*/
package org.restcomm.connect.dao.mybatis;
import static org.restcomm.connect.dao.DaoUtils.readBoolean;
import static org.restcomm.connect.dao.DaoUtils.readDateTime;
import static org.restcomm.connect.dao.DaoUtils.readInteger;
import static org.restcomm.connect.dao.DaoUtils.readSid;
import static org.restcomm.connect.dao.DaoUtils.readString;
import static org.restcomm.connect.dao.DaoUtils.writeDateTime;
import static org.restcomm.connect.dao.DaoUtils.writeSid;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.log4j.Logger;
import org.joda.time.DateTime;
import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe;
import org.restcomm.connect.dao.RegistrationsDao;
import org.restcomm.connect.dao.entities.Registration;
import org.restcomm.connect.commons.dao.Sid;
/**
* @author [email protected] (Thomas Quintana)
* @author [email protected] (Jean Deruelle)
*/
@ThreadSafe
public final class MybatisRegistrationsDao implements RegistrationsDao {
private static final Logger logger = Logger.getLogger(MybatisRegistrationsDao.class);
private static final String namespace = "org.mobicents.servlet.sip.restcomm.dao.RegistrationsDao.";
private final SqlSessionFactory sessions;
public MybatisRegistrationsDao(final SqlSessionFactory sessions) {
super();
this.sessions = sessions;
}
@Override
public void addRegistration(final Registration registration) {
final SqlSession session = sessions.openSession();
try {
session.insert(namespace + "addRegistration", toMap(registration));
session.commit();
} finally {
session.close();
}
}
@Override
public Registration getRegistration(String user) {
final SqlSession session = sessions.openSession();
try {
// https://bitbucket.org/telestax/telscale-restcomm/issue/107/dial-fails-to-call-a-client-registered
// we get all registrations and sort them by latest updated date so that we target the device where the user last
// updated the registration
final List