这是indexloc提供的服务,不要输入任何密码
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,46 @@ public void deleteDocument(String documentId) throws FileNotFoundException {
}
}

@Override
public String moveDocument(String sourceDocumentId, String sourceParentDocumentId, String targetParentDocumentId) throws FileNotFoundException {
File sourceFile = getFileForDocId(sourceDocumentId);
File targetParentFile = getFileForDocId(targetParentDocumentId);
if (!isChildDocument(sourceParentDocumentId, sourceDocumentId)) {
throw new FileNotFoundException("Document with id " + sourceParentDocumentId +
" is not the parent document of " + sourceDocumentId);
}
if (!targetParentFile.isDirectory()) {
throw new FileNotFoundException("Target parent document with id " +
targetParentDocumentId + " is not a directory");
}
File targetFile = new File(targetParentFile, sourceFile.getName());
if (targetFile.exists()) {
throw new FileNotFoundException("Failed to move document with id " +
sourceDocumentId + " : target file " + targetFile.getPath() + " exists");
}
if (!sourceFile.renameTo(targetFile)) {
throw new FileNotFoundException("Failed to move document with id " +
sourceDocumentId + " (whose parent document id is " + sourceParentDocumentId +
") to directory with document id " + targetParentDocumentId);
}
return targetFile.getPath();
}

@Override
public String renameDocument(String documentId, String displayName) throws FileNotFoundException {
File sourceFile = getFileForDocId(documentId);
File targetFile = new File(sourceFile.getParentFile(), displayName);
if (targetFile.exists()) {
throw new FileNotFoundException("Failed to rename document with id " +
documentId + " : target file " + targetFile.getPath() + " exists");
}
if (!sourceFile.renameTo(targetFile)) {
throw new FileNotFoundException("Failed to rename document with id " +
documentId + " to display name " + displayName);
}
return targetFile.getPath();
}

@Override
public String getDocumentType(String documentId) throws FileNotFoundException {
File file = getFileForDocId(documentId);
Expand Down