KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webdav > ant > taskdefs > Mkcol


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

22 package org.apache.webdav.ant.taskdefs;
23
24 import java.io.IOException JavaDoc;
25
26 import org.apache.tools.ant.BuildException;
27 import org.apache.tools.ant.Project;
28 import org.apache.webdav.ant.Utils;
29
30 /**
31  * WebDAV task for creating collections.
32  *
33  * @see <a HREF="../doc-files/tasks.htm#mkcol">Task documentation</a>
34  */

35 public class Mkcol extends WebdavTask {
36    private String JavaDoc locktoken = null;
37    
38    /*
39     * @see org.apache.tools.ant.Task#execute()
40     */

41    public void execute() throws BuildException {
42       validate();
43       try {
44          boolean created = Utils.assureExistingCollection(
45                                     getHttpClient(),
46                                     getUrl(),
47                                     this.locktoken);
48          if (created) {
49             log("Created collection " + getUrl(), Project.MSG_INFO);
50          }
51       }
52       catch (IOException JavaDoc e) {
53          throw Utils.makeBuildException("Can't make collection!", e);
54       }
55    }
56    
57
58    public void setLocktoken(String JavaDoc token) {
59       this.locktoken = token;
60       if (!this.locktoken.startsWith("opaquelocktoken:")) {
61          throw new BuildException("Invalid locktoken: " + token);
62       }
63    }
64 }
65
Popular Tags