Package org.xmpp.forms

Examples of org.xmpp.forms.DataForm


  private static final Logger Log = LoggerFactory.getLogger(GetGroupConversationTranscript.class);
 
    @Override
  protected void addStageInformation(SessionData data, Element command) {
        DataForm form = new DataForm(DataForm.Type.form);
        form.setTitle("Requesting PDF of conversation transcript");
        form.addInstruction("Fill out this form to request the conversation transcript in PDF format.");

        FormField field = form.addField();
        field.setType(FormField.Type.hidden);
        field.setVariable("FORM_TYPE");
        field.addValue("http://jabber.org/protocol/admin");

        field = form.addField();
        field.setType(FormField.Type.jid_single);
        field.setLabel("JID of the user that participated in the chat");
        field.setVariable("participant");
        field.setRequired(true);

        field = form.addField();
        field.setType(FormField.Type.jid_single);
        field.setLabel("JID of the room");
        field.setVariable("room");
        field.setRequired(true);

        field = form.addField();
        field.setType(FormField.Type.text_single);
        field.setLabel("Time when the chat took place");
        field.setVariable("time");
        field.setRequired(true);

        field = form.addField();
        field.setType(FormField.Type.boolean_type);
        field.setLabel("Include PDF");
        field.setVariable("includePDF");
        field.setRequired(true);

        // Add the form to the command
        command.add(form.getElement());
    }
View Full Code Here


                (ConversationManager) plugin.getModule(ConversationManager.class);
        if (!conversationManager.isArchivingEnabled()) {
            note.addAttribute("type", "error");
            note.setText("Message archiving is not enabled.");

            DataForm form = new DataForm(DataForm.Type.result);

            FormField field = form.addField();
            field.setType(FormField.Type.hidden);
            field.setVariable("FORM_TYPE");
            field.addValue("http://jabber.org/protocol/admin");

            field = form.addField();
            field.setLabel("Conversation Found?");
            field.setVariable("found");
            field.addValue(false);
            // Add form to reply
            command.add(form.getElement());

            return;
        }

        try {
            JID participant = new JID(data.getData().get("participant").get(0));
            JID room = new JID(data.getData().get("room").get(0));
            Date time = DataForm.parseDate(data.getData().get("time").get(0));
            boolean includePDF = DataForm.parseBoolean(data.getData().get("includePDF").get(0));

            // Get archive searcher module
            ArchiveSearcher archiveSearcher = (ArchiveSearcher) plugin.getModule(ArchiveSearcher.class);

            ArchiveSearch search = new ArchiveSearch();
            search.setParticipants(participant);
            search.setIncludeTimestamp(time);
            search.setRoom(room);

            Collection<Conversation> conversations = archiveSearcher.search(search);

            DataForm form = new DataForm(DataForm.Type.result);

            FormField field = form.addField();
            field.setType(FormField.Type.hidden);
            field.setVariable("FORM_TYPE");
            field.addValue("http://jabber.org/protocol/admin");

            field = form.addField();
            field.setLabel("Conversation Found?");
            field.setVariable("found");
            field.addValue(!conversations.isEmpty());

            if (includePDF) {
                ByteArrayOutputStream stream = null;
                if (!conversations.isEmpty()) {
                    stream = new ConversationUtils().getConversationPDF(conversations.iterator().next());
                }

                if (stream != null) {
                    field = form.addField();
                    field.setLabel("PDF");
                    field.setVariable("pdf");
                    field.addValue(StringUtils.encodeBase64(stream.toByteArray()));
                }
            }

            // Add form to reply
            command.add(form.getElement());
        }
        catch (Exception e) {
            Log.error("Error occurred while running the command", e);
            note.addAttribute("type", "error");
            note.setText("Error while processing the command.");
View Full Code Here

    static {
        registeredExtensions.put(QName.get(ELEMENT_NAME, NAMESPACE), ChallengeExtension.class);
    }

    public ChallengeExtension() {
        this( new DataForm(DataForm.Type.form) );
    }
View Full Code Here

   
    public DataForm getChallengeForm() {
        if( challengeForm == null ) {
            Element dataFormElem = element.element( QName.get(DataForm.ELEMENT_NAME, DataForm.NAMESPACE) );
            if( dataFormElem != null ) {
                challengeForm = new DataForm(dataFormElem);
            // TODO how to create new element of none exists? not here.
        }
       
        return challengeForm;
    }
View Full Code Here

    public String getFrom() {
        return getChallengeForm().getField("from").getValues().get(0);
    }
   
    public void setFrom(String from) {
        DataForm challengeForm = getChallengeForm();
       
        FormField field = challengeForm.getField("from");
        if( field == null ) {
            field = challengeForm.addField();
            field.setVariable("from");
            field.setType(FormField.Type.hidden);
           
            field.clearValues();
        }
View Full Code Here

    public String getChallengeId() {
        return getChallengeForm().getField("cid").getValues().get(0);
    }
   
    public void setChallengeId(String challengeId) {
        DataForm challengeForm = getChallengeForm();
       
        FormField field = challengeForm.getField("cid");
        if( field == null ) {
            field = challengeForm.addField();
            field.setVariable("cid");
            field.setType(FormField.Type.hidden);
           
            field.clearValues();
        }
View Full Code Here

    public String getPacketId() {
        return getChallengeForm().getField("sid").getValues().get(0);
    }
   
    public void setPacketId(String packetId) {
        DataForm challengeForm = getChallengeForm();
       
        FormField field = challengeForm.getField("sid");
        if( field == null ) {
            field = challengeForm.addField();
            field.setVariable("sid");
            field.setType(FormField.Type.hidden);
           
            field.clearValues();
        }
View Full Code Here

        }
        field.addValue(packetId);
    }
   
    public void setQAChallenge(String question) {
        DataForm challengeForm = getChallengeForm();
       
        FormField field = challengeForm.getField("qa");
        if( field == null ) {
            field = challengeForm.addField();
            field.setVariable("qa");
            field.setType(FormField.Type.text_single);
        }
        field.setLabel(question);
    }
View Full Code Here

    public void removeQAChallenge() {
        getChallengeForm().removeField("qa");
    }
   
    public void addFormType() {
        DataForm challengeForm = getChallengeForm();
       
        challengeForm.removeField("FORM_TYPE");
       
        FormField field = challengeForm.addField();
        field.setVariable("FORM_TYPE");
        field.setType(FormField.Type.hidden);
        field.addValue("urn:xmpp:tmp:challenge");
    }
View Full Code Here

        field.addValue("urn:xmpp:tmp:challenge");
    }
   
   
    public void addLegacyChallenge(Message challengeMessage) {
        DataForm challengeForm = getChallengeForm();
       
        if( challengeForm == null ) {
            return; //TODO should this throw exception?
        }
       
View Full Code Here

TOP

Related Classes of org.xmpp.forms.DataForm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.