01: /**
02: *
03: */package generate.utils;
04:
05: import java.io.File;
06:
07: import org.apache.commons.logging.Log;
08: import org.apache.commons.logging.LogFactory;
09: import org.openarchitectureware.workflow.WorkflowContext;
10: import org.openarchitectureware.workflow.issues.Issues;
11: import org.openarchitectureware.workflow.lib.AbstractWorkflowComponent2;
12: import org.openarchitectureware.workflow.monitor.ProgressMonitor;
13:
14: /**
15: * This directory creator is needed for the
16: * protected region detection. The protected
17: * region detection has to access the source
18: * folder to scan for pr before the source
19: * creator works on the folder.
20: *
21: * @author sh
22: */
23: public class DirectoryCreator extends AbstractWorkflowComponent2 {
24:
25: private final Log log = LogFactory.getLog(DirectoryCreator.class);
26:
27: private String directory;
28:
29: public void setDirectory(final String directory) {
30: this .directory = directory;
31: }
32:
33: public void addDirectory(final String directory) {
34: this .directory = directory;
35: }
36:
37: public String getLogMessage() {
38: return "creating directory '" + directory + "'";
39: }
40:
41: @Override
42: protected void checkConfigurationInternal(Issues issues) {
43: if (directory == null || directory.equals("")) {
44: issues.addError("No source directory created !");
45: }
46: }
47:
48: @Override
49: protected void invokeInternal(WorkflowContext model,
50: ProgressMonitor monitor, Issues issues) {
51:
52: File file = new File(directory);
53: if (file.exists() && file.isDirectory())
54: return;
55: file.mkdirs();
56: }
57: }
|