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