001 package org.apache.oozie.executor.jpa; 002 003 import javax.persistence.EntityManager; 004 005 import org.apache.oozie.CoordinatorActionBean; 006 import org.apache.oozie.ErrorCode; 007 import org.apache.oozie.command.CommandException; 008 import org.apache.oozie.util.ParamChecker; 009 010 /** 011 * Update the CoordinatorAction into a Bean and persist it. 012 */ 013 public class CoordActionRemoveJPAExecutor implements JPAExecutor<Void> { 014 015 // private CoordinatorActionBean coordAction = null; 016 private String coordActionId = null; 017 018 /** 019 * This constructs the object to Update the CoordinatorAction into a Bean and persist it. 020 * 021 * @param coordAction 022 */ 023 public CoordActionRemoveJPAExecutor(String coordActionId) { 024 ParamChecker.notNull(coordActionId, "coordActionId"); 025 this.coordActionId = coordActionId; 026 } 027 028 /* (non-Javadoc) 029 * @see org.apache.oozie.executor.jpa.JPAExecutor#execute(javax.persistence.EntityManager) 030 */ 031 @Override 032 public Void execute(EntityManager em) throws JPAExecutorException { 033 try { 034 CoordinatorActionBean action = em.find(CoordinatorActionBean.class, coordActionId); 035 if (action != null) { 036 em.remove(action); 037 } 038 else { 039 throw new CommandException(ErrorCode.E0605, coordActionId); 040 } 041 042 return null; 043 } 044 catch (Exception e) { 045 throw new JPAExecutorException(ErrorCode.E0603, e); 046 } 047 } 048 049 /* (non-Javadoc) 050 * @see org.apache.oozie.executor.jpa.JPAExecutor#getName() 051 */ 052 @Override 053 public String getName() { 054 return "CoordActionRemoveJPAExecutor"; 055 } 056 }