SecurityManager securityManager = pc.getConfig().getSecurityManager();
securityManager.checkFileLocation(pc.getConfig(),directory,serverPassword);
if(!directory.exists())
throw new ApplicationException("directory ["+directory.toString()+"] doesn't exist");
if(!directory.isDirectory())
throw new ApplicationException("file ["+directory.toString()+"] exists, but isn't a directory");
if(!directory.canRead())
throw new ApplicationException("no access to read directory ["+directory.toString()+"]");
if(StringUtil.isEmpty(strDestination))
throw new ApplicationException("attribute destination is not defined");
// real to source
Resource newdirectory=toDestination(pc,strDestination,directory);
if ( nameconflict == NAMECONFLICT_ERROR && newdirectory.exists() )
throw new ApplicationException("new directory ["+newdirectory.toString()+"] already exist");
securityManager.checkFileLocation(pc.getConfig(),newdirectory,serverPassword);
try {
// has already a filter
if(filter!=null) {
if(recurse) filter=new OrResourceFilter(new ResourceFilter[]{
filter,DirectoryResourceFilter.FILTER
});
}
else {
if(!recurse)filter=new NotResourceFilter(DirectoryResourceFilter.FILTER);
}
if(!createPath) {
Resource p = newdirectory.getParentResource();
if(p!=null && !p.exists())
throw new ApplicationException("parent directory for ["+newdirectory+"] doesn't exist");
}
ResourceUtil.copyRecursive(directory, newdirectory,filter);
}
catch(Throwable t) {
throw new ApplicationException(t.getMessage());
}
// set S3 stuff
setS3Attrs(directory,acl,storage);