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