001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    
021    import java.util.LinkedList;
022    import java.util.List;
023    
024    import jodd.util.StringPool;
025    
026    import org.im4java.core.ConvertCmd;
027    import org.im4java.process.ProcessTask;
028    
029    /**
030     * @author Alexander Chow
031     * @author Ivica Cardic
032     */
033    public class LiferayConvertCmd extends ConvertCmd {
034    
035            public ProcessTask getProcessTask(
036                            String globalSearchPath, List<String> resourceLimits,
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                    arguments.addAll(resourceLimits);
046                    arguments.addAll(commandArguments);
047    
048                    if (_log.isInfoEnabled()) {
049                            StringBundler sb = new StringBundler(arguments.size() * 2);
050    
051                            for (String argument : arguments) {
052                                    sb.append(argument);
053                                    sb.append(StringPool.SPACE);
054                            }
055    
056                            _log.info("Excecuting command '" + sb.toString() + "'");
057                    }
058    
059                    return getProcessTask(arguments);
060            }
061    
062            private static Log _log = LogFactoryUtil.getLog(LiferayConvertCmd.class);
063    
064            private static LiferayConvertCmd _instance = new LiferayConvertCmd();
065    
066    }