Skip to content

Commit cb61064

Browse files
committed
0.8.6-jvfs4 (2023-01-20)
+ Added db script for daogen jfile mount + Added JFileCopyFacade
1 parent 098fb77 commit cb61064

File tree

8 files changed

+89
-20
lines changed

8 files changed

+89
-20
lines changed

docgen/parameters.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"title" : "Jupiter (Fugerit Core A.P.I.)",
33
"name": "Jupiter",
4-
"version" : "0.8.6-jvfs3",
4+
"version" : "0.8.6-jvfs4",
55
"date" : "20/01/2023",
66
"organization" : {
77
"name" : "Fugerit Org",

docgen/release-notes.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
0.8.6-jvfs3 (2023-01-20)
1+
0.8.6-jvfs4 (2023-01-20)
22
------------------
3-
+ Fix in handling of db jvfs for oracle data base
3+
+ Added db script for daogen jfile mount
4+
+ Added JFileCopyFacade
45

56
0.8.6-jvfs2 (2023-01-19)
67
------------------

fj-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.fugerit.java</groupId>
99
<artifactId>fj-lib</artifactId>
10-
<version>0.8.6-jvfs3</version>
10+
<version>0.8.6-jvfs4</version>
1111
</parent>
1212

1313
<name>fj-core</name>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package org.fugerit.java.core.jvfs;
2+
3+
import java.io.IOException;
4+
5+
import org.fugerit.java.core.io.StreamIO;
6+
import org.slf4j.Logger;
7+
import org.slf4j.LoggerFactory;
8+
9+
public class JFileCopyFacade {
10+
11+
private final static Logger logger = LoggerFactory.getLogger( JFileCopyFacade.class );
12+
13+
public static int copyFile( JFile from, JFile to ) throws IOException {
14+
return copyFile(from, to, false);
15+
}
16+
17+
public static int copyFile( JFile from, JFile to, boolean recurse ) throws IOException {
18+
return copyFile(from, to, recurse, false);
19+
}
20+
21+
public static int copyFile( JFile from, JFile to, boolean recurse, boolean force ) throws IOException {
22+
return copyFile(from, to, recurse, force, false);
23+
}
24+
25+
public static int copyFileRecurse( JFile from, JFile to ) throws IOException {
26+
return copyFile(from, to, true );
27+
}
28+
29+
public static int copyFileRecurseForce( JFile from, JFile to ) throws IOException {
30+
return copyFile(from, to, true, true );
31+
}
32+
33+
public static int copyFileRecurseForceVerbose( JFile from, JFile to ) throws IOException {
34+
return copyFile(from, to, true, true, true );
35+
}
36+
37+
public static int copyFile( JFile from, JFile to, boolean recurse, boolean force, boolean verbose ) throws IOException {
38+
int res = 1;
39+
if ( verbose ) {
40+
logger.info( "copyFile( recurse:"+recurse+", force:"+force+" ) {} -> {}", from, to );
41+
}
42+
if ( to.exists() && !force ) {
43+
throw new IOException( "You can overwrite existing files only with the 'force' flag" );
44+
} else {
45+
if ( from.isFile() && to.isFile() ) {
46+
StreamIO.pipeStream( from.getInputStream() , to.getOutputStream(), StreamIO.MODE_CLOSE_BOTH );
47+
} else if ( from.isDirectory() && to.isDirectory() ) {
48+
if ( recurse ) {
49+
to.mkdir();
50+
JFile[] list = from.listFiles();
51+
for ( int k=0; k<list.length; k++ ) {
52+
JFile kidFrom = list[k];
53+
JFile kidTo = to.getChild( kidFrom.getName() );
54+
res+= copyFile( kidFrom, kidTo, recurse, force, verbose);
55+
}
56+
} else {
57+
throw new IOException( "Directories can only be copied recursively, from:("+from+") to:("+to+")" );
58+
}
59+
} else {
60+
if ( verbose ) {
61+
logger.warn( "from {} -> isDirectory:{}", from, from.isDirectory() );
62+
logger.warn( "to {} -> isDirectory:{}", to, to.isDirectory() );
63+
}
64+
throw new IOException( "You can only copy a two files or two directories, from:("+from+") to:("+to+")" );
65+
}
66+
}
67+
return res;
68+
}
69+
70+
}

fj-core/src/main/java/org/fugerit/java/core/jvfs/file/RealJFile.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.io.InputStream;
88
import java.io.OutputStream;
99

10+
import org.fugerit.java.core.cfg.ConfigRuntimeException;
1011
import org.fugerit.java.core.jvfs.JFile;
1112
import org.fugerit.java.core.jvfs.JVFS;
1213
import org.fugerit.java.core.jvfs.helpers.AbstractJFile;
@@ -42,7 +43,15 @@ public InputStream getInputStream() throws IOException {
4243

4344
@Override
4445
public String getName() {
45-
return this.file.getName();
46+
String name = this.file.getName();
47+
try {
48+
if ( this.isDirectory() && !name.endsWith( SEPARATOR ) ) {
49+
name+= SEPARATOR;
50+
}
51+
} catch (IOException e) {
52+
throw new ConfigRuntimeException( e );
53+
}
54+
return name;
4655
}
4756

4857
@Override

fj-core/src/test/java/test/org/fugerit/java/core/jvfs/TestJVFSHelper.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import org.fugerit.java.core.db.daogen.BasicDaoResult;
77
import org.fugerit.java.core.db.daogen.CloseableDAOContext;
88
import org.fugerit.java.core.db.daogen.CloseableDAOContextSC;
9-
import org.fugerit.java.core.io.StreamIO;
109
import org.fugerit.java.core.jvfs.JFile;
10+
import org.fugerit.java.core.jvfs.JFileCopyFacade;
1111
import org.fugerit.java.core.jvfs.JVFS;
1212
import org.fugerit.java.core.jvfs.db.daogen.EntityDbJvfsFileFacade;
1313
import org.fugerit.java.core.jvfs.db.daogen.ModelDbJvfsFile;
@@ -39,18 +39,7 @@ protected void testJVFSWorker( JVFS jvfs ) {
3939

4040
private void testCopyRecurse( JVFS to, JFile source ) throws IOException {
4141
JFile dest = to.getJFile( source.getPath() );
42-
logger.info( "testCopyRecurse() source:{} -> dest:{}", source, dest );
43-
if ( source.isDirectory() ) {
44-
if ( !dest.exists() ) {
45-
dest.mkdir();
46-
}
47-
JFile[] list = source.listFiles();
48-
for ( int k=0; k<list.length; k++ ) {
49-
testCopyRecurse( to , list[k] );
50-
}
51-
} else {
52-
StreamIO.pipeStream( source.getInputStream() , dest.getOutputStream(), StreamIO.MODE_CLOSE_BOTH );
53-
}
42+
JFileCopyFacade.copyFile( source , dest , true, true, true );
5443
}
5544

5645
private void testReadRecurse( JFile file1, JFile file2 ) throws IOException {

fj-tool/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.fugerit.java</groupId>
99
<artifactId>fj-lib</artifactId>
10-
<version>0.8.6-jvfs3</version>
10+
<version>0.8.6-jvfs4</version>
1111
</parent>
1212

1313
<name>fj-tool</name>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<relativePath></relativePath>
1212
</parent>
1313

14-
<version>0.8.6-jvfs3</version>
14+
<version>0.8.6-jvfs4</version>
1515
<packaging>pom</packaging>
1616

1717
<name>fj-lib</name>

0 commit comments

Comments
 (0)