01: /*
02: * Copyright 1999-2002,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 nl.hippo.slide.store.impl;
17:
18: import java.io.File;
19: import java.util.Hashtable;
20:
21: import org.apache.slide.common.Domain;
22: import org.apache.slide.common.ServiceParameterErrorException;
23: import org.apache.slide.common.ServiceParameterMissingException;
24: import org.apache.slide.store.txfile.TxFileContentStore;
25:
26: /**
27: * Specialized version of the TxFileContentStore from the
28: * Jakarta Slide project, which respects the context path and work directory.
29: */
30: public class ContextTxFileContentStore extends TxFileContentStore {
31:
32: public ContextTxFileContentStore() {
33: }
34:
35: public void setParameters(Hashtable parameters)
36: throws ServiceParameterErrorException,
37: ServiceParameterMissingException {
38:
39: // resolve the rootpath parameter relative to the webapp context path
40: String rootpath = (String) parameters.get(STORE_DIR_PARAMETER);
41: rootpath = new File(Domain.getParameter("contextpath"),
42: rootpath).toString();
43: parameters.put(STORE_DIR_PARAMETER, rootpath);
44:
45: // resolve the workpath parameter relative to the cocoon work directory
46: String workpath = (String) parameters.get(WORK_DIR_PARAMETER);
47: workpath = new File(Domain.getParameter("workdir"), workpath)
48: .toString();
49: parameters.put(WORK_DIR_PARAMETER, workpath);
50:
51: super.setParameters(parameters);
52: }
53:
54: }
|