001
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.Validator;
020 import com.liferay.portal.sharepoint.Property;
021 import com.liferay.portal.sharepoint.ResponseElement;
022 import com.liferay.portal.sharepoint.SharepointRequest;
023 import com.liferay.portal.sharepoint.SharepointUtil;
024
025 import java.util.ArrayList;
026 import java.util.List;
027
028
031 public class UrlToWebUrlMethodImpl extends BaseMethodImpl {
032
033 @Override
034 public String getMethodName() {
035 return _METHOD_NAME;
036 }
037
038 @Override
039 protected List<ResponseElement> getElements(
040 SharepointRequest sharepointRequest) {
041
042 List<ResponseElement> elements = new ArrayList<ResponseElement>();
043
044 String url = sharepointRequest.getParameterValue("url");
045
046 if (Validator.isNotNull(url)) {
047 if (_log.isInfoEnabled()) {
048 _log.info("Original URL " + url);
049 }
050
051 url = SharepointUtil.stripService(url, false);
052
053 if (_log.isInfoEnabled()) {
054 _log.info("Modified URL " + url);
055 }
056
057 elements.add(new Property("fileUrl", url));
058 elements.add(new Property("webUrl", "/sharepoint"));
059 }
060 else if (_log.isInfoEnabled()) {
061 _log.info("URL is " + url);
062 }
063
064 return elements;
065 }
066
067 private static final String _METHOD_NAME = "url to web url";
068
069 private static Log _log = LogFactoryUtil.getLog(
070 UrlToWebUrlMethodImpl.class);
071
072 }