コード例 #1
0
ファイル: Host.java プロジェクト: kaduardo/cyberduck
 @Override
 public <T> T getAsDictionary() {
   final Serializer dict = SerializerFactory.createSerializer();
   dict.setStringForKey(this.getProtocol().getIdentifier(), "Protocol");
   if (StringUtils.isNotBlank(this.getProtocol().getProvider())) {
     if (!StringUtils.equals(
         this.getProtocol().getProvider(), this.getProtocol().getIdentifier())) {
       dict.setStringForKey(this.getProtocol().getProvider(), "Provider");
     }
   }
   dict.setStringForKey(this.getNickname(), "Nickname");
   dict.setStringForKey(this.getUuid(), "UUID");
   dict.setStringForKey(this.getHostname(), "Hostname");
   dict.setStringForKey(String.valueOf(this.getPort()), "Port");
   if (StringUtils.isNotBlank(this.getCredentials().getUsername())) {
     dict.setStringForKey(this.getCredentials().getUsername(), "Username");
   }
   if (StringUtils.isNotBlank(this.getCdnCredentials().getUsername())) {
     dict.setStringForKey(this.getCdnCredentials().getUsername(), "CDN Credentials");
   }
   if (StringUtils.isNotBlank(this.getDefaultPath())) {
     dict.setStringForKey(this.getDefaultPath(), "Path");
   }
   if (StringUtils.isNotBlank(this.getWorkdir())) {
     dict.setStringForKey(this.getWorkdir(), "Workdir");
   }
   if (StringUtils.isNotBlank(this.getEncoding())) {
     dict.setStringForKey(this.getEncoding(), "Encoding");
   }
   if (null != this.getCredentials().getIdentity()) {
     dict.setStringForKey(
         this.getCredentials().getIdentity().getAbbreviatedPath(), "Private Key File");
   }
   if (this.getProtocol().isConnectModeConfigurable()) {
     if (null != this.getFTPConnectMode()) {
       if (this.getFTPConnectMode().equals(FTPConnectMode.PORT)) {
         dict.setStringForKey(FTPConnectMode.PORT.toString(), "FTP Connect Mode");
       } else if (this.getFTPConnectMode().equals(FTPConnectMode.PASV)) {
         dict.setStringForKey(FTPConnectMode.PASV.toString(), "FTP Connect Mode");
       }
     }
   }
   if (null != this.getMaxConnections()) {
     dict.setStringForKey(String.valueOf(this.getMaxConnections()), "Maximum Connections");
   }
   if (!this.isDefaultDownloadFolder()) {
     dict.setStringForKey(this.getDownloadFolder().getAbbreviatedPath(), "Download Folder");
   }
   if (null != this.getTimezone()) {
     dict.setStringForKey(this.getTimezone().getID(), "Timezone");
   }
   if (StringUtils.isNotBlank(this.getComment())) {
     dict.setStringForKey(this.getComment(), "Comment");
   }
   if (!this.isDefaultWebURL()) {
     dict.setStringForKey(this.getWebURL(), "Web URL");
   }
   if (null != this.getTimestamp()) {
     dict.setStringForKey(String.valueOf(this.getTimestamp().getTime()), "Access Timestamp");
   }
   return dict.getSerialized();
 }
コード例 #2
0
ファイル: Host.java プロジェクト: kaduardo/cyberduck
 /** @param serialized A valid bookmark dictionary */
 public <T> Host(T serialized) {
   final Deserializer dict = DeserializerFactory.createDeserializer(serialized);
   Object uuidObj = dict.stringForKey("UUID");
   if (uuidObj != null) {
     this.setUuid(uuidObj.toString());
   }
   Object protocolObj = dict.stringForKey("Protocol");
   if (protocolObj != null) {
     this.setProtocol(ProtocolFactory.forName(protocolObj.toString()));
   }
   Object providerObj = dict.stringForKey("Provider");
   if (providerObj != null) {
     this.setProtocol(ProtocolFactory.forName(providerObj.toString()));
   }
   Object hostnameObj = dict.stringForKey("Hostname");
   if (hostnameObj != null) {
     this.setHostname(hostnameObj.toString());
   }
   Object usernameObj = dict.stringForKey("Username");
   if (usernameObj != null) {
     credentials.setUsername(usernameObj.toString());
   }
   Object passwordObj = dict.stringForKey("Password");
   if (passwordObj != null) {
     credentials.setPassword(passwordObj.toString());
   }
   Object cdnCredentialsObj = dict.stringForKey("CDN Credentials");
   if (cdnCredentialsObj != null) {
     cdnCredentials.setUsername(cdnCredentialsObj.toString());
   }
   Object keyObj = dict.stringForKey("Private Key File");
   if (keyObj != null) {
     this.getCredentials().setIdentity(LocalFactory.createLocal(keyObj.toString()));
   }
   Object portObj = dict.stringForKey("Port");
   if (portObj != null) {
     this.setPort(Integer.parseInt(portObj.toString()));
   }
   Object pathObj = dict.stringForKey("Path");
   if (pathObj != null) {
     this.setDefaultPath(pathObj.toString());
   }
   Object workdirObj = dict.stringForKey("Workdir");
   if (workdirObj != null) {
     this.setWorkdir(workdirObj.toString());
   }
   Object nicknameObj = dict.stringForKey("Nickname");
   if (nicknameObj != null) {
     this.setNickname(nicknameObj.toString());
   }
   Object encodingObj = dict.stringForKey("Encoding");
   if (encodingObj != null) {
     this.setEncoding(encodingObj.toString());
   }
   Object connectModeObj = dict.stringForKey("FTP Connect Mode");
   if (connectModeObj != null) {
     if (connectModeObj.toString().equals(FTPConnectMode.PORT.toString())) {
       this.setFTPConnectMode(FTPConnectMode.PORT);
     }
     if (connectModeObj.toString().equals(FTPConnectMode.PASV.toString())) {
       this.setFTPConnectMode(FTPConnectMode.PASV);
     }
   }
   Object connObj = dict.stringForKey("Maximum Connections");
   if (connObj != null) {
     this.setMaxConnections(Integer.valueOf(connObj.toString()));
   }
   Object downloadObj = dict.stringForKey("Download Folder");
   if (downloadObj != null) {
     this.setDownloadFolder(LocalFactory.createLocal(downloadObj.toString()));
   }
   Object timezoneObj = dict.stringForKey("Timezone");
   if (timezoneObj != null) {
     this.setTimezone(TimeZone.getTimeZone(timezoneObj.toString()));
   }
   Object commentObj = dict.stringForKey("Comment");
   if (commentObj != null) {
     this.setComment(commentObj.toString());
   }
   Object urlObj = dict.stringForKey("Web URL");
   if (urlObj != null) {
     this.setWebURL(urlObj.toString());
   }
   Object accessObj = dict.stringForKey("Access Timestamp");
   if (accessObj != null) {
     this.setTimestamp(new Date(Long.parseLong(accessObj.toString())));
   }
 }