code: public static void initEndpointDirectory(MuleContext muleContext, String endpointName) throws Exception {
  
  		logger.info("Init directory for endpoint: {}", endpointName);
  		
  		FTPClient ftpClient = null;
  
  		try {
  			ftpClient = getFtpClient(muleContext, endpointName);
  	
  			EndpointURI endpointURI = getImmutableEndpoint(muleContext, endpointName).getEndpointURI();
  			String path = endpointURI.getPath();
  	
  			try {
  				if (path.startsWith("/~/")) {
  					path = path.substring(3); // Strip off the leading "/~/" to apply the command to the home-folder
  				
  				} else if (path.startsWith("/")) {
  					path = path.substring(1); // Strip off the leading "/" to apply the command to the home-folder
  				}
  				recursiveDeleteDirectory(ftpClient, path);
  				recursiveCreateDirectory(ftpClient, path);
  			} catch (IOException e) {
  				if (logger.isErrorEnabled()) logger.error("Failed to recursivly delete endpoint " + endpointName, e);
  			}
  			
  		} finally {
  			if (ftpClient != null) {
  				ftpClient.disconnect();
  			}
  		}
  	}
docs: Ensures that the directory exists and is writable by deleting the
  directory and then recreate it.
  
  @param muleContext
  @param endpointName
  @throws Exception