@@ 266,58 266,10 @@ public class CephFSDocumentsProvider extends DocumentsProvider {
}
}
- public Cursor queryChildDocuments(String parentDocumentId,
- String[] projection, String sortOrder)
+ private void lstatBuildDocumentRow(String filename, String displayName,
+ String documentId, MatrixCursor result)
throws FileNotFoundException {
- MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_DOC_PROJECTION);
- Log.v(APP_NAME, "queryChildDocuments " + parentDocumentId);
- String filename = parentDocumentId.substring(parentDocumentId.indexOf("/") + 1);
- String[] res = doCephOperation(() -> {
- try {
- return cm.listdir(filename);
- } catch (FileNotFoundException e) {
- Log.e(APP_NAME, "queryChildDocuments " + parentDocumentId + " not found");
- throw new FileNotFoundException(parentDocumentId + " not found");
- }
- });
CephStat cs = new CephStat();
- for (String entry : res) {
- Log.v(APP_NAME, "lstat " + parentDocumentId + " " + entry);
- doCephOperation(() -> {
- try {
- cm.lstat(filename + "/" + entry, cs);
- return null;
- } catch (FileNotFoundException|CephNotDirectoryException e) {
- Log.e(APP_NAME, "lstat: " + filename + "/" + entry + " not found");
- throw new FileNotFoundException(parentDocumentId + "/" + entry + " not found");
- }
- });
- MatrixCursor.RowBuilder row = result.newRow();
- row.add(Document.COLUMN_DOCUMENT_ID, parentDocumentId + "/" + entry);
- row.add(Document.COLUMN_DISPLAY_NAME, entry);
- if (cs.isDir()) {
- row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
- if (!checkPermissions || (getPerm(cs) & PERM_WRITEABLE) == PERM_WRITEABLE) {
- row.add(Document.COLUMN_FLAGS, Document.FLAG_DIR_SUPPORTS_CREATE);
- }
- } else if (cs.isFile() || cs.isSymlink()) {
- row.add(Document.COLUMN_MIME_TYPE, getMime(entry));
- if (!checkPermissions || (getPerm(cs) & PERM_WRITEABLE) == PERM_WRITEABLE) {
- row.add(Document.COLUMN_FLAGS, Document.FLAG_SUPPORTS_WRITE);
- }
- }
- row.add(Document.COLUMN_SIZE, cs.size);
- row.add(Document.COLUMN_LAST_MODIFIED, cs.m_time);
- }
- return result;
- }
-
- public Cursor queryDocument(String documentId, String[] projection)
- throws FileNotFoundException {
- MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_DOC_PROJECTION);
- String filename = documentId.substring(documentId.indexOf("/") + 1);
- CephStat cs = new CephStat();
- Log.v(APP_NAME, "queryDocument " + documentId);
doCephOperation(() -> {
try {
cm.lstat(filename, cs);
@@ 329,7 281,7 @@ public class CephFSDocumentsProvider extends DocumentsProvider {
});
MatrixCursor.RowBuilder row = result.newRow();
row.add(Document.COLUMN_DOCUMENT_ID, documentId);
- row.add(Document.COLUMN_DISPLAY_NAME, filename);
+ row.add(Document.COLUMN_DISPLAY_NAME, displayName);
if (cs.isDir()) {
row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
if (!checkPermissions || (getPerm(cs) & PERM_WRITEABLE) == PERM_WRITEABLE) {
@@ 343,6 295,36 @@ public class CephFSDocumentsProvider extends DocumentsProvider {
}
row.add(Document.COLUMN_SIZE, cs.size);
row.add(Document.COLUMN_LAST_MODIFIED, cs.m_time);
+ }
+
+ public Cursor queryChildDocuments(String parentDocumentId,
+ String[] projection, String sortOrder)
+ throws FileNotFoundException {
+ MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_DOC_PROJECTION);
+ Log.v(APP_NAME, "queryChildDocuments " + parentDocumentId);
+ String filename = parentDocumentId.substring(parentDocumentId.indexOf("/") + 1);
+ String[] res = doCephOperation(() -> {
+ try {
+ return cm.listdir(filename);
+ } catch (FileNotFoundException e) {
+ Log.e(APP_NAME, "queryChildDocuments " + parentDocumentId + " not found");
+ throw new FileNotFoundException(parentDocumentId + " not found");
+ }
+ });
+ for (String entry : res) {
+ lstatBuildDocumentRow(filename + "/" + entry, entry,
+ parentDocumentId + "/" + entry, result);
+ }
+ return result;
+ }
+
+ public Cursor queryDocument(String documentId, String[] projection)
+ throws FileNotFoundException {
+ Log.v(APP_NAME, "queryDocument " + documentId);
+ MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_DOC_PROJECTION);
+ lstatBuildDocumentRow(documentId.substring(documentId.indexOf("/") + 1),
+ documentId.substring(documentId.lastIndexOf("/") + 1),
+ documentId, result);
return result;
}