001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.image;
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.StringPool;
021    
022    import java.util.LinkedList;
023    import java.util.List;
024    
025    import org.im4java.core.ConvertCmd;
026    import org.im4java.process.ProcessTask;
027    
028    /**
029     * @author Alexander Chow
030     * @author Ivica Cardic
031     */
032    public class LiferayConvertCmd extends ConvertCmd {
033    
034            public ProcessTask getProcessTask(
035                            String globalSearchPath, List<String> resourceLimits,
036                            List<String> commandArguments)
037                    throws Exception {
038    
039                    setGlobalSearchPath(globalSearchPath);
040    
041                    LinkedList<String> arguments = new LinkedList<String>();
042    
043                    arguments.addAll(_instance.getCommand());
044                    arguments.addAll(resourceLimits);
045                    arguments.addAll(commandArguments);
046    
047                    if (_log.isInfoEnabled()) {
048                            StringBundler sb = new StringBundler(arguments.size() * 2);
049    
050                            for (String argument : arguments) {
051                                    sb.append(argument);
052                                    sb.append(StringPool.SPACE);
053                            }
054    
055                            _log.info("Excecuting command '" + sb.toString() + "'");
056                    }
057    
058                    return getProcessTask(arguments);
059            }
060    
061            private static Log _log = LogFactoryUtil.getLog(LiferayConvertCmd.class);
062    
063            private static LiferayConvertCmd _instance = new LiferayConvertCmd();
064    
065    }