001    /**
002     * Copyright (c) 2000-2011 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.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    }