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.smack.SmackException.NoResponseException; 021import org.jivesoftware.smack.SmackException.NotConnectedException; 022import org.jivesoftware.smack.XMPPConnection; 023import org.jivesoftware.smack.XMPPException.XMPPErrorException; 024 025import org.jivesoftware.smackx.workgroup.packet.Transcript; 026import org.jivesoftware.smackx.workgroup.packet.Transcripts; 027 028import org.jxmpp.jid.Jid; 029 030/** 031 * A TranscriptManager helps to retrieve the full conversation transcript of a given session 032 * {@link #getTranscript(Jid, String)} or to retrieve a list with the summary of all the 033 * conversations that a user had {@link #getTranscripts(Jid, Jid)}. 034 * 035 * @author Gaston Dombiak 036 */ 037public class TranscriptManager { 038 private XMPPConnection connection; 039 040 public TranscriptManager(XMPPConnection connection) { 041 this.connection = connection; 042 } 043 044 /** 045 * Returns the full conversation transcript of a given session. 046 * 047 * @param sessionID the id of the session to get the full transcript. 048 * @param workgroupJID the JID of the workgroup that will process the request. 049 * @return the full conversation transcript of a given session. 050 * @throws XMPPErrorException 051 * @throws NoResponseException 052 * @throws NotConnectedException 053 * @throws InterruptedException 054 */ 055 public Transcript getTranscript(Jid workgroupJID, String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 056 Transcript request = new Transcript(sessionID); 057 request.setTo(workgroupJID); 058 Transcript response = connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); 059 return response; 060 } 061 062 /** 063 * Returns the transcripts of a given user. The answer will contain the complete history of 064 * conversations that a user had. 065 * 066 * @param userID the id of the user to get his conversations. 067 * @param workgroupJID the JID of the workgroup that will process the request. 068 * @return the transcripts of a given user. 069 * @throws XMPPErrorException 070 * @throws NoResponseException 071 * @throws NotConnectedException 072 * @throws InterruptedException 073 */ 074 public Transcripts getTranscripts(Jid workgroupJID, Jid userID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 075 Transcripts request = new Transcripts(userID); 076 request.setTo(workgroupJID); 077 Transcripts response = connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); 078 return response; 079 } 080}