001    /**
002     * Copyright (c) 2000-2012 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.sharepoint.methods;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.util.StringPool;
020    import com.liferay.portal.kernel.util.Validator;
021    import com.liferay.portal.sharepoint.Property;
022    import com.liferay.portal.sharepoint.ResponseElement;
023    import com.liferay.portal.sharepoint.SharepointRequest;
024    
025    import java.util.ArrayList;
026    import java.util.List;
027    
028    /**
029     * @author Bruno Farache
030     */
031    public class UrlToWebUrlMethodImpl extends BaseMethodImpl {
032    
033            public String getMethodName() {
034                    return _METHOD_NAME;
035            }
036    
037            @Override
038            protected List<ResponseElement> getElements(
039                    SharepointRequest sharepointRequest) {
040    
041                    List<ResponseElement> elements = new ArrayList<ResponseElement>();
042    
043                    String url = sharepointRequest.getParameterValue("url");
044    
045                    if (_log.isInfoEnabled()) {
046                            _log.info("URL is " + url);
047                    }
048    
049                    if (Validator.isNotNull(url)) {
050                            elements.add(new Property("webUrl", "/sharepoint"));
051    
052                            url = url.substring(1);
053    
054                            elements.add(new Property("fileUrl", StringPool.BLANK));
055                    }
056    
057                    return elements;
058            }
059    
060            private static final String _METHOD_NAME = "url to web url";
061    
062            private static Log _log = LogFactoryUtil.getLog(
063                    UrlToWebUrlMethodImpl.class);
064    
065    }