Package org.jivesoftware.openfire

Examples of org.jivesoftware.openfire.XMPPServer$ShutdownHookThread


    private void enableService(boolean enabled) {
        if (serviceEnabled == enabled) {
            // Do nothing if the service status has not changed
            return;
        }
        XMPPServer server = XMPPServer.getInstance();
        if (!enabled) {
            // Disable disco information
            server.getIQDiscoItemsHandler().removeServerItemsProvider(this);
            // Stop the service/module
            stop();
        }
        serviceEnabled = enabled;
        if (enabled) {
            // Start the service/module
            start();
            // Enable disco information
            server.getIQDiscoItemsHandler().addServerItemsProvider(this);
        }
    }
View Full Code Here


  private void notify(String fromJID, ActivityEntry entry) throws UserNotFoundException {

    // TODO We may want to do some cleaning of activities before
    // forwarding them (e.g. remove the acl, it is no one business)
    final ActivityDomWriter writer = new DefaultActivityDomWriter();
    final XMPPServer server = XMPPServer.getInstance();
    final List<Subscription> subscriptions = getSubscribers(fromJID);
  //  final Roster roster = XMPPServer.getInstance().getRosterManager().getRoster(new JID(fromJID).getNode());
    final DOMDocument domDocument = new DOMDocument();

    // Prepare the message
    final Element entryElement = (Element) domDocument.appendChild(domDocument.createElementNS(Atom.NAMESPACE, Atom.ENTRY_ELEMENT));
    writer.write(entry, entryElement);
    domDocument.removeChild(entryElement);

    final Message message = new Message();
    message.setFrom(fromJID);
    message.setBody("New activity: " + entry.getTitle());
    message.setType(Message.Type.headline);
    org.dom4j.Element eventElement = message.addChildElement("event", "http://jabber.org/protocol/pubsub#event");
    org.dom4j.Element itemsElement = eventElement.addElement("items");
    itemsElement.addAttribute("node", PEPActivityHandler.NODE);
    org.dom4j.Element itemElement = itemsElement.addElement("item");
    itemElement.addAttribute("id", entry.getId());
    itemElement.add((org.dom4j.Element) entryElement);

    // Keep a list of people we sent it to avoid duplicates
    List<String> alreadySent = new ArrayList<String>();
   
    // Send to this user
    alreadySent.add(fromJID);
    message.setTo(fromJID);
    server.getMessageRouter().route(message)
           
    // Send to all subscribers
    for (Subscription activitySubscription : subscriptions) {
      String recipientJID = activitySubscription.getSubscriber();
      if (!canSee(fromJID, entry, recipientJID)) {
        continue;
      }
      alreadySent.add(recipientJID);           
      message.setTo(recipientJID);
      server.getMessageRouter().route(message)
    }

    // Send to recipients, if they can see it and have not already received it
    if (entry.hasRecipients()) {
      for (AtomReplyTo recipient : entry.getRecipients()) {
        //TODO This is dirty, the recipient should be an IRI etc...
        String recipientJID = recipient.getHref()
        if (!alreadySent.contains(recipientJID) && canSee(fromJID, entry, recipientJID)) {
          alreadySent.add(fromJID);
         
          message.setTo(recipientJID);
          server.getMessageRouter().route(message);                       
        }
      }
    }     
  }
View Full Code Here

 

  private void notifyDelete(String fromJID, String activityId) {

   
    final XMPPServer server = XMPPServer.getInstance();
    final List<Subscription> subscriptions = getSubscribers(fromJID);
 
    // Prepare the message
   
    final Message message = new Message();
    message.setFrom(fromJID);
    message.setBody("Delete activity: " + activityId);
    message.setType(Message.Type.headline);
   
    org.dom4j.Element eventElement = message.addChildElement("event", "http://jabber.org/protocol/pubsub#event");
    org.dom4j.Element itemsElement = eventElement.addElement("items");
    itemsElement.addAttribute("node", PEPActivityHandler.NODE);
    org.dom4j.Element retractElement = itemsElement.addElement("retract");
    retractElement.addAttribute("id", activityId);
   

    // Keep a list of people we sent it to avoid duplicates
    List<String> alreadySent = new ArrayList<String>();
   
    // Send to this user
    alreadySent.add(fromJID);
    message.setTo(fromJID);
    server.getMessageRouter().route(message)
           
    // Send to all subscribers
    for (Subscription activitySubscription : subscriptions) {
      String recipientJID = activitySubscription.getSubscriber();     
      alreadySent.add(recipientJID);           
      message.setTo(recipientJID);
      server.getMessageRouter().route(message)
    }     
   
  }
View Full Code Here

            if ( token == null ) {
                throw new ServletException("Missing some data, yo");
            }
           
           
            XMPPServer server = XMPPServer.getInstance();
            FileTransferManager ftm = server.getFileTransferManager();


            // process files
            for (FileItem item : (List<FileItem>) items) {
                if (!item.isFormField()) {
View Full Code Here

* @author Harlan
*/
public class HttpFileXferInterceptor implements FileTransferInterceptor {

    public void interceptFileTransfer(FileTransfer fileTransfer, boolean isReady) throws FileTransferRejectedException {
        XMPPServer server = XMPPServer.getInstance();
       
        JID initiator = new JID(fileTransfer.getInitiator());
        JID receiver = new JID(fileTransfer.getTarget());
        Session initiatorSession = server.getSessionManager().getSession(initiator);
        Session receiverSession = server.getSessionManager().getSession(receiver);
       
        // initial request initiated locally from an HTTP session
        if( !isReady
                && server.isLocal( initiator )
                && initiatorSession != null
                && initiatorSession instanceof HttpSession ) {
           
            // TODO:
            // - tell servlet we're expecting a file with a given ID
            // - silently discard the packet without notifying anyone
            //   - actually, give the initiator a URL to post to w/ token?
            // - servlet continues where the POSTed file left off
           
            HttpSession httpSession = (HttpSession)initiatorSession;
            HttpConnection httpConnection = (HttpConnection)httpSession.getConnection();
           
           
            // does getServerName include port? is it the actual HTTP host name?
            String transferPostUrl = "http://"+httpSession.getServerName()+"/fileupload.jsp";

            IQ httpInfoIQ = new IQ(IQ.Type.set);
            httpInfoIQ.setTo(initiator);
            // FIXME this seems like gross misuse of error... make a custom packet extension.
            httpInfoIQ.setError(new PacketError(PacketError.Condition.redirect, PacketError.Type.modify, transferPostUrl) );
           
            throw new FileTransferRejectedException("HTTP client resuming via upload servlet");
           
           

           
           
        // file stream initiated from anywhere destined for an HTTP stream
        } else if( isReady
                && server.isLocal(receiver)
                && receiverSession != null
                && receiverSession instanceof HttpSession ) {
           
            // TODO can we just make a data: iframe on the client side?
        }
View Full Code Here

TOP

Related Classes of org.jivesoftware.openfire.XMPPServer$ShutdownHookThread

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.