001
014
015 package com.liferay.portal.sharepoint.methods;
016
017 import com.liferay.portal.kernel.util.StringPool;
018 import com.liferay.portal.sharepoint.Property;
019 import com.liferay.portal.sharepoint.ResponseElement;
020 import com.liferay.portal.sharepoint.SharepointRequest;
021 import com.liferay.portal.sharepoint.SharepointStorage;
022 import com.liferay.portal.sharepoint.SharepointUtil;
023 import com.liferay.portal.sharepoint.Tree;
024
025 import java.util.ArrayList;
026 import java.util.List;
027
028
031 public class MoveDocumentMethodImpl extends BaseMethodImpl {
032
033 @Override
034 public String getMethodName() {
035 return _METHOD_NAME;
036 }
037
038 @Override
039 public String getRootPath(SharepointRequest sharepointRequest) {
040 return sharepointRequest.getParameterValue("oldUrl");
041 }
042
043 @Override
044 protected List<ResponseElement> getElements(
045 SharepointRequest sharepointRequest)
046 throws Exception {
047
048 List<ResponseElement> elements = new ArrayList<ResponseElement>();
049
050 String oldUrl = sharepointRequest.getParameterValue("oldUrl");
051
052 oldUrl = SharepointUtil.replaceBackSlashes(oldUrl);
053
054 String newUrl = sharepointRequest.getParameterValue("newUrl");
055
056 newUrl = SharepointUtil.replaceBackSlashes(oldUrl);
057
058 SharepointStorage storage = sharepointRequest.getSharepointStorage();
059
060 Tree[] results = storage.moveDocument(sharepointRequest);
061
062 elements.add(new Property("message", StringPool.BLANK));
063 elements.add(new Property("oldUrl", oldUrl));
064 elements.add(new Property("newUrl", newUrl));
065
066 Property documentListProperty = new Property(
067 "document_list", new Tree());
068
069 elements.add(documentListProperty);
070
071 elements.add(new Property("moved_docs", results[0]));
072 elements.add(new Property("moved_dirs", results[1]));
073
074 return elements;
075 }
076
077 private static final String _METHOD_NAME = "move document";
078
079 }