Package org.wso2.carbon.humantask.configuration

Source Code of org.wso2.carbon.humantask.configuration.HumanTaskServerConfiguration

/*
* Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* 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 org.wso2.carbon.humantask.configuration;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.xmlbeans.XmlException;
import org.wso2.carbon.humantask.server.config.HumanTaskServerConfigDocument;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class HumanTaskServerConfiguration {
    private static final Log log = LogFactory.getLog(HumanTaskServerConfiguration.class);


    /**
     * Create Human Task Server Configuration from a configuration file. If error occurred while parsing configuration
     * file, default configuration will be created.
     *
     * @param htServerConfig XMLBeans object of human task server configuration file
     */
    public HumanTaskServerConfiguration(File htServerConfig) {
        HumanTaskServerConfigDocument htServerConfigDocument = readConfigurationFromFile(htServerConfig);

        if (htServerConfigDocument == null) {
            initDefaultConfiguration();
        }

        initConfigurationFromFile(htServerConfigDocument);


    }


    private HumanTaskServerConfigDocument readConfigurationFromFile(File htServerConfiguration) {
        try {
            return HumanTaskServerConfigDocument.Factory.parse(new FileInputStream(htServerConfiguration));
        } catch (XmlException e) {
            log.error("Error parsing human task server configuration.", e);
        } catch (FileNotFoundException e) {
            log.error("Cannot find the human task server configuration in specified location "
                    + htServerConfiguration.getPath() + " .", e);
        } catch (IOException e) {
            log.error("Error reading human task server configuration file" + htServerConfiguration.getPath() + " .");
        }

        return null;
    }

    private void initDefaultConfiguration() {

    }

    private void initConfigurationFromFile(HumanTaskServerConfigDocument htServerConfigDoc){

    }


}
TOP

Related Classes of org.wso2.carbon.humantask.configuration.HumanTaskServerConfiguration

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.