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    import com.liferay.portal.kernel.util.StringPool;
021    
022    import java.util.LinkedList;
023    import java.util.List;
024    
025    import org.im4java.core.IdentifyCmd;
026    import org.im4java.process.ProcessTask;
027    
028    /**
029     * @author Alexander Chow
030     * @author Ivica Cardic
031     */
032    public class LiferayIdentifyCmd extends IdentifyCmd {
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(LiferayIdentifyCmd.class);
062    
063            private static LiferayIdentifyCmd _instance = new LiferayIdentifyCmd();
064    
065    }