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