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) throws WorkflowException {
039 return parseDef(jobConf, null);
040 }
041
042 public WorkflowApp parseDef(Configuration jobConf, Configuration configDefault) throws WorkflowException {
043 String appPath = ParamChecker.notEmpty(jobConf.get(OozieClient.APP_PATH), OozieClient.APP_PATH);
044 String user = ParamChecker.notEmpty(jobConf.get(OozieClient.USER_NAME), OozieClient.USER_NAME);
045 String workflowXml = readDefinition(appPath, user, jobConf);
046 return parseDef(workflowXml, jobConf, configDefault);
047 }
048
049 @Override
050 public WorkflowApp parseDef(String wfXml, Configuration jobConf) throws WorkflowException {
051 return parseDef(wfXml, jobConf, null);
052 }
053
054 public WorkflowApp parseDef(String workflowXml, Configuration jobConf, Configuration configDefault)
055 throws WorkflowException {
056 WorkflowLib workflowLib = Services.get().get(WorkflowStoreService.class).getWorkflowLibWithNoDB();
057 return workflowLib.parseDef(workflowXml, jobConf, configDefault);
058 }
059
060 }