1 23 package org.infoglue.cms.applications.workflowtool.function; 24 25 import org.apache.log4j.Logger; 26 import org.infoglue.cms.controllers.kernel.impl.simple.ContentController; 27 import org.infoglue.cms.controllers.kernel.impl.simple.RepositoryController; 28 import org.infoglue.cms.entities.management.Repository; 29 30 import com.opensymphony.workflow.WorkflowException; 31 32 35 public class PathContentProvider extends ContentProvider 36 { 37 private final static Logger logger = Logger.getLogger(PathContentProvider.class.getName()); 38 39 42 private static final String CONTENT_PARAMETER_NAME_ARGUMENT = "contentParameterName"; 43 44 47 private static final String CONTENT_VERSION_PARAMETER_NAME_ARGUMENT = "contentVersionParameterName"; 48 49 52 private static final String PATH_ARGUMENT = "path"; 53 54 57 private static final String REPOSITORY_NAME_ARGUMENT = "repository"; 58 59 62 private String repositoryName; 63 64 67 private String path; 68 69 72 private String contentParameterName; 73 74 77 private String contentVersionParameterName; 78 79 82 public PathContentProvider() 83 { 84 super(); 85 } 86 87 90 protected String getContentParameterName() 91 { 92 return contentParameterName; 93 } 94 95 98 protected String getContentVersionParameterName() 99 { 100 return contentVersionParameterName; 101 } 102 103 106 protected void initializeContentVO() throws WorkflowException 107 { 108 try 109 { 110 logger.debug("Using repository=["+ repositoryName + "] path=["+ path + "]"); 111 final Repository repository = RepositoryController.getController().getRepositoryWithName(repositoryName, getDatabase()); 112 if(repository == null) 113 { 114 throwException("No repository with the name [" + repositoryName + "] found."); 115 } 116 setContentVO(ContentController.getContentController().getContentVOWithPath(repository.getId(), path, false, getPrincipal(), getDatabase())); 117 } 118 catch(Exception e) 119 { 120 throwException(e); 121 } 122 } 123 124 130 protected void initialize() throws WorkflowException 131 { 132 super.initialize(); 133 path = getArgument(PATH_ARGUMENT); 134 repositoryName = getArgument(REPOSITORY_NAME_ARGUMENT); 135 contentParameterName = getArgument(CONTENT_PARAMETER_NAME_ARGUMENT, ContentFunction.CONTENT_PARAMETER); 136 contentVersionParameterName = getArgument(CONTENT_VERSION_PARAMETER_NAME_ARGUMENT, ContentFunction.CONTENT_VERSION_PARAMETER); 137 } 138 } 139 | Popular Tags |