final RepositoryFile repositoryFile =
getRepository().createFile( destDir.getId(), duplicateFile, data, acl, null );
getRepository()
.setFileMetadata( repositoryFile.getId(), getRepository().getFileMetadata( sourceFileId ) );
} else if ( mode == MODE_OVERWRITE ) { // destFile exists so check to see if we want to overwrite it.
RepositoryFileDto destFileDto = toFileDto( destFile, null, false );
destFileDto.setHidden( sourceFile.isHidden() );
destFile = toFile( destFileDto );
final RepositoryFile repositoryFile = getRepository().updateFile( destFile, data, null );
getRepository().updateAcl( acl );
getRepository()
.setFileMetadata( repositoryFile.getId(), getRepository().getFileMetadata( sourceFileId ) );
}
}
}
}
} else {
for ( String sourceFileId : sourceFileIds ) {
RepositoryFile sourceFile = getRepository().getFileById( sourceFileId );
if ( destDir != null && destDir.isFolder() && sourceFile != null && !sourceFile.isFolder() ) {
// First try to see if regular name is available
String fileName = sourceFile.getName();
String copyText = "";
String rootCopyText = "";
String nameNoExtension = fileName;
String extension = "";
int indexOfDot = fileName.lastIndexOf( '.' );
if ( !( indexOfDot == -1 ) ) {
nameNoExtension = fileName.substring( 0, indexOfDot );
extension = fileName.substring( indexOfDot );
}
RepositoryFileDto
testFile =
getRepoWs().getFile( path + FileUtils.PATH_SEPARATOR + nameNoExtension + extension ); //$NON-NLS-1$
if ( testFile != null ) {
// Second try COPY_PREFIX, If the name already ends with a COPY_PREFIX don't append twice
if ( !nameNoExtension