1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.sharepoint.methods;
16  
17  import com.liferay.portal.kernel.util.StringPool;
18  import com.liferay.portal.sharepoint.Property;
19  import com.liferay.portal.sharepoint.ResponseElement;
20  import com.liferay.portal.sharepoint.SharepointRequest;
21  import com.liferay.portal.sharepoint.SharepointStorage;
22  
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  /**
27   * <a href="CreateURLDirectoriesMethodImpl.java.html"><b><i>View Source</i></b>
28   * </a>
29   *
30   * @author Bruno Farache
31   */
32  public class CreateURLDirectoriesMethodImpl extends BaseMethodImpl {
33  
34      public String getMethodName() {
35          return _METHOD_NAME;
36      }
37  
38      public String getRootPath(SharepointRequest sharepointRequest) {
39          String urlDirs = sharepointRequest.getParameterValue("urldirs");
40  
41          urlDirs = urlDirs.substring(2, urlDirs.length() - 2);
42  
43          String urls[] = urlDirs.split(StringPool.SEMICOLON);
44  
45          return urls[0].substring(4);
46      }
47  
48      protected List<ResponseElement> getElements(
49              SharepointRequest sharepointRequest)
50          throws Exception {
51  
52          List<ResponseElement> elements = new ArrayList<ResponseElement>();
53  
54          SharepointStorage storage = sharepointRequest.getSharepointStorage();
55  
56          storage.createFolder(sharepointRequest);
57  
58          elements.add(new Property("message", StringPool.BLANK));
59  
60          return elements;
61      }
62  
63      private static final String _METHOD_NAME = "create url-directories";
64  
65  }