use of org.nuxeo.drive.adapter.FileSystemItem in project nuxeo-drive-server by nuxeo.
the class AuditChangeFinder method getFileSystemItemChange.
protected FileSystemItemChange getFileSystemItemChange(CoreSession session, DocumentRef docRef, LogEntry entry, String expectedFileSystemItemId) {
DocumentModel doc = session.getDocument(docRef);
// TODO: check the facet, last root change and list of roots
// to have a special handling for the roots.
FileSystemItem fsItem = null;
try {
// NXP-19442: Avoid useless and costly call to DocumentModel#getLockInfo
fsItem = Framework.getService(FileSystemItemAdapterService.class).getFileSystemItem(doc, false, false, false);
} catch (RootlessItemException e) {
// be adapted as a FileSystemItem: nothing to do.
if (log.isDebugEnabled()) {
log.debug(String.format("RootlessItemException thrown while trying to adapt document %s (%s) as a FileSystemItem.", entry.getDocPath(), docRef));
}
}
if (fsItem == null) {
if (log.isDebugEnabled()) {
log.debug(String.format("Document %s (%s) is not adaptable as a FileSystemItem, returning null.", entry.getDocPath(), docRef));
}
return null;
}
if (expectedFileSystemItemId != null && !fsItem.getId().endsWith(AbstractFileSystemItem.FILE_SYSTEM_ITEM_ID_SEPARATOR + expectedFileSystemItemId)) {
if (log.isDebugEnabled()) {
log.debug(String.format("Id %s of FileSystemItem adapted from document %s (%s) doesn't match expected FileSystemItem id %s, returning null.", fsItem.getId(), entry.getDocPath(), docRef, expectedFileSystemItemId));
}
return null;
}
if (log.isDebugEnabled()) {
log.debug(String.format("Document %s (%s) is adaptable as a FileSystemItem, providing it to the FileSystemItemChange entry.", entry.getDocPath(), docRef));
}
// guarantee when facing long transactions.
return new FileSystemItemChangeImpl(entry.getEventId(), entry.getEventDate().getTime(), entry.getRepositoryId(), entry.getDocUUID(), fsItem);
}
use of org.nuxeo.drive.adapter.FileSystemItem in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveGetFileSystemItem method run.
@OperationMethod
public Blob run() throws IOException {
FileSystemItemManager fileSystemItemManager = Framework.getService(FileSystemItemManager.class);
FileSystemItem fsItem;
if (parentId == null) {
fsItem = fileSystemItemManager.getFileSystemItemById(id, ctx.getPrincipal());
} else {
fsItem = fileSystemItemManager.getFileSystemItemById(id, parentId, ctx.getPrincipal());
}
return Blobs.createJSONBlobFromValue(fsItem);
}
use of org.nuxeo.drive.adapter.FileSystemItem in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveGetTopLevelChildren method run.
@OperationMethod
public Blob run() throws IOException {
FileSystemItemManager fileSystemItemManager = Framework.getService(FileSystemItemManager.class);
List<FileSystemItem> children = fileSystemItemManager.getTopLevelChildren(ctx.getPrincipal());
return Blobs.createJSONBlobFromValue(children);
}
Aggregations