001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.components.repository;
018:
019: import java.io.IOException;
020:
021: import org.apache.excalibur.source.SourceException;
022:
023: /**
024: * A stateless utility service intended to be used by flowscripts to help
025: * them with persistent operations on sources.
026: *
027: * <p>
028: * Each operation returns a status code that is based on RFC 2518 (WebDAV).
029: * </p>
030: *
031: * @version $Id: SourceRepository.java 433543 2006-08-22 06:22:54Z crossley $
032: */
033: public interface SourceRepository {
034:
035: public static final String ROLE = SourceRepository.class.getName();
036:
037: /**
038: * Status OK (<b>200</b>).
039: */
040: public static final int STATUS_OK = 200;
041:
042: /**
043: * Status CREATED (<b>201</b>).
044: */
045: public static final int STATUS_CREATED = 201;
046:
047: /**
048: * Status NO_CONTENT (<b>204</b>).
049: */
050: public static final int STATUS_NO_CONTENT = 204;
051:
052: /**
053: * Status FORBIDDEN (<b>403</b>).
054: */
055: public static final int STATUS_FORBIDDEN = 403;
056:
057: /**
058: * Status NOT_FOUND (<b>404</b>).
059: */
060: public static final int STATUS_NOT_FOUND = 404;
061:
062: /**
063: * Status NOT_ALLOWED (<b>405</b>).
064: */
065: public static final int STATUS_NOT_ALLOWED = 405;
066:
067: /**
068: * Status CONFLICT (<b>409</b>).
069: */
070: public static final int STATUS_CONFLICT = 409;
071:
072: /**
073: * Status PRECONDITION_FAILED (<b>412</b>)
074: */
075: public static final int STATUS_PRECONDITION_FAILED = 412;
076:
077: /**
078: * Saves a Source by either creating a new one or overwriting the previous one.
079: *
080: * @param in the Source location to read from.
081: * @param out the Source location to write to.
082: * @return a status code describing the exit status.
083: * @throws IOException
084: * @throws SourceException
085: */
086: public abstract int save(String in, String out) throws IOException,
087: SourceException;
088:
089: /**
090: * Create a Source collection.
091: *
092: * @param location the location of the source collection to create.
093: * @return a status code describing the exit status.
094: * @throws IOException
095: * @throws SourceException
096: */
097: public abstract int makeCollection(String location)
098: throws IOException, SourceException;
099:
100: /**
101: * Deletes a Source and all of its descendants.
102: *
103: * @param location the location of the source to delete.
104: * @return a status code describing the exit status.
105: * @throws IOException
106: * @throws SourceException
107: */
108: public abstract int remove(String location) throws IOException,
109: SourceException;
110:
111: /**
112: * Move a Source from one location to the other.
113: *
114: * @param from the source location.
115: * @param to the destination location.
116: * @param recurse whether to move all the source descendents also.
117: * @param overwrite whether to overwrite the destination source if it exists.
118: * @return a status code describing the exit status.
119: * @throws IOException
120: * @throws SourceException
121: */
122: public abstract int move(String from, String to, boolean recurse,
123: boolean overwrite) throws IOException, SourceException;
124:
125: /**
126: * Copy a Souce from one location to the other.
127: *
128: * @param from the source location.
129: * @param to the destination location.
130: * @param recurse whether to move all the source descendents also.
131: * @param overwrite whether to overwrite the destination source if it exists.
132: * @return a status code describing the exit status.
133: * @throws IOException
134: * @throws SourceException
135: */
136: public abstract int copy(String from, String to, boolean recurse,
137: boolean overwrite) throws IOException, SourceException;
138:
139: }
|