How to connect to CVs I used wincvs GUI but it doesnot connect ever I use the the CVs root [EMAIL PROTECTED]:/home/cvspublic
It says that server refused the connection??? -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 13, 2004 11:08 AM To: [EMAIL PROTECTED] Subject: cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/event NotificationTrigger.java Subscriber.java luetzkendorf 2004/07/13 02:08:19 Modified: src/webdav/server/org/apache/slide/webdav/event NotificationTrigger.java Subscriber.java Log: some changes to satisfy the notification test cases Revision Changes Path 1.11 +51 -35 jakarta-slide/src/webdav/server/org/apache/slide/webdav/event/NotificationTr igger.java Index: NotificationTrigger.java =================================================================== RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/event/Noti ficationTrigger.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- NotificationTrigger.java 12 May 2004 11:09:47 -0000 1.10 +++ NotificationTrigger.java 13 Jul 2004 09:08:18 -0000 1.11 @@ -80,6 +80,8 @@ } public boolean removeSubscriber(Subscriber subscriber) { + Domain.log("Removing subscriber with ID: "+subscriber.getId(), LOG_CHANNEL, Logger.INFO); + subscriber.getLifetime().cancel(); return subscribers.remove(subscriber); } @@ -122,8 +124,11 @@ private void notifySubscribers(EventCollection collection) { Map subscriberEnumerations = new HashMap(); - ContentEvent[] update = EventCollectionFilter.getChangedContents(collection); List matchingSubscribers = new ArrayList(); + + // get subscribers with matching notification types + // (and remember events) + ContentEvent[] update = EventCollectionFilter.getChangedContents(collection); for ( int i = 0; i < update.length; i++ ) { matchingSubscribers.addAll(getSubscribers(Subscriber.UPDATE, update[i])); } @@ -136,34 +141,42 @@ matchingSubscribers.addAll(getSubscribers(Subscriber.DELETE, delete[i])); } // FIXME: Add methods for MOVE, and NEW_MAIL (??) to get full exchange notification compliance + + // notifiy subscribers for ( Iterator i = matchingSubscribers.iterator(); i.hasNext(); ) { - final Subscriber subscriber = (Subscriber)i.next(); - if ( subscriber.getNotificationDelay() == 0 ) { - // send notification without delay - List idList = (List)subscriberEnumerations.get(subscriber.getCallback()); - if ( idList == null ) { - idList = new ArrayList(); - subscriberEnumerations.put(subscriber.getCallback(), idList); - } - Integer subscriberId = new Integer(subscriber.getId()); - if ( !idList.contains(subscriberId) ) { - idList.add(subscriberId); - } - } else { - // send delayed notification - TimerTask notifyTask = subscriber.getNotify(); - if ( notifyTask == null ) { - Domain.log("Starting notification delay: "+subscriber.getNotificationDelay(), LOG_CHANNEL, Logger.INFO); - notifyTask = new TimerTask() { - public void run() { - notifySubscriber(subscriber.getCallback(), String.valueOf(subscriber.getId())); - subscriber.setNotify(null); - } - }; - subscriber.setNotify(notifyTask); - timer.schedule(notifyTask, subscriber.getNotificationDelay()*1000); - } - } + final Subscriber subscriber = (Subscriber)i.next(); + + // skip subscribers that has no callback (we can't notify them) + if (!subscriber.hasCallback()) continue; + + if ( subscriber.getNotificationDelay() == 0 ) { + // send notification without delay + List idList = (List)subscriberEnumerations.get(subscriber.getCallback()); + if ( idList == null ) { + idList = new ArrayList(); + subscriberEnumerations.put(subscriber.getCallback(), idList); + } + Integer subscriberId = new Integer(subscriber.getId()); + if ( !idList.contains(subscriberId) ) { + idList.add(subscriberId); + } + } else { + // send delayed notification + TimerTask notifyTask = subscriber.getNotify(); + if ( notifyTask == null ) { + Domain.log("Starting notification delay: "+subscriber.getNotificationDelay(), + LOG_CHANNEL, Logger.INFO); + notifyTask = new TimerTask() { + public void run() { + notifySubscriber(subscriber.getCallback(), + String.valueOf(subscriber.getId())); + subscriber.setNotify(null); + } + }; + subscriber.setNotify(notifyTask); + timer.schedule(notifyTask, subscriber.getNotificationDelay()*1000); + } + } } for ( Iterator i = subscriberEnumerations.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry)i.next(); @@ -185,14 +198,16 @@ } } - private void notifySubscriber(String callback, String subscribers) { + protected void notifySubscriber(String callback, String subscribers) { if ( callback.startsWith(TCP_PROTOCOL) ) { Domain.log("Notify subscribers with adress='"+callback+"' via TCP with id's "+subscribers, LOG_CHANNEL, Logger.INFO); NotifyMethod notifyMethod = new NotifyMethod(callback.toString()); notifyMethod.addRequestHeader(H_SUBSCRIPTION_ID_RESPONSE, subscribers); try { URL url = new URL(callback); - int state = notifyMethod.execute(new HttpState(), new HttpConnection(url.getHost(), url.getPort())); + notifyMethod.execute( + new HttpState(), new HttpConnection(url.getHost(), + url.getPort()!=-1 ? url.getPort() : 80)); } catch (IOException e) { Domain.log("Notification of subscriber '"+callback.toString()+"' failed!"); } @@ -203,7 +218,8 @@ String notification = "NOTIFY "+callback+" HTTP/1.1\nSubscription-id: "+subscribers; byte[] buf = notification.getBytes(); InetAddress address = InetAddress.getByName(url.getHost()); - DatagramPacket packet = new DatagramPacket(buf, buf.length, address, url.getPort()); + DatagramPacket packet = new DatagramPacket( + buf, buf.length, address, url.getPort()!=-1 ? url.getPort() : 80); socket.send(packet); } catch (IOException e) { Domain.log("Notification of subscriber '"+callback.toString()+"' failed!", LOG_CHANNEL, Logger.ERROR); 1.9 +11 -7 jakarta-slide/src/webdav/server/org/apache/slide/webdav/event/Subscriber.jav a Index: Subscriber.java =================================================================== RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/event/Subs criber.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- Subscriber.java 2 Jul 2004 12:04:28 -0000 1.8 +++ Subscriber.java 13 Jul 2004 09:08:18 -0000 1.9 @@ -90,9 +90,9 @@ // check if event matches notification-type // see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wss/wss/_we bdav_notification_type_header.asp // for details - if ( notificationType.equals(type) || - ( type.equals(NEW_MEMBER) && notificationType.equals(UPDATE) && depth == 1 ) || - ( type.equals(DELETE) && notificationType.equals(UPDATE) && depth == 1 ) ){ + if ( type.equalsIgnoreCase(notificationType) || + ( type.equalsIgnoreCase(NEW_MEMBER) && notificationType.equalsIgnoreCase(UPDATE) && depth > 0 ) || + ( type.equalsIgnoreCase(DELETE) && notificationType.equalsIgnoreCase(UPDATE) && depth > 0 ) ){ String eventUri = event.getUri(); if ( eventUri != null && uri != null ) { if ( depth == 0 && eventUri.equals(uri.toString()) ) return true; @@ -107,6 +107,10 @@ return false; } + public boolean hasCallback() { + return this.callback != null && this.callback.length() > 0; + } + public String getCallback() { return callback; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
