ch.cyberduck.core.Local.setBookmark()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中ch.cyberduck.core.Local.setBookmark()方法的一些代码示例,展示了Local.setBookmark()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Local.setBookmark()方法的具体详情如下:
包路径:ch.cyberduck.core.Local
类名称:Local
方法名:setBookmark

Local.setBookmark介绍

暂无

代码示例

代码示例来源:origin: iterate-ch/cyberduck

public Local withBookmark(final String data) {
  this.setBookmark(data);
  return this;
}

代码示例来源:origin: iterate-ch/cyberduck

public <T> Local deserialize(T serialized) {
    final Deserializer dict = deserializer.create(serialized);
    final String path = dict.stringForKey("Path");
    if(StringUtils.isBlank(path)) {
      return null;
    }
    final Local file = LocalFactory.get(path);
    if(StringUtils.isNotBlank(dict.stringForKey(String.format("%s Bookmark", PreferencesFactory.get().getProperty("application.name"))))) {
      file.setBookmark(dict.stringForKey(String.format("%s Bookmark", PreferencesFactory.get().getProperty("application.name"))));
    }
    else {
      if(StringUtils.isNotBlank(dict.stringForKey("Bookmark"))) {
        file.setBookmark(dict.stringForKey("Bookmark"));
      }
    }
    return file;
  }
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public NSURL resolve(final Local file, final boolean interactive) throws AccessDeniedException {
  final NSData bookmark;
  if(null == file.getBookmark()) {
    log.warn(String.format("Missing security scoped bookmark for file %s", file));
    if(interactive) {
      // Prompt user if no bookmark reference is available
      final String reference = this.choose(file);
      file.setBookmark(reference);
      bookmark = NSData.dataWithBase64EncodedString(reference);
    }
    else {
      throw new LocalAccessDeniedException(String.format("No security scoped bookmark for %s", file.getName()));
    }
  }
  else {
    bookmark = NSData.dataWithBase64EncodedString(file.getBookmark());
  }
  final ObjCObjectByReference error = new ObjCObjectByReference();
  final NSURL resolved = NSURL.URLByResolvingBookmarkData(bookmark, resolve, error);
  if(null == resolved) {
    log.warn(String.format("Error resolving bookmark for %s to URL", file));
    final NSError f = error.getValueAs(NSError.class);
    if(null == f) {
      throw new LocalAccessDeniedException(file.getAbsolute());
    }
    throw new LocalAccessDeniedException(String.format("%s", f.localizedDescription()));
  }
  return resolved;
}

相关文章