001 /** 002 * Copyright (c) 2010 Yahoo! Inc. All rights reserved. 003 * Licensed under the Apache License, Version 2.0 (the "License"); 004 * you may not use this file except in compliance with the License. 005 * You may obtain a copy of the License at 006 * 007 * http://www.apache.org/licenses/LICENSE-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, software 010 * distributed under the License is distributed on an "AS IS" BASIS, 011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 * See the License for the specific language governing permissions and 013 * limitations under the License. See accompanying LICENSE file. 014 */ 015 package org.apache.oozie.command.wf; 016 017 018 import org.apache.oozie.ErrorCode; 019 import org.apache.oozie.WorkflowActionBean; 020 import org.apache.oozie.command.CommandException; 021 import org.apache.oozie.executor.jpa.JPAExecutorException; 022 import org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor; 023 import org.apache.oozie.util.ParamChecker; 024 import org.apache.oozie.service.JPAService; 025 import org.apache.oozie.service.Services; 026 027 public class WorkflowActionInfoXCommand extends WorkflowXCommand<WorkflowActionBean> { 028 private String id; 029 030 public WorkflowActionInfoXCommand(String id) { 031 super("action.info", "action.info", 1); 032 this.id = ParamChecker.notEmpty(id, "id"); 033 LOG.debug("Command for workflow action " + id); 034 } 035 036 @Override 037 protected WorkflowActionBean execute() throws CommandException { 038 JPAService jpaService = Services.get().get(JPAService.class); 039 if (jpaService != null) { 040 WorkflowActionBean action; 041 try { 042 action = jpaService.execute(new WorkflowActionGetJPAExecutor(this.id)); 043 } 044 catch (JPAExecutorException ex) { 045 throw new CommandException(ex); 046 } 047 return action; 048 } 049 else { 050 LOG.error(ErrorCode.E0610); 051 return null; 052 } 053 } 054 055 /* (non-Javadoc) 056 * @see org.apache.oozie.command.XCommand#getEntityKey() 057 */ 058 @Override 059 protected String getEntityKey() { 060 return null; 061 } 062 063 /* (non-Javadoc) 064 * @see org.apache.oozie.command.XCommand#loadState() 065 */ 066 @Override 067 protected void loadState() { 068 069 } 070 071 /* (non-Javadoc) 072 * @see org.apache.oozie.command.XCommand#verifyPrecondition() 073 */ 074 @Override 075 protected void verifyPrecondition() throws CommandException { 076 077 } 078 079 @Override 080 protected boolean isLockRequired() { 081 return false; 082 } 083 084 }