1 23 package org.infoglue.cms.applications.workflowtool.function.email; 24 25 import org.apache.log4j.Logger; 26 import org.infoglue.cms.applications.workflowtool.function.ContentFunction; 27 import org.infoglue.cms.applications.workflowtool.function.defaultvalue.StringPopulator; 28 import org.infoglue.cms.controllers.kernel.impl.simple.ContentVersionController; 29 import org.infoglue.cms.entities.content.ContentVersionVO; 30 31 import com.opensymphony.workflow.WorkflowException; 32 33 36 public class ContentVersionAddressProvider extends AddressProvider 37 { 38 private final static Logger logger = Logger.getLogger(ContentVersionAddressProvider.class.getName()); 39 40 43 private static final String ATTRIBUTE_ARGUMENT = "attribute"; 44 45 48 private String attributeName; 49 50 53 private ContentVersionVO contentVersionVO; 54 55 58 public ContentVersionAddressProvider() 59 { 60 super(); 61 } 62 63 67 protected void populate() throws WorkflowException 68 { 69 logger.debug("Creating email from the [" + attributeName + "] attribute."); 70 addRecipient(getAttribute()); 71 } 72 73 76 private String getAttribute() throws WorkflowException 77 { 78 String value = ""; 79 try 80 { 81 value = ContentVersionController.getContentVersionController().getAttributeValue(contentVersionVO, attributeName, false); 82 } 83 catch(Exception e) 84 { 85 throwException(e); 86 } 87 return value; 88 } 89 90 96 protected void initialize() throws WorkflowException 97 { 98 super.initialize(); 99 attributeName = getArgument(ATTRIBUTE_ARGUMENT); 100 contentVersionVO = (ContentVersionVO) getParameter(ContentFunction.CONTENT_VERSION_PARAMETER); 101 } 102 } 103 | Popular Tags |