Skip to content

Commit 4e08a8e

Browse files
committed
0.8.6-jvfs3 (2023-01-20)
------------------ + Fix in handling of db jvfs for oracle data base
1 parent 25d993b commit 4e08a8e

File tree

8 files changed

+44
-15
lines changed

8 files changed

+44
-15
lines changed

docgen/parameters.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"title" : "Jupiter (Fugerit Core A.P.I.)",
33
"name": "Jupiter",
4-
"version" : "0.8.6-jvfs2",
5-
"date" : "19/01/2023",
4+
"version" : "0.8.6-jvfs3",
5+
"date" : "20/01/2023",
66
"organization" : {
77
"name" : "Fugerit Org",
88
"url" : "https://www.fugerit.org"

docgen/release-notes.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
0.8.6-jvfs2 (2023-01-19)
1+
0.8.6-jvfs3 (2023-01-20)
2+
------------------
3+
+ Fix in handling of db jvfs for oracle data base
4+
5+
0.8.6-jvfs2 (2023-01-19)
26
------------------
37
+ Removed system out
48

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-jvfs2</version>
10+
<version>0.8.6-jvfs3</version>
1111
</parent>
1212

1313
<name>fj-core</name>

fj-core/src/main/java/org/fugerit/java/core/jvfs/db/JMountDaogenDB.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public class JMountDaogenDB implements JMount, Serializable {
4141

4242
private EntityDbJvfsFileFacade facade;
4343

44+
private String rootParentPath;
45+
4446
public JMountDaogenDB(DataSource ds, EntityDbJvfsFileFacade facade) throws DAOException {
4547
this( ConnectionFactoryImpl.newInstance( ds ), facade );
4648
}
@@ -49,6 +51,7 @@ public JMountDaogenDB(ConnectionFactory cf, EntityDbJvfsFileFacade facade) {
4951
super();
5052
this.cf = cf;
5153
this.facade = facade;
54+
this.rootParentPath = JFile.SEPARATOR+JFile.SEPARATOR;
5255
}
5356

5457
public static JVFS createJVFSWithPrefix( ConnectionFactory cf, String prefix ) throws IOException {
@@ -71,12 +74,28 @@ public static JVFS createJVFS( ConnectionFactory cf ) throws IOException {
7174
}
7275
}
7376

77+
public String getParentPath( PathDescriptor descriptor ) {
78+
String parentPath = descriptor.getParentPath();
79+
if ( this.rootParentPath != null && JFileUtils.isRoot( descriptor.getPath() ) ) {
80+
parentPath = this.rootParentPath;
81+
}
82+
return parentPath;
83+
}
84+
85+
public String checkParentPath( String parentPath ) {
86+
String path = parentPath;
87+
if ( this.rootParentPath != null && this.rootParentPath.equals( parentPath ) ) {
88+
path = "";
89+
}
90+
return path;
91+
}
92+
7493
@Override
7594
public JFile getJFile(JVFS jvfs, String point, String relPath) {
7695
JFile file = null;
7796
try ( CloseableDAOContext context = this.newContext() ) {
7897
PathDescriptor descriptor = JFileUtils.pathDescriptor(relPath);
79-
ModelDbJvfsFile model = this.facade.loadById( context, descriptor.getName(), descriptor.getParentPath() );
98+
ModelDbJvfsFile model = this.facade.loadById( context, descriptor.getName(), this.getParentPath(descriptor) );
8099
file = new DaogenJFileDB(relPath, jvfs, model, this);
81100
} catch (Exception e) {
82101
throw new ConfigRuntimeException( "Error loading file "+relPath, e );
@@ -106,8 +125,10 @@ public JFile[] listFiles( DaogenJFileDB file ) throws IOException {
106125
BasicDaoResult<ModelDbJvfsFile> res = this.facade.loadAllByFinder( context , finder );
107126
if ( res.isResultOk() ) {
108127
list = res.getList().stream().map(
109-
dbf -> new DaogenJFileDB( JFileUtils.createPath( dbf.getParentPath(), dbf.getFileName() ), file.getJVFS(), dbf, this )
128+
dbf -> new DaogenJFileDB( JFileUtils.createPath( this.checkParentPath( dbf.getParentPath() ), dbf.getFileName() ), file.getJVFS(), dbf, this )
110129
).collect( Collectors.toList() ).toArray( new JFile[0] );
130+
} else {
131+
throw new DAOException( "Failed to created listing : "+res );
111132
}
112133
} catch (Exception e) {
113134
throw new IOException( "Failed to created directory listing : "+file );
@@ -154,13 +175,13 @@ public boolean updateOrCreate( DaogenJFileDB file, byte[] data ) throws IOExcep
154175
boolean updated = false;
155176
try ( CloseableDAOContext context = newContext() ) {
156177
PathDescriptor descriptor = JFileUtils.pathDescriptor( file.getPath() );
157-
ModelDbJvfsFile model = this.facade.loadById( context, descriptor.getName(), descriptor.getParentPath() );
178+
ModelDbJvfsFile model = this.facade.loadById( context, descriptor.getName(), this.getParentPath(descriptor) );
158179
boolean create = ( model == null );
159180
Date currentTime = new Date();
160181
if ( create ) {
161182
model = new HelperDbJvfsFile();
162183
model.setFileName( descriptor.getName() );
163-
model.setParentPath( descriptor.getParentPath() );
184+
model.setParentPath( this.getParentPath(descriptor) );
164185
model.setCreationTime( currentTime );
165186
file.setDbFile( model );
166187
}

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import org.fugerit.java.core.jvfs.JVFS;
66
import org.fugerit.java.core.jvfs.db.JMountDaogenDB;
7-
import org.fugerit.java.core.jvfs.db.daogen.impl.DataEntityDbJvfsFileFacade;
87
import org.fugerit.java.core.jvfs.file.RealJMount;
98
import org.fugerit.java.test.db.helper.MemDBHelper;
109
import org.junit.Test;
@@ -14,12 +13,10 @@ public class TestCopyRealToDb extends TestJVFSHelper {
1413
@Test
1514
public void testCopy02() {
1615
try {
17-
String prefix = "FUGERIT.";
18-
DataEntityDbJvfsFileFacade facade = DataEntityDbJvfsFileFacade.newInstanceWithPrefix(prefix);
1916
JVFS from = RealJMount.createJVFS( new File( "src/test/resources/core" ) );
20-
JVFS to = JMountDaogenDB.createJVFS( MemDBHelper.newCF(), facade );
17+
JVFS to = JMountDaogenDB.createJVFS( MemDBHelper.newCF(), this.facade );
2118
this.testWriteRead(from, to);
22-
this.tryDumpTestDb( facade );
19+
this.tryDumpTestDb();
2320
} catch (Exception e) {
2421
this.failEx(e);
2522
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@
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;
14+
import org.fugerit.java.core.jvfs.db.daogen.impl.DataEntityDbJvfsFileFacade;
1415
import org.fugerit.java.core.lang.helpers.StringUtils;
1516
import org.fugerit.java.test.db.helper.MemDBHelper;
1617

1718
import test.org.fugerit.java.BasicTest;
1819

1920
public class TestJVFSHelper extends BasicTest {
2021

22+
protected EntityDbJvfsFileFacade facade = DataEntityDbJvfsFileFacade.newInstanceWithPrefix( "FUGERIT." );
23+
2124
protected void testJVFSWorker( JVFS jvfs ) {
2225
try {
2326
JFile root =jvfs.getRoot();
@@ -74,6 +77,10 @@ public int compare(ModelDbJvfsFile o1, ModelDbJvfsFile o2) {
7477
}
7578
};
7679

80+
protected void tryDumpTestDb() {
81+
this.tryDumpTestDb( this.facade );
82+
}
83+
7784
protected void tryDumpTestDb( EntityDbJvfsFileFacade fileFacade ) {
7885
logger.info( "Try to dumb jvfs db : " );
7986
try ( CloseableDAOContext context = new CloseableDAOContextSC( MemDBHelper.newConnection() ) ) {

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-jvfs2</version>
10+
<version>0.8.6-jvfs3</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-jvfs2</version>
14+
<version>0.8.6-jvfs3</version>
1515
<packaging>pom</packaging>
1616

1717
<name>fj-lib</name>

0 commit comments

Comments
 (0)