KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > webdav > method > UnsubscribeMethod


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UnsubscribeMethod.java,v 1.4 2004/08/02 16:36:01 unico Exp $
3  * $Revision: 1.4 $
4  * $Date: 2004/08/02 16:36:01 $
5  *
6  * ====================================================================
7  *
8  * Copyright 2004 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.webdav.method;
25
26
27 import org.apache.slide.common.NamespaceAccessToken;
28 import org.apache.slide.event.EventDispatcher;
29 import org.apache.slide.webdav.WebdavException;
30 import org.apache.slide.webdav.WebdavServletConfig;
31 import org.apache.slide.webdav.event.NotificationTrigger;
32 import org.apache.slide.webdav.event.Subscriber;
33 import org.apache.slide.webdav.event.WebdavEvent;
34 import org.apache.slide.webdav.util.NotificationConstants;
35 import org.apache.slide.webdav.util.WebdavStatus;
36
37
38 /**
39  * Unsubscribe Method.
40  *
41  */

42 public class UnsubscribeMethod extends AbstractWebdavMethod implements NotificationConstants {
43     protected static final String JavaDoc LOG_CHANNEL = UnsubscribeMethod.class.getName();
44
45     /**
46      * Constructor.
47      *
48      * @param token the token for accessing the namespace
49      * @param config configuration of the WebDAV servlet
50      */

51     public UnsubscribeMethod(NamespaceAccessToken token,
52                          WebdavServletConfig config) {
53         super(token, config);
54     }
55     
56     protected void parseRequest() throws WebdavException {
57     }
58
59     protected void executeRequest() throws WebdavException {
60         try {
61             if ( WebdavEvent.UNSUBSCRIBE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(WebdavEvent.UNSUBSCRIBE, new WebdavEvent(this));
62             int []subscriptionIDs = requestHeaders.getSubscriptionId();
63             for ( int i = 0; i < subscriptionIDs.length; i++ ) {
64                 Subscriber subscriber = NotificationTrigger.getInstance().getSubscriber(subscriptionIDs[i]);
65                 NotificationTrigger.getInstance().removeSubscriber(subscriber);
66             }
67             resp.setStatus(WebdavStatus.SC_OK);
68         } catch (Exception JavaDoc e) {
69             int statusCode = getErrorCode( (Exception JavaDoc)e );
70             sendError( statusCode, e );
71             throw new WebdavException( statusCode );
72         }
73     }
74 }
Popular Tags