/** * Create a FileName. * * @param absPath The absolute path. * @param type The FileType. * @return The FileName */ @Override public FileName createName(final String absPath, final FileType type) { return new URLFileName(getScheme(), getHostName(), getPort(), getDefaultPort(), getUserName(), getPassword(), absPath, type, getQueryString()); }
/** * Convert the FileName to an encoded url String. * * @param name The FileName. * @return The encoded URL String. */ private String hrefString(final URLFileName name) { final URLFileName newFile = new URLFileName("http", name.getHostName(), name.getPort(), name.getDefaultPort(), null, null, name.getPath(), name.getType(), name.getQueryString()); try { return newFile.getURIEncoded(this.getUrlCharset()); } catch (final Exception e) { return name.getURI(); } }
@Override public FileName parseUri( VfsComponentContext context, FileName base, String filename ) throws FileSystemException { URLFileName fileNameURLFileName = (URLFileName) super.parseUri( context, base, filename ); return new URLFileName( fileNameURLFileName.getScheme(), getHostNameCaseSensitive( filename ), fileNameURLFileName.getPort(), fileNameURLFileName.getDefaultPort(), fileNameURLFileName.getUserName(), fileNameURLFileName.getPassword(), fileNameURLFileName.getPath(), fileNameURLFileName.getType(), fileNameURLFileName.getQueryString() ); }
/** * Create a FileName. * @param absPath The absolute path. * @param type The FileType. * @return The FileName */ @Override public FileName createName(final String absPath, final FileType type) { return new URLFileName(getScheme(), getHostName(), getPort(), getDefaultPort(), absPath, type, getQueryString()); }
/** * Get the path and query string e.g. /path/servlet?param1=true. * * @return the path and its query string */ public String getPathQuery() { final StringBuilder sb = new StringBuilder(BUFFER_SIZE); sb.append(getPath()); sb.append("?"); sb.append(getQueryString()); return sb.toString(); }
/** * Get the path encoded suitable for url like filesystem e.g. (http, webdav). * * @param charset the charset used for the path encoding * @return The encoded path. * @throws URIException If an error occurs encoding the URI. * @throws FileSystemException If some other error occurs. */ public String getPathQueryEncoded(final String charset) throws URIException, FileSystemException { if (getQueryString() == null) { if (charset != null) { return URIUtil.encodePath(getPathDecoded(), charset); } return URIUtil.encodePath(getPathDecoded()); } final StringBuilder sb = new StringBuilder(BUFFER_SIZE); if (charset != null) { sb.append(URIUtil.encodePath(getPathDecoded(), charset)); } else { sb.append(URIUtil.encodePath(getPathDecoded())); } sb.append("?"); sb.append(getQueryString()); return sb.toString(); }
/** * Encode a URI. * * @param charset The character set. * @return The encoded URI * @throws FileSystemException if some other exception occurs. * @throws URIException if an exception occurs encoding the URI. */ public String getURIEncoded(final String charset) throws FileSystemException, URIException { final StringBuilder sb = new StringBuilder(BUFFER_SIZE); appendRootUri(sb, true); sb.append(getPathQueryEncoded(charset)); return sb.toString(); } }
private void setUserName(final URLFileName fileName, final String urlStr) throws IOException { final List<DefaultDavProperty> list = new ArrayList<>(); String name = builder.getCreatorName(getFileSystem().getFileSystemOptions()); final String userName = fileName.getUserName(); if (name == null) { name = userName; } else { if (userName != null) { final String comment = "Modified by user " + userName; list.add(new DefaultDavProperty(DeltaVConstants.COMMENT, comment)); } } list.add(new DefaultDavProperty(DeltaVConstants.CREATOR_DISPLAYNAME, name)); final PropPatchMethod method = new PropPatchMethod(urlStr, list); setupMethod(method); execute(method); } }
@Override public FileName parseChildUri(final VfsComponentContext context, final FileName base, final String filename) throws FileSystemException { // FTP URI are generic URI (as per RFC 2396) final StringBuilder name = new StringBuilder(); // Extract the scheme and authority parts final Authority auth = extractToPath(filename, name); // Extract the queryString final String queryString = UriParser.extractQueryString(name); // Decode and normalise the file name UriParser.canonicalizePath(name, 0, name.length(), this); //UriParser.fixSeparators(name); final FileType fileType = UriParser.normalisePath(name); final String path = name.toString(); return new URLFileName( auth.getScheme(), auth.getHostName(), auth.getPort(), getDefaultPort(), path, fileType, queryString); } }
/** * Append query string to the uri. * * @return the uri */ @Override protected String createURI() { if (getQueryString() != null) { final StringBuilder sb = new StringBuilder(BUFFER_SIZE); sb.append(super.createURI()); sb.append("?"); sb.append(getQueryString()); return sb.toString(); } return super.createURI(); }
URLFileName file = (URLFileName) sftpFilenameParser.parseUri( null, null, vfsUrl ); if ( !parameterContainsHost( fullParameterName ) || fullParameterName.endsWith( file.getHostName() ) ) {
private boolean isCurrentFile(final String href, final URLFileName fileName) { String name = hrefString(fileName); if (href.endsWith("/") && !name.endsWith("/")) { name += "/"; } return href.equals(name) || href.equals(fileName.getPath()); }
@Override protected void appendRootUri(final StringBuilder buffer, final boolean addPassword) { if (getHostName() != null && !"".equals(getHostName())) { super.appendRootUri(buffer, addPassword); return; } buffer.append(getScheme()); buffer.append(":"); } }
/** * Convert the FileName to an encoded url String. * * @param name The FileName. * @return The encoded URL String. */ private String hrefString(final URLFileName name) { final URLFileName newFile = new URLFileName("http", name.getHostName(), name.getPort(), name.getDefaultPort(), null, null, name.getPath(), name.getType(), name.getQueryString()); try { return newFile.getURIEncoded(this.getUrlCharset()); } catch (final Exception e) { return name.getURI(); } }
/** * Get the path and query string e.g. /path/servlet?param1=true. * * @return the path and its query string */ public String getPathQuery() { final StringBuilder sb = new StringBuilder(BUFFER_SIZE); sb.append(getPath()); sb.append("?"); sb.append(getQueryString()); return sb.toString(); }
/** * Get the path encoded suitable for url like filesystem e.g. (http, webdav). * * @param charset the charset used for the path encoding * @return The encoded path. * @throws URIException If an error occurs encoding the URI. * @throws FileSystemException If some other error occurs. */ public String getPathQueryEncoded(final String charset) throws URIException, FileSystemException { if (getQueryString() == null) { if (charset != null) { return URIUtil.encodePath(getPathDecoded(), charset); } return URIUtil.encodePath(getPathDecoded()); } final StringBuilder sb = new StringBuilder(BUFFER_SIZE); if (charset != null) { sb.append(URIUtil.encodePath(getPathDecoded(), charset)); } else { sb.append(URIUtil.encodePath(getPathDecoded())); } sb.append("?"); sb.append(getQueryString()); return sb.toString(); }
/** * Encode a URI. * * @param charset The character set. * @return The encoded URI * @throws FileSystemException if some other exception occurs. * @throws URIException if an exception occurs encoding the URI. */ public String getURIEncoded(final String charset) throws FileSystemException, URIException { final StringBuilder sb = new StringBuilder(BUFFER_SIZE); appendRootUri(sb, true); sb.append(getPathQueryEncoded(charset)); return sb.toString(); } }
private void setUserName(final URLFileName fileName, final String urlStr) throws IOException { final List<DefaultDavProperty> list = new ArrayList<>(); String name = builder.getCreatorName(getFileSystem().getFileSystemOptions()); final String userName = fileName.getUserName(); if (name == null) { name = userName; } else { if (userName != null) { final String comment = "Modified by user " + userName; list.add(new DefaultDavProperty(DeltaVConstants.COMMENT, comment)); } } list.add(new DefaultDavProperty(DeltaVConstants.CREATOR_DISPLAYNAME, name)); final PropPatchMethod method = new PropPatchMethod(urlStr, list); setupMethod(method); execute(method); } }
@Override public FileName parseUri(final VfsComponentContext context, final FileName base, final String filename) throws FileSystemException { // FTP URI are generic URI (as per RFC 2396) final StringBuilder name = new StringBuilder(); // Extract the scheme and authority parts final Authority auth = extractToPath(filename, name); // Extract the queryString final String queryString = UriParser.extractQueryString(name); // Decode and normalise the file name UriParser.canonicalizePath(name, 0, name.length(), this); UriParser.fixSeparators(name); final FileType fileType = UriParser.normalisePath(name); final String path = name.toString(); return new URLFileName(auth.getScheme(), auth.getHostName(), auth.getPort(), getDefaultPort(), auth.getUserName(), auth.getPassword(), path, fileType, queryString); } }
/** * Append query string to the uri. * * @return the uri */ @Override protected String createURI() { if (getQueryString() != null) { final StringBuilder sb = new StringBuilder(BUFFER_SIZE); sb.append(super.createURI()); sb.append("?"); sb.append(getQueryString()); return sb.toString(); } return super.createURI(); }