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 public String getMethodName() {
034 return _METHOD_NAME;
035 }
036
037 @Override
038 public String getRootPath(SharepointRequest sharepointRequest) {
039 return sharepointRequest.getParameterValue("oldUrl");
040 }
041
042 @Override
043 protected List<ResponseElement> getElements(
044 SharepointRequest sharepointRequest)
045 throws Exception {
046
047 List<ResponseElement> elements = new ArrayList<ResponseElement>();
048
049 String oldUrl = sharepointRequest.getParameterValue("oldUrl");
050
051 oldUrl = SharepointUtil.replaceBackSlashes(oldUrl);
052
053 String newUrl = sharepointRequest.getParameterValue("newUrl");
054
055 newUrl = SharepointUtil.replaceBackSlashes(oldUrl);
056
057 SharepointStorage storage = sharepointRequest.getSharepointStorage();
058
059 Tree[] results = storage.moveDocument(sharepointRequest);
060
061 elements.add(new Property("message", StringPool.BLANK));
062 elements.add(new Property("oldUrl", oldUrl));
063 elements.add(new Property("newUrl", newUrl));
064
065 Property documentListProperty = new Property(
066 "document_list", new Tree());
067
068 elements.add(documentListProperty);
069
070 elements.add(new Property("moved_docs", results[0]));
071 elements.add(new Property("moved_dirs", results[1]));
072
073 return elements;
074 }
075
076 private static final String _METHOD_NAME = "move document";
077
078 }