Package org.apache.slide.webdav.event

Examples of org.apache.slide.webdav.event.Subscriber


            Element subscriptionIdNoContent = new Element(E_SUBSCRIPTION_ID, NNSP);
            contentResponse.addContent(subscriptionIdContent);
            noContentResponse.addContent(subscriptionIdNoContent);
            for ( int i = 0; i < subscriptionID.length; i++ ) {
                // sort subscribers by the occurance of events
                Subscriber subscriber = NotificationTrigger.getInstance().getSubscriber(subscriptionID[i]);
                if ( subscriber != null ) {
                    NotificationTrigger.getInstance().refreshSubscriber(subscriber, true);
                    List events = subscriber.getEvents();
                    if ( events.size() == 0 ) {
                        noContent = true;
                        Element listener = new Element(E_LISTENER);
                        listener.addContent(String.valueOf(subscriber.getId()));
                        subscriptionIdNoContent.addContent(listener);
                    } else {
                        content = true;
                        Element listener = new Element(E_LISTENER);
                        listener.addContent(String.valueOf(subscriber.getId()));
                        subscriptionIdContent.addContent(listener);
                        for ( Iterator j = events.iterator(); j.hasNext(); ) {
                            EventObject event = (EventObject)j.next();
                            if ( event instanceof RemoteInformation ) {
                                Element eventElement = new Element(E_EVENT, NNSP);
                                String[][] information = ((RemoteInformation)event).getInformation();
                                for ( int k = 0; k < information.length; k++ ) {
                                    Element entry = new Element(E_INFORMATION, NNSP);
                                    entry.setAttribute(A_INFORMATION_KEY, information[k][0]);
                                    // FIXME: if the information value is a Slide URI, we
                                    // have to add the slideContext
                                    // FIXME: this should be generalized
                                    if ("uri".equals(information[k][0])) {
                                       entry.addContent(
                                             getSlideContextPath() +
                                             String.valueOf(information[k][1]));
                                    } else {
                                       entry.addContent(String.valueOf(information[k][1]));
                                    }
                                    eventElement.addContent(entry);
                                }
                                subscriptionIdContent.addContent(eventElement);
                            }
                        }
                        subscriber.clearEvents();
                    }
                }
            }
            if ( content ) {
                multistatus.addContent(contentResponse);
View Full Code Here


    protected void executeRequest() throws WebdavException {
        try {
            if ( WebdavEvent.UNSUBSCRIBE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(WebdavEvent.UNSUBSCRIBE, new WebdavEvent(this));
            int []subscriptionIDs = requestHeaders.getSubscriptionId();
            for ( int i = 0; i < subscriptionIDs.length; i++ ) {
                Subscriber subscriber = NotificationTrigger.getInstance().getSubscriber(subscriptionIDs[i]);
                NotificationTrigger.getInstance().removeSubscriber(subscriber);
            }
            resp.setStatus(WebdavStatus.SC_OK);
        } catch (Exception e) {
            int statusCode = getErrorCode( (Exception)e );
View Full Code Here

            int []subscriptionIDs = requestHeaders.getSubscriptionId();
           
            if ( subscriptionIDs.length > 0 ) {
                // renew subscribers
                for ( int i = 0; i < subscriptionIDs.length; i++ ) {
                    Subscriber subscriber = NotificationTrigger.getInstance().getSubscriber(subscriptionIDs[i]);
                    if ( subscriber != null ) {
                        NotificationTrigger.getInstance().refreshSubscriber(subscriber, true);
                    }
                }
            } else {
                if (notificationType == null) {
                   sendError(WebdavStatus.SC_BAD_REQUEST, "Notification-Type header missing.");
                   return;
                } else {
                   // FIXME check for valid notification types
                }
                Subscriber subscriber = new Subscriber(requestUri, callback, notificationType, notificationDelay,
                      subscriptionLifetime, depth);
                int subscriptionID = NotificationTrigger.getInstance().addSubscriber(subscriber);
                resp.setHeader(H_CALL_BACK, callback);
                resp.setHeader(H_NOTIFICATION_TYPE, notificationType);
                resp.setHeader(H_SUBSCRIPTION_LIFETIME, String.valueOf(subscriptionLifetime));
View Full Code Here

TOP

Related Classes of org.apache.slide.webdav.event.Subscriber

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.