001
014
015 package com.liferay.portal.convert;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.util.MaintenanceUtil;
020
021 import org.apache.commons.lang.time.StopWatch;
022
023
026 public abstract class ConvertProcess {
027
028 public void convert() throws ConvertException {
029 try {
030 if (getPath() != null) {
031 return;
032 }
033
034 StopWatch stopWatch = new StopWatch();
035
036 stopWatch.start();
037
038 if (_log.isInfoEnabled()) {
039 _log.info("Starting conversion for " + getClass().getName());
040 }
041
042 doConvert();
043
044 if (_log.isInfoEnabled()) {
045 _log.info(
046 "Finished conversion for " + getClass().getName() + " in " +
047 stopWatch.getTime() + " ms");
048 }
049 }
050 catch (Exception e) {
051 throw new ConvertException(e);
052 }
053 finally {
054 setParameterValues(null);
055
056 MaintenanceUtil.cancel();
057 }
058 }
059
060 public abstract String getDescription();
061
062 public String getParameterDescription() {
063 return null;
064 }
065
066 public String[] getParameterNames() {
067 return null;
068 }
069
070 public String[] getParameterValues() {
071 return _paramValues;
072 }
073
074 public String getPath() {
075 return null;
076 }
077
078 public abstract boolean isEnabled();
079
080 public void setParameterValues(String[] values) {
081 _paramValues = values;
082 }
083
084 protected abstract void doConvert() throws Exception;
085
086 private static Log _log = LogFactoryUtil.getLog(ConvertProcess.class);
087
088 private String[] _paramValues = null;
089
090 }