@ -40,10 +40,10 @@ public class FileOperationHelper {
HistoryTemplateListCache . getInstance ( ) . deleteFile ( nodeFILE ) ;
FineLoggerFactory . getLogger ( ) . info ( "template {} move to {} success." , sourceFileNode . getEnvPath ( ) , targetDir ) ;
} else {
//删除失败,将复制过去的文件删掉
TemplateResourceManager . getResource ( ) . delete ( new FileNodeFILE ( targetPath ) ) ;
//删除源文件 失败,将复制过去的文件删掉
TemplateResourceManager . getResource ( ) . delete ( new FileNodeFILE ( new FileNode ( targetPath , sourceFileNode . isDirectory ( ) ) ) ) ;
FineLoggerFactory . getLogger ( ) . error ( "template {} move to {} failed." , sourceFileNode . getEnvPath ( ) , targetDir ) ;
targetPath = StringUtils . EMPTY ;
throw new ResourceIOException ( String . format ( "template %s move to %s failed" , sourceFileNode . getEnvPath ( ) , targetDir ) ) ;
}
}
return targetPath ;
@ -79,13 +79,16 @@ public class FileOperationHelper {
public boolean checkFreeOrLock ( ExpandMutableTreeNode node , ArrayList < ExpandMutableTreeNode > dNodes , ArrayList < ExpandMutableTreeNode > lNodes ) {
// 自己没锁
boolean selfEmptyLock = false ;
boolean isDir = false ;
Object userObj = node . getUserObject ( ) ;
if ( userObj instanceof FileNode ) {
String lock = ( ( FileNode ) userObj ) . getLock ( ) ;
selfEmptyLock = lock = = null | | ( ( FileNode ) userObj ) . getUserID ( ) . equals ( lock ) ;
FileNode fileNode = ( FileNode ) userObj ;
String lock = fileNode . getLock ( ) ;
selfEmptyLock = lock = = null | | fileNode . getUserID ( ) . equals ( lock ) ;
isDir = fileNode . isDirectory ( ) ;
}
if ( node . isLeaf ( ) ) {
if ( ! isDir ) {
if ( selfEmptyLock ) {
dNodes . add ( node ) ;
} else {
@ -130,7 +133,9 @@ public class FileOperationHelper {
FileNode [ ] fileNodes = TemplateTreePane . getInstance ( ) . getTemplateFileTree ( ) . listFile ( sourceDir ) ;
if ( ArrayUtils . isEmpty ( fileNodes ) ) {
//空目录:相当于新建一个目录
DesignerFrameFileDealerPane . getInstance ( ) . getSelectedOperation ( ) . mkdir ( targetDir ) ;
if ( ! DesignerFrameFileDealerPane . getInstance ( ) . getSelectedOperation ( ) . mkdir ( targetDir ) ) {
throw new ResourceIOException ( String . format ( "copy dir failed: from %s to %s." , sourceDir , targetDir ) ) ;
}
return ;
}
for ( FileNode fileNode : fileNodes ) {