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.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            @Override
038            public Collection<String> getPropertyNames() {
039                    return _propertyNames;
040            }
041    
042            @Override
043            public String getType() {
044                    return getHandlerType();
045            }
046    
047            @Override
048            protected String getURL(
049                    MDRAction mdrAction, HttpServletRequest request,
050                    HttpServletResponse response) {
051    
052                    UnicodeProperties typeSettingsProperties =
053                            mdrAction.getTypeSettingsProperties();
054    
055                    return GetterUtil.getString(typeSettingsProperties.getProperty("url"));
056            }
057    
058            private static Collection<String> _propertyNames;
059    
060            static {
061                    _propertyNames = new ArrayList<String>(1);
062    
063                    _propertyNames.add("url");
064    
065                    _propertyNames = Collections.unmodifiableCollection(_propertyNames);
066            }
067    
068    }