当前位置: 首页>>代码示例>>Java>>正文


Java FileSystemException类代码示例

本文整理汇总了Java中org.apache.commons.vfs.FileSystemException的典型用法代码示例。如果您正苦于以下问题:Java FileSystemException类的具体用法?Java FileSystemException怎么用?Java FileSystemException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileSystemException类属于org.apache.commons.vfs包,在下文中一共展示了FileSystemException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseUri

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
/**
 * Parses URI and constructs S3 file name.
 */
public FileName parseUri(final VfsComponentContext context, final FileName base, final String filename) throws FileSystemException {
	StringBuffer name = new StringBuffer();

	String scheme = UriParser.extractScheme(filename, name);
	UriParser.canonicalizePath(name, 0, name.length(), this);

	// Normalize separators in the path
	UriParser.fixSeparators(name);

	// Normalise the path
	FileType fileType = UriParser.normalisePath(name);

	// Extract bucket name
	final String bucketName = UriParser.extractFirstElement(name);

	return new S3FileName(scheme, bucketName, name.toString(), fileType);
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:21,代码来源:S3FileNameParser.java

示例2: handle

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
public FtpReplay handle(String command, String params)
        throws CommandException, FileSystemException
{
    try
    {
        if(getSession().getLoginContext()!=null) 
            getSession().getLoginContext().logout();
        getSession().setUsername(null);
        getSession().setPassword(null);
        return FtpReplay.createReplay(221, "Goodbye.");
    }
    catch (LoginException e)
    {
        return FtpReplay.createReplay(530, "User {0} cannot log out.", getSession().getUsername());
    }
}
 
开发者ID:PhantomYdn,项目名称:jvfsftpd,代码行数:17,代码来源:QuitHandler.java

示例3: handle

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
public FtpReplay handle(String command, String params)
        throws CommandException, FileSystemException
{
    String portStr = params;
    StringTokenizer st = new StringTokenizer(portStr, ",");
    String h1 = st.nextToken();
    String h2 = st.nextToken();
    String h3 = st.nextToken();
    String h4 = st.nextToken();
    int p1 = Integer.parseInt(st.nextToken());
    int p2 = Integer.parseInt(st.nextToken());

    String dataHost = h1 + "." + h2 + "." + h3 + "." + h4;
    int dataPort = (p1 << 8) | p2;

    getServerPI().dtp.setDataPort(dataHost, dataPort);

    return FtpReplay.createReplay(200, "{0} command successful.",command);
}
 
开发者ID:PhantomYdn,项目名称:jvfsftpd,代码行数:20,代码来源:PortHandler.java

示例4: handle

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
public FtpReplay handle(String command, String params)
        throws CommandException, FileSystemException
{
    String arg = params;


    FileObject dir = getPath(arg); 
    if (dir.exists())
        throw new CommandException(550, arg + ": file exists");
    try
    {
        dir.createFile();
    }
    catch(FileSystemException exc)
    {
        throw new CommandException(550, arg
                + ": directory could not be created");
    }        
    return FtpReplay.createReplay(257, "\"{0}\" directory created", getRelativePath(dir));
}
 
开发者ID:PhantomYdn,项目名称:jvfsftpd,代码行数:21,代码来源:MakeDirHandler.java

示例5: handle

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
public FtpReplay handle(String command, String params)
        throws CommandException, FileSystemException
{
    String arg = params.toUpperCase();
    try
    {
        if (arg.length() != 1)
            throw new Exception();
        char stru = arg.charAt(0);
        switch (stru)
        {
        case 'F':
            getServerPI().dtp.setDataStructure(stru);
            break;
        default:
            throw new Exception();
        }
    }
    catch (Exception e)
    {
        throw new CommandException(500, "STRU: invalid argument '" + arg
                + "'");
    }
    return FtpReplay.createReplay(200, "STRU {0} ok.",arg);
}
 
开发者ID:PhantomYdn,项目名称:jvfsftpd,代码行数:26,代码来源:STRUHandler.java

示例6: handle

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
public FtpReplay handle(String command, String params)
        throws CommandException, FileSystemException
{
    try
    {
        if(getSession().getLoginContext()!=null)getSession().getLoginContext().logout();
        getSession().setUsername(null);
        getSession().setPassword(null);
        getSession().setCurrentDir(getSession().getBaseDir());
        getServerPI().dtp = new ServerDTP(getServerPI());
        return FtpReplay.createReplay(220, "Service ready for new user.");
    }
    catch (LoginException e)
    {
        return FtpReplay.createReplay(530, "User {0} cannot log out.", getSession().getUsername());
    }
    
}
 
开发者ID:PhantomYdn,项目名称:jvfsftpd,代码行数:19,代码来源:ReinitializeHandler.java

示例7: handle

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
public FtpReplay handle(String command, String params)
        throws CommandException, FileSystemException
{
    String arg = params;
    FileObject file = getPath(arg); 

    if (!file.exists())
        throw new CommandException(550, arg + ": no such file");
    if (file.getType().equals(FileType.FOLDER))
        throw new CommandException(550, arg + ": not a plain file");

    Representation representation = getServerPI().dtp.getRepresentation();
    long size;
    try
    {
        size = representation.sizeOf(file);
    }
    catch (IOException e)
    {
        throw new CommandException(550, e.getMessage());
    }

    // XXX: in ascii mode, we must count newlines properly
    return FtpReplay.createReplay(213, "{0}",size);
}
 
开发者ID:PhantomYdn,项目名称:jvfsftpd,代码行数:26,代码来源:SizeHandler.java

示例8: getInitialBaseDir

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
@Override
public FileObject getInitialBaseDir(FtpSession session)
{
	String expr = "/ftpd/user[@name=\""+session.getUsername()+"\"]/basedir/text()";
	String dirStr = evalXPath(expr);
	if(StringUtils.isEmpty(dirStr))
	{
		dirStr = evalXPath("/ftpd/default/basedir/text()");
	}
	if(StringUtils.isEmpty(dirStr) )
		throw new IncorrectConfigurationException("Basedir is not set");
	try
	{			
		FileSystemManager fsManager = VFS.getManager();
		return fsManager.resolveFile(dirStr);
	} 
	catch (FileSystemException e)
	{
		throw new IncorrectConfigurationException(e);
	}
}
 
开发者ID:PhantomYdn,项目名称:jvfsftpd,代码行数:22,代码来源:FileFtpConfiguration.java

示例9: getInitialCurrentDir

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
@Override
public FileObject getInitialCurrentDir(FtpSession session)
{
	String expr = "/ftpd/user[@name=\""+session.getUsername()+"\"]/initialdir/text()";
	String dirStr = evalXPath(expr);
	if(StringUtils.isEmpty(dirStr))
	{
		dirStr = evalXPath("/ftpd/default/initialdir/text()");
	}
	if(StringUtils.isEmpty(dirStr))
		return getInitialBaseDir(session);
	try
	{			
		FileSystemManager fsManager = VFS.getManager();
		return fsManager.resolveFile(dirStr);
	} 
	catch (FileSystemException e)
	{
		throw new IncorrectConfigurationException(e);
	}
}
 
开发者ID:PhantomYdn,项目名称:jvfsftpd,代码行数:22,代码来源:FileFtpConfiguration.java

示例10: init

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
public void init(ServletConfig servletConfig) throws ServletException {
  super.init(servletConfig);
  String rootUri = servletConfig.getInitParameter("vfs.uri");
  String authDomain = servletConfig.getInitParameter("vfs.auth.domain");
  String authUser = servletConfig.getInitParameter("vfs.auth.user");
  String authPass = servletConfig.getInitParameter("vfs.auth.password");
  try {
    StaticUserAuthenticator userAuthenticator =
            new StaticUserAuthenticator(authDomain, authUser, authPass);
    FileSystemOptions options = new FileSystemOptions();
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, userAuthenticator);

    VFSBackend.initialize(rootUri, options);
  } catch (FileSystemException e) {
    LOG.error(String.format("can't create file system backend for '%s'", rootUri));
  }
}
 
开发者ID:thinkberg,项目名称:moxo,代码行数:18,代码来源:MoxoWebDAVServlet.java

示例11: addGetContentTypeProperty

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
protected boolean addGetContentTypeProperty(Element root, boolean ignoreValue) {
  try {
    String contentType = object.getContent().getContentInfo().getContentType();
    if (null == contentType || "".equals(contentType)) {
      return false;
    }

    Element el = root.addElement(PROP_GET_CONTENT_TYPE);
    if (!ignoreValue) {
      el.addText(contentType);
    }
    return true;
  } catch (FileSystemException e) {
    e.printStackTrace();
    return false;
  }
}
 
开发者ID:thinkberg,项目名称:moxo,代码行数:18,代码来源:DavResource.java

示例12: addLockDiscoveryProperty

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
protected boolean addLockDiscoveryProperty(Element root, boolean ignoreValue) {
  Element lockdiscoveryEl = root.addElement(PROP_LOCK_DISCOVERY);
  try {
    List<Lock> locks = LockManager.getInstance().discoverLock(object);
    if (locks != null && !locks.isEmpty()) {
      for (Lock lock : locks) {
        if (lock != null && !ignoreValue) {
          lock.serializeToXml(lockdiscoveryEl);
        }
      }
    }
    return true;
  } catch (FileSystemException e) {
    root.remove(lockdiscoveryEl);
    e.printStackTrace();
    return false;
  }
}
 
开发者ID:thinkberg,项目名称:moxo,代码行数:19,代码来源:DavResource.java

示例13: getMultiStatusResponse

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
/**
 * Get a multistatus response for each of the property set/remove requests.
 *
 * @param object              the context object the property requests apply to
 * @param requestedProperties the properties that should be set or removed
 * @param baseUrl             the base url of this server
 * @return an XML document that is the response
 * @throws FileSystemException if there is an error setting or removing a property
 */
private Document getMultiStatusResponse(FileObject object, List<Element> requestedProperties, URL baseUrl)
        throws FileSystemException {
  Document propDoc = DocumentHelper.createDocument();
  propDoc.setXMLEncoding("UTF-8");

  Element multiStatus = propDoc.addElement(TAG_MULTISTATUS, NAMESPACE_DAV);
  Element responseEl = multiStatus.addElement(TAG_RESPONSE);
  try {
    URL url = new URL(baseUrl, URLEncoder.encode(object.getName().getPath(), "UTF-8"));
    responseEl.addElement(TAG_HREF).addText(url.toExternalForm());
  } catch (Exception e) {
    LOG.error("can't set HREF tag in response", e);
  }
  DavResource resource = DavResourceFactory.getInstance().getDavResource(object);
  resource.setPropertyValues(responseEl, requestedProperties);
  return propDoc;
}
 
开发者ID:thinkberg,项目名称:moxo,代码行数:27,代码来源:PropPatchHandler.java

示例14: getMultiStatusResponse

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
/**
 * Create a multistatus response by requesting all properties and writing a response for each
 * the found and the non-found properties
 *
 * @param object  the context object the propfind request applies to
 * @param propEl  the &lt;prop&gt; element containing the actual properties
 * @param baseUrl the base url of this server
 * @param depth   a depth argument for how deep the find will go
 * @return an XML document that is the response
 * @throws FileSystemException if there was an error executing the propfind request
 */
private Document getMultiStatusResponse(FileObject object, Element propEl, URL baseUrl, int depth)
        throws FileSystemException {
  Document propDoc = DocumentHelper.createDocument();
  propDoc.setXMLEncoding("UTF-8");

  Element multiStatus = propDoc.addElement(TAG_MULTISTATUS, NAMESPACE_DAV);
  FileObject[] children = object.findFiles(new DepthFileSelector(depth));
  for (FileObject child : children) {
    Element responseEl = multiStatus.addElement(TAG_RESPONSE);
    try {
      URL url = new URL(baseUrl, URLEncoder.encode(child.getName().getPath(), "UTF-8"));
      responseEl.addElement(TAG_HREF).addText(url.toExternalForm());
    } catch (Exception e) {
      LOG.error("can't set href in response", e);
    }
    DavResource resource = DavResourceFactory.getInstance().getDavResource(child);
    resource.getPropertyValues(responseEl, propEl);
  }
  return propDoc;
}
 
开发者ID:thinkberg,项目名称:moxo,代码行数:32,代码来源:PropFindHandler.java

示例15: KettleVFS

import org.apache.commons.vfs.FileSystemException; //导入依赖的package包/类
private KettleVFS()
{
	// Install a shutdown hook to make sure that the file system manager is closed
	// This will clean up temporary files in vfs_cache
	//
    Thread thread = new Thread(new Runnable(){
    	public void run() {
      try
      {
          FileSystemManager mgr = VFS.getManager();
          if (mgr instanceof DefaultFileSystemManager)
          {
              ((DefaultFileSystemManager)mgr).close();
          }
      }
      catch (FileSystemException e)
      {
          e.printStackTrace();
      }
     }
    });
    Runtime.getRuntime().addShutdownHook(thread); 
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:24,代码来源:KettleVFS.java


注:本文中的org.apache.commons.vfs.FileSystemException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。