1
14
15 package com.liferay.portal.sharepoint.methods;
16
17 import com.liferay.portal.sharepoint.Property;
18 import com.liferay.portal.sharepoint.ResponseElement;
19 import com.liferay.portal.sharepoint.SharepointRequest;
20 import com.liferay.portal.sharepoint.SharepointStorage;
21 import com.liferay.portal.sharepoint.Tree;
22 import com.liferay.portlet.documentlibrary.NoSuchFileEntryException;
23
24 import java.util.ArrayList;
25 import java.util.List;
26
27
32 public class GetDocsMetaInfoMethodImpl extends BaseMethodImpl {
33
34 public String getMethodName() {
35 return _METHOD_NAME;
36 }
37
38 public String getRootPath(SharepointRequest sharepointRequest) {
39 String urlList = sharepointRequest.getParameterValue("url_list");
40
41 urlList = urlList.substring(1, urlList.length() - 1);
42
43 int pos = urlList.lastIndexOf("sharepoint/");
44
45 if (pos != -1) {
46 urlList = urlList.substring(pos + 11);
47 }
48
49 return urlList;
50 }
51
52 protected List<ResponseElement> getElements(
53 SharepointRequest sharepointRequest)
54 throws Exception {
55
56 List<ResponseElement> elements = new ArrayList<ResponseElement>();
57
58 SharepointStorage storage = sharepointRequest.getSharepointStorage();
59
60 Tree documentListTree = new Tree();
61
62 try {
63 documentListTree.addChild(
64 storage.getDocumentTree(sharepointRequest));
65 }
66 catch (Exception e1) {
67 if (e1 instanceof NoSuchFileEntryException) {
68 try {
69 documentListTree.addChild(
70 storage.getFolderTree(sharepointRequest));
71 }
72 catch (Exception e2) {
73 }
74 }
75 }
76
77 Property documentProperty = new Property(
78 "document_list", documentListTree);
79
80 elements.add(documentProperty);
81
82 elements.add(new Property("urldirs", new Tree()));
83
84 return elements;
85 }
86
87 private static final String _METHOD_NAME = "getDocsMetaInfo";
88
89 }