1
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 import com.liferay.portal.sharepoint.SharepointUtil;
23 import com.liferay.portal.sharepoint.Tree;
24
25 import java.util.ArrayList;
26 import java.util.List;
27
28
33 public class MoveDocumentMethodImpl extends BaseMethodImpl {
34
35 public String getMethodName() {
36 return _METHOD_NAME;
37 }
38
39 public String getRootPath(SharepointRequest sharepointRequest) {
40 return sharepointRequest.getParameterValue("oldUrl");
41 }
42
43 protected List<ResponseElement> getElements(
44 SharepointRequest sharepointRequest)
45 throws Exception {
46
47 List<ResponseElement> elements = new ArrayList<ResponseElement>();
48
49 String oldUrl = sharepointRequest.getParameterValue("oldUrl");
50
51 oldUrl = SharepointUtil.replaceBackSlashes(oldUrl);
52
53 String newUrl = sharepointRequest.getParameterValue("newUrl");
54
55 newUrl = SharepointUtil.replaceBackSlashes(oldUrl);
56
57 SharepointStorage storage = sharepointRequest.getSharepointStorage();
58
59 Tree[] results = storage.moveDocument(sharepointRequest);
60
61 elements.add(new Property("message", StringPool.BLANK));
62 elements.add(new Property("oldUrl", oldUrl));
63 elements.add(new Property("newUrl", newUrl));
64
65 Property documentListProperty = new Property(
66 "document_list", new Tree());
67
68 elements.add(documentListProperty);
69
70 elements.add(new Property("moved_docs", results[0]));
71 elements.add(new Property("moved_dirs", results[1]));
72
73 return elements;
74 }
75
76 private static final String _METHOD_NAME = "move document";
77
78 }