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
019package org.apache.oozie.command.wf;
020
021
022import org.apache.oozie.ErrorCode;
023import org.apache.oozie.WorkflowActionBean;
024import org.apache.oozie.command.CommandException;
025import org.apache.oozie.executor.jpa.JPAExecutorException;
026import org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor;
027import org.apache.oozie.util.ParamChecker;
028import org.apache.oozie.service.JPAService;
029import org.apache.oozie.service.Services;
030
031public class WorkflowActionInfoXCommand extends WorkflowXCommand<WorkflowActionBean> {
032    private String id;
033
034    public WorkflowActionInfoXCommand(String id) {
035        super("action.info", "action.info", 1);
036        this.id = ParamChecker.notEmpty(id, "id");
037        LOG.debug("Command for workflow action " + id);
038    }
039
040    @Override
041    protected WorkflowActionBean execute() throws CommandException {
042        JPAService jpaService = Services.get().get(JPAService.class);
043        if (jpaService != null) {
044            WorkflowActionBean action;
045            try {
046                action = jpaService.execute(new WorkflowActionGetJPAExecutor(this.id));
047            }
048            catch (JPAExecutorException ex) {
049                throw new CommandException(ex);
050            }
051            return action;
052        }
053        else {
054            LOG.error(ErrorCode.E0610);
055            return null;
056        }
057    }
058
059    /* (non-Javadoc)
060     * @see org.apache.oozie.command.XCommand#getEntityKey()
061     */
062    @Override
063    public String getEntityKey() {
064        return null;
065    }
066
067    /* (non-Javadoc)
068     * @see org.apache.oozie.command.XCommand#loadState()
069     */
070    @Override
071    protected void loadState() {
072
073    }
074
075    /* (non-Javadoc)
076     * @see org.apache.oozie.command.XCommand#verifyPrecondition()
077     */
078    @Override
079    protected void verifyPrecondition() throws CommandException {
080
081    }
082
083    @Override
084    protected boolean isLockRequired() {
085        return false;
086    }
087
088}