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 = null;
035
036 if (_log.isInfoEnabled()) {
037 stopWatch = new StopWatch();
038
039 stopWatch.start();
040
041 _log.info("Starting conversion for " + getClass().getName());
042 }
043
044 doConvert();
045
046 if (_log.isInfoEnabled()) {
047 _log.info(
048 "Finished conversion for " + getClass().getName() + " in " +
049 stopWatch.getTime() + " ms");
050 }
051 }
052 catch (Exception e) {
053 throw new ConvertException(e);
054 }
055 finally {
056 setParameterValues(null);
057
058 MaintenanceUtil.cancel();
059 }
060 }
061
062 public abstract String getDescription();
063
064 public String getParameterDescription() {
065 return null;
066 }
067
068 public String[] getParameterNames() {
069 return null;
070 }
071
072 public String[] getParameterValues() {
073 return _paramValues;
074 }
075
076 public String getPath() {
077 return null;
078 }
079
080 public abstract boolean isEnabled();
081
082 public void setParameterValues(String[] values) {
083 _paramValues = values;
084 }
085
086 protected abstract void doConvert() throws Exception;
087
088 private static Log _log = LogFactoryUtil.getLog(ConvertProcess.class);
089
090 private String[] _paramValues = null;
091
092 }