public override void Solve(
IFileSystemInfo localFile,
IObjectId remoteId,
ContentChangeType localContent = ContentChangeType.NONE,
ContentChangeType remoteContent = ContentChangeType.NONE)
{
// Move Remote Object
var remoteObject = remoteId as IFileableCmisObject;
var mappedObject = this.Storage.GetObjectByRemoteId(remoteId.Id);
if (mappedObject.LastChangeToken != (remoteId as ICmisObject).ChangeToken) {
throw new ArgumentException("The remote change token is different to the last synchronization");
}
var targetPath = localFile is IDirectoryInfo ? (localFile as IDirectoryInfo).Parent : (localFile as IFileInfo).Directory;
var targetId = this.Storage.GetObjectByLocalPath(targetPath).RemoteObjectId;
try {
if (mappedObject.ParentId != targetId) {
var src = this.Session.GetObject(mappedObject.ParentId);
var target = this.Session.GetObject(targetId);
OperationsLogger.Info(string.Format("Moving remote object {2} from folder {0} to folder {1}", src.Name, target.Name, remoteId.Id));
remoteObject = remoteObject.Move(src, target);
}
if (localFile.Name != remoteObject.Name) {
try {
remoteObject.Rename(localFile.Name, true);
} catch (CmisConstraintException e) {
if (!Utils.IsValidISO885915(localFile.Name)) {
OperationsLogger.Warn(string.Format("Server denied the rename of {0} to {1}, possibly because it contains UTF-8 charactes", remoteObject.Name, localFile.Name));
throw new InteractionNeededException(string.Format("Server denied renaming of {0}", remoteObject.Name), e) {
Title = string.Format("Server denied renaming of {0}", remoteObject.Name),
Description = string.Format("Server denied the rename of {0} to {1}, possibly because it contains UTF-8 charactes", remoteObject.Name, localFile.Name)
};
}
throw;
}
}
} catch (CmisPermissionDeniedException) {
OperationsLogger.Info(string.Format("Moving remote object failed {0}: Permission Denied", localFile.FullName));
return;
}
if (this.ServerCanModifyDateTimes) {
if (mappedObject.LastLocalWriteTimeUtc != localFile.LastWriteTimeUtc) {
remoteObject.UpdateLastWriteTimeUtc(localFile.LastWriteTimeUtc);
}
}
bool isContentChanged = localFile is IFileInfo ? (localFile as IFileInfo).IsContentChangedTo(mappedObject) : false;
mappedObject.ParentId = targetId;
mappedObject.LastChangeToken = remoteObject.ChangeToken;
mappedObject.LastRemoteWriteTimeUtc = remoteObject.LastModificationDate;
mappedObject.Name = remoteObject.Name;
this.Storage.SaveMappedObject(mappedObject);
if (isContentChanged) {
throw new ArgumentException("Local file content is also changed => force crawl sync.");
}
}
}