use of org.nuxeo.drive.adapter.RootlessItemException in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveCanMove method run.
@OperationMethod
public Blob run() throws IOException {
boolean canMove = false;
try {
FileSystemItemManager fileSystemItemManager = Framework.getService(FileSystemItemManager.class);
canMove = fileSystemItemManager.canMove(srcId, destId, ctx.getPrincipal());
} catch (RootlessItemException e) {
// active sync root: just return false in that case.
if (log.isDebugEnabled()) {
log.debug(String.format("Cannot move %s to %s: %s", srcId, destId, e.getMessage()), e);
}
}
return Blobs.createJSONBlobFromValue(canMove);
}
use of org.nuxeo.drive.adapter.RootlessItemException 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);
}
Aggregations