001    /**
002     * Copyright (c) 2000-2011 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.mobile.device.rulegroup.action.impl;
016    
017    import com.liferay.portal.kernel.util.GetterUtil;
018    import com.liferay.portal.kernel.util.UnicodeProperties;
019    import com.liferay.portlet.mobiledevicerules.model.MDRAction;
020    
021    import java.util.ArrayList;
022    import java.util.Collection;
023    import java.util.Collections;
024    
025    import javax.servlet.http.HttpServletRequest;
026    import javax.servlet.http.HttpServletResponse;
027    
028    /**
029     * @author Edward Han
030     */
031    public class SimpleRedirectActionHandler extends BaseRedirectActionHandler {
032    
033            public static String getHandlerType() {
034                    return SimpleRedirectActionHandler.class.getName();
035            }
036    
037            public Collection<String> getPropertyNames() {
038                    return _propertyNames;
039            }
040    
041            public String getType() {
042                    return getHandlerType();
043            }
044    
045            @Override
046            protected String getURL(
047                    MDRAction mdrAction, HttpServletRequest request,
048                    HttpServletResponse response) {
049    
050                    UnicodeProperties typeSettingsProperties =
051                            mdrAction.getTypeSettingsProperties();
052    
053                    return GetterUtil.getString(
054                            typeSettingsProperties.getProperty("url"));
055            }
056    
057            private static Collection<String> _propertyNames;
058    
059            static {
060                    _propertyNames = new ArrayList<String>(1);
061    
062                    _propertyNames.add("url");
063    
064                    _propertyNames = Collections.unmodifiableCollection(_propertyNames);
065            }
066    
067    }