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 String getConfigurationErrorMessage() {
063 return null;
064 }
065
066 @Override
067 public abstract String getDescription();
068
069 @Override
070 public String getParameterDescription() {
071 return null;
072 }
073
074 @Override
075 public String[] getParameterNames() {
076 return null;
077 }
078
079 public String[] getParameterValues() {
080 return _paramValues;
081 }
082
083 @Override
084 public String getPath() {
085 return null;
086 }
087
088 @Override
089 public abstract boolean isEnabled();
090
091 @Override
092 public void setParameterValues(String[] values) {
093 _paramValues = values;
094 }
095
096
099 @Override
100 public void validate() throws ConvertException {
101 }
102
103 protected abstract void doConvert() throws Exception;
104
105 private static final Log _log = LogFactoryUtil.getLog(
106 BaseConvertProcess.class);
107
108 private String[] _paramValues = null;
109
110 }