1
14
15 package com.liferay.portal.convert;
16
17 import com.liferay.portal.kernel.log.Log;
18 import com.liferay.portal.kernel.log.LogFactoryUtil;
19 import com.liferay.portal.util.MaintenanceUtil;
20
21 import org.apache.commons.lang.time.StopWatch;
22
23
28 public abstract class ConvertProcess {
29
30 public void convert() throws ConvertException {
31 try {
32 if (getPath() != null) {
33 return;
34 }
35
36 StopWatch stopWatch = null;
37
38 if (_log.isInfoEnabled()) {
39 stopWatch = new StopWatch();
40
41 stopWatch.start();
42
43 _log.info("Starting conversion for " + getClass().getName());
44 }
45
46 doConvert();
47
48 if (_log.isInfoEnabled()) {
49 _log.info(
50 "Finished conversion for " + getClass().getName() + " in " +
51 stopWatch.getTime() + " ms");
52 }
53 }
54 catch (Exception e) {
55 throw new ConvertException(e);
56 }
57 finally {
58 setParameterValues(null);
59
60 MaintenanceUtil.cancel();
61 }
62 }
63
64 public abstract String getDescription();
65
66 public String getParameterDescription() {
67 return null;
68 }
69
70 public String[] getParameterNames() {
71 return null;
72 }
73
74 public String[] getParameterValues() {
75 return _paramValues;
76 }
77
78 public String getPath() {
79 return null;
80 }
81
82 public abstract boolean isEnabled();
83
84 public void setParameterValues(String[] values) {
85 _paramValues = values;
86 }
87
88 protected abstract void doConvert() throws Exception;
89
90 private static Log _log = LogFactoryUtil.getLog(ConvertProcess.class);
91
92 private String[] _paramValues = null;
93
94 }