001
014
015 package com.liferay.portlet.documentlibrary.util;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.util.StringBundler;
020 import com.liferay.portal.kernel.util.Validator;
021
022 import java.util.LinkedList;
023 import java.util.List;
024 import java.util.Properties;
025
026 import jodd.util.StringPool;
027
028 import org.im4java.core.ConvertCmd;
029
030
033 public class LiferayConvertCmd extends ConvertCmd {
034
035 public static void run(
036 String globalSearchPath, Properties resourceLimitsProperties,
037 List<String> commandArguments)
038 throws Exception {
039
040 setGlobalSearchPath(globalSearchPath);
041
042 LinkedList<String> arguments = new LinkedList<String>();
043
044 arguments.addAll(_instance.getCommand());
045
046 for (Object key : resourceLimitsProperties.keySet()) {
047 String value = (String)resourceLimitsProperties.get(key);
048
049 if (Validator.isNull(value)) {
050 continue;
051 }
052
053 arguments.add("-limit");
054 arguments.add((String)key);
055 arguments.add(value);
056 }
057
058 arguments.addAll(commandArguments);
059
060 if (_log.isInfoEnabled()) {
061 StringBundler sb = new StringBundler(arguments.size() * 2);
062
063 for (String argument : arguments) {
064 sb.append(argument);
065 sb.append(StringPool.SPACE);
066 }
067
068 _log.info("Excecuting command '" + sb.toString() + "'");
069 }
070
071 _instance.run(arguments);
072 }
073
074 private static Log _log = LogFactoryUtil.getLog(LiferayConvertCmd.class);
075
076 private static LiferayConvertCmd _instance = new LiferayConvertCmd();
077
078 }