1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.sharepoint.methods;
16  
17  import com.liferay.portal.kernel.util.StringPool;
18  import com.liferay.portal.kernel.util.Validator;
19  import com.liferay.portal.sharepoint.Property;
20  import com.liferay.portal.sharepoint.ResponseElement;
21  import com.liferay.portal.sharepoint.SharepointRequest;
22  
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  /**
27   * <a href="UrlToWebUrlMethodImpl.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Bruno Farache
30   */
31  public class UrlToWebUrlMethodImpl extends BaseMethodImpl {
32  
33      public String getMethodName() {
34          return _METHOD_NAME;
35      }
36  
37      protected List<ResponseElement> getElements(
38          SharepointRequest sharepointRequest) {
39  
40          List<ResponseElement> elements = new ArrayList<ResponseElement>();
41  
42          String url = sharepointRequest.getParameterValue("url");
43  
44          if (Validator.isNotNull(url)) {
45              elements.add(new Property("webUrl", "/sharepoint"));
46  
47              url = url.substring(1);
48  
49              elements.add(new Property("fileUrl", StringPool.BLANK));
50          }
51  
52          return elements;
53      }
54  
55      private static final String _METHOD_NAME = "url to web url";
56  
57  }