KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > repository > SourceRepository


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.repository;
17
18 import java.io.IOException JavaDoc;
19
20 import org.apache.excalibur.source.SourceException;
21
22 /**
23  * A stateless utility service intended to be used by flowscripts to help
24  * them with persistent operations on sources.
25  *
26  * <p>
27  * Each operation returns a status code that is based on RFC 2518 (WebDAV).
28  * </p>
29  *
30  * @version $Id: SourceRepository.java 30932 2004-07-29 17:35:38Z vgritsenko $
31  */

32 public interface SourceRepository {
33     
34     public static final String JavaDoc ROLE = SourceRepository.class.getName();
35     
36     /**
37      * Status OK (<b>200</b>).
38      */

39     public static final int STATUS_OK = 200;
40     
41     /**
42      * Status CREATED (<b>201</b>).
43      */

44     public static final int STATUS_CREATED = 201;
45     
46     /**
47      * Status NO_CONTENT (<b>204</b>).
48      */

49     public static final int STATUS_NO_CONTENT = 204;
50     
51     /**
52      * Status FORBIDDEN (<b>403</b>).
53      */

54     public static final int STATUS_FORBIDDEN = 403;
55     
56     /**
57      * Status NOT_FOUND (<b>404</b>).
58      */

59     public static final int STATUS_NOT_FOUND = 404;
60
61     /**
62      * Status NOT_ALLOWED (<b>405</b>).
63      */

64     public static final int STATUS_NOT_ALLOWED = 405;
65     
66     /**
67      * Status CONFLICT (<b>409</b>).
68      */

69     public static final int STATUS_CONFLICT = 409;
70     
71     /**
72      * Status PRECONDITION_FAILED (<b>412</b>)
73      */

74     public static final int STATUS_PRECONDITION_FAILED = 412;
75     
76     
77     /**
78      * Saves a Source by either creating a new one or overwriting the previous one.
79      *
80      * @param in the Source location to read from.
81      * @param out the Source location to write to.
82      * @return a status code describing the exit status.
83      * @throws IOException
84      * @throws SourceException
85      */

86     public abstract int save(String JavaDoc in, String JavaDoc out) throws IOException JavaDoc, SourceException;
87     
88     /**
89      * Create a Source collection.
90      *
91      * @param location the location of the source collection to create.
92      * @return a status code describing the exit status.
93      * @throws IOException
94      * @throws SourceException
95      */

96     public abstract int makeCollection(String JavaDoc location) throws IOException JavaDoc, SourceException;
97     
98     /**
99      * Deletes a Source and all of its descendants.
100      *
101      * @param location the location of the source to delete.
102      * @return a status code describing the exit status.
103      * @throws IOException
104      * @throws SourceException
105      */

106     public abstract int remove(String JavaDoc location) throws IOException JavaDoc, SourceException;
107     
108     /**
109      * Move a Source from one location to the other.
110      *
111      * @param from the source location.
112      * @param to the destination location.
113      * @param recurse whether to move all the source descendents also.
114      * @param overwrite whether to overwrite the destination source if it exists.
115      * @return a status code describing the exit status.
116      * @throws IOException
117      * @throws SourceException
118      */

119     public abstract int move(String JavaDoc from, String JavaDoc to, boolean recurse, boolean overwrite)
120         throws IOException JavaDoc, SourceException;
121     
122     /**
123      * Copy a Souce from one location to the other.
124      *
125      * @param from the source location.
126      * @param to the destination location.
127      * @param recurse whether to move all the source descendents also.
128      * @param overwrite whether to overwrite the destination source if it exists.
129      * @return a status code describing the exit status.
130      * @throws IOException
131      * @throws SourceException
132      */

133     public abstract int copy(String JavaDoc from, String JavaDoc to, boolean recurse, boolean overwrite)
134         throws IOException JavaDoc, SourceException;
135     
136 }
Popular Tags