001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     * 
010     *      http://www.apache.org/licenses/LICENSE-2.0
011     * 
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    package org.apache.oozie.service;
019    
020    import org.apache.hadoop.conf.Configuration;
021    import org.apache.oozie.client.OozieClient;
022    import org.apache.oozie.workflow.WorkflowApp;
023    import org.apache.oozie.workflow.WorkflowException;
024    import org.apache.oozie.workflow.WorkflowLib;
025    import org.apache.oozie.util.ParamChecker;
026    
027    /**
028     * Service that provides workflow application definition reading, parsing and creating proto configuration.
029     */
030    public class LiteWorkflowAppService extends WorkflowAppService {
031        /**
032         * Parse workflow definition.
033         *
034         * @param jobConf workflow job configuration.
035         * @param authToken authorization token.
036         * @return workflow application.
037         */
038        public WorkflowApp parseDef(Configuration jobConf, String authToken) throws WorkflowException {
039            String appPath = ParamChecker.notEmpty(jobConf.get(OozieClient.APP_PATH), OozieClient.APP_PATH);
040            String user = ParamChecker.notEmpty(jobConf.get(OozieClient.USER_NAME), OozieClient.USER_NAME);
041            String workflowXml = readDefinition(appPath, user, authToken, jobConf);
042            return parseDef(workflowXml, jobConf);
043        }
044    
045        public WorkflowApp parseDef(String workflowXml, Configuration jobConf) throws WorkflowException {
046            WorkflowLib workflowLib = Services.get().get(WorkflowStoreService.class).getWorkflowLibWithNoDB();
047            return workflowLib.parseDef(workflowXml, jobConf);
048        }
049    }