001/** 002 * 003 * Copyright 2003-2007 Jive Software. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.jivesoftware.smackx.workgroup.agent; 019 020import org.jivesoftware.smackx.workgroup.packet.Transcript; 021import org.jivesoftware.smackx.workgroup.packet.Transcripts; 022import org.jivesoftware.smack.SmackException.NoResponseException; 023import org.jivesoftware.smack.SmackException.NotConnectedException; 024import org.jivesoftware.smack.XMPPConnection; 025import org.jivesoftware.smack.XMPPException.XMPPErrorException; 026import org.jxmpp.jid.Jid; 027 028/** 029 * A TranscriptManager helps to retrieve the full conversation transcript of a given session 030 * {@link #getTranscript(Jid, String)} or to retrieve a list with the summary of all the 031 * conversations that a user had {@link #getTranscripts(Jid, Jid)}. 032 * 033 * @author Gaston Dombiak 034 */ 035public class TranscriptManager { 036 private XMPPConnection connection; 037 038 public TranscriptManager(XMPPConnection connection) { 039 this.connection = connection; 040 } 041 042 /** 043 * Returns the full conversation transcript of a given session. 044 * 045 * @param sessionID the id of the session to get the full transcript. 046 * @param workgroupJID the JID of the workgroup that will process the request. 047 * @return the full conversation transcript of a given session. 048 * @throws XMPPErrorException 049 * @throws NoResponseException 050 * @throws NotConnectedException 051 * @throws InterruptedException 052 */ 053 public Transcript getTranscript(Jid workgroupJID, String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 054 Transcript request = new Transcript(sessionID); 055 request.setTo(workgroupJID); 056 Transcript response = (Transcript) connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); 057 return response; 058 } 059 060 /** 061 * Returns the transcripts of a given user. The answer will contain the complete history of 062 * conversations that a user had. 063 * 064 * @param userID the id of the user to get his conversations. 065 * @param workgroupJID the JID of the workgroup that will process the request. 066 * @return the transcripts of a given user. 067 * @throws XMPPErrorException 068 * @throws NoResponseException 069 * @throws NotConnectedException 070 * @throws InterruptedException 071 */ 072 public Transcripts getTranscripts(Jid workgroupJID, Jid userID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 073 Transcripts request = new Transcripts(userID); 074 request.setTo(workgroupJID); 075 Transcripts response = (Transcripts) connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); 076 return response; 077 } 078}