ContextTxFileContentStore.java :  » Content-Management-System » hippo » nl » hippo » slide » store » impl » Java Open Source

Java Open Source » Content Management System » hippo 
hippo » nl » hippo » slide » store » impl » ContextTxFileContentStore.java
/*
 * Copyright 1999-2002,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.hippo.slide.store.impl;

import java.io.File;
import java.util.Hashtable;

import org.apache.slide.common.Domain;
import org.apache.slide.common.ServiceParameterErrorException;
import org.apache.slide.common.ServiceParameterMissingException;
import org.apache.slide.store.txfile.TxFileContentStore;

/**
 * Specialized version of the TxFileContentStore from the
 * Jakarta Slide project, which respects the context path and work directory.
 */
public class ContextTxFileContentStore extends TxFileContentStore {
    
    public ContextTxFileContentStore() {
    }
    
    public void setParameters(Hashtable parameters)
        throws ServiceParameterErrorException, ServiceParameterMissingException {
        
        // resolve the rootpath parameter relative to the webapp context path
        String rootpath = (String) parameters.get(STORE_DIR_PARAMETER);
        rootpath = new File(Domain.getParameter("contextpath"),rootpath).toString();
        parameters.put(STORE_DIR_PARAMETER,rootpath);
        
        // resolve the workpath parameter relative to the cocoon work directory
        String workpath = (String) parameters.get(WORK_DIR_PARAMETER);
        workpath = new File(Domain.getParameter("workdir"),workpath).toString();
        parameters.put(WORK_DIR_PARAMETER,workpath);
        
        super.setParameters(parameters);
    }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.