RE: [Jstyx-users] Re: question about CStyx.openOrCreate()
Status: Beta
Brought to you by:
jonblower
From: Jon B. <jd...@ma...> - 2006-05-16 13:03:18
|
> Actually, according to the rules of Styx you should create > directories with read permissions only. Therefore your call: Sorry, I meant to write that you should create directories and open them with the mode OREAD only. Nothing to do with permissions. > -----Original Message----- > From: jst...@li... > [mailto:jst...@li...] On Behalf Of > Jon Blower > Sent: 12 May 2006 12:32 > To: jst...@li... > Subject: RE: [Jstyx-users] Re: question about CStyx.openOrCreate() > > Hi Tianchao, > > Thanks for reporting this so clearly. There is indeed a bug > in the OpenOrCreateCallback class. The fix will be checked > into the SVN repository later, but in the meantime I've > attached the corrected version. > > Actually, according to the rules of Styx you should create > directories with read permissions only. Therefore your call: > > file.openOrCreate(true, StyxUtils.OWRITE); > > will return an error (although in the buggy version it went > into an infinite loop). You should do this: > > file.openOrCreate(true, StyxUtils.OREAD); > > This may seem counter-intuitive but is logical. The > StyxUtils.OREAD is the > *mode* under which the newly-created directory is opened, not the > *permissions* of the directory. It is not legal to write to > directories so it is not legal to open them with mode OWRITE. > You can create new files in the newly-created directory as normal. > > Perhaps I should change the API to something more intuitive... > > Jon > > > > -----Original Message----- > > From: jst...@li... > > [mailto:jst...@li...] On Behalf > Of Tianchao > > Li > > Sent: 11 May 2006 18:54 > > To: jst...@li... > > Subject: [Jstyx-users] Re: question about CStyx.openOrCreate() > > > > The problem only occurs if the first parameter is true (i.e. > > directory) > > > > file.openOrCreate(true, StyxUtils.OWRITE); > > > > Best regards, > > Tianchao Li > > > > On Thu, 2006-05-11 at 12:41 -0400, Tianchao Li wrote: > > > Hi, > > > > > > I have some problem with the correct usage of > CStyx.openOrCreate() > > > method. > > > > > > I have started the following server: > > > import java.io.IOException; > > > > > > import uk.ac.rdg.resc.jstyx.StyxException; > > > import uk.ac.rdg.resc.jstyx.server.DirectoryOnDisk; > > > import uk.ac.rdg.resc.jstyx.server.StyxDirectory; > > > import uk.ac.rdg.resc.jstyx.server.StyxServer; > > > > > > > > > public class TestStyxServer { > > > > > > /** > > > * @param args > > > */ > > > public static void main(String[] args) { > > > > > > StyxDirectory root; > > > try { > > > root = new StyxDirectory("/"); > > > DirectoryOnDisk file = new > > > DirectoryOnDisk("/home/lit/styxfilesystem"); > > > root.addChild(file); > > > new StyxServer(9876, root).start(); > > > } catch (StyxException e) { > > > // TODO Auto-generated catch block > > > e.printStackTrace(); > > > } catch (IOException e) { > > > // TODO Auto-generated catch block > > > e.printStackTrace(); > > > } > > > } > > > > > > } > > > > > > and the following client: > > > > > > import uk.ac.rdg.resc.jstyx.StyxException; > > > import uk.ac.rdg.resc.jstyx.StyxUtils; import > > > uk.ac.rdg.resc.jstyx.client.CStyxFile; > > > import uk.ac.rdg.resc.jstyx.client.StyxConnection; > > > > > > > > > public class TestStyxClient { > > > > > > /** > > > * @param args > > > */ > > > public static void main(String[] args) { > > > StyxConnection conn = new > StyxConnection("localhost", 9876); > > > try > > > { > > > conn.connect(); > > > CStyxFile file = > > conn.getFile("/styxfilesystem/test.txt"); > > > file.openOrCreate(true, StyxUtils.OWRITE); > > > System.out.println(file.getURL()); > > > } > > > catch (StyxException se) > > > { > > > se.printStackTrace(); > > > } > > > finally > > > { > > > conn.close(); > > > } > > > > > > } > > > > > > } > > > > > > The client is blocked at file.openOrCreate(). Or more exactly, the > > > callback.getReply() never returns. > > > > > > public void openOrCreate(boolean isDirectory, int > mode) throws > > > StyxException > > > { > > > StyxReplyCallback callback = new StyxReplyCallback(); > > > this.openOrCreateAsync(isDirectory, mode, callback); > > > // Blocks until the process is complete > > > callback.getReply(); > > > } > > > > > > > > > Is this a bug? > > > > > > Regards, > > > Tianchao Li > > > > > > > > > > > > > > ------------------------------------------------------- > > Using Tomcat but need to do more? Need to support web services, > > security? > > Get stuff done quickly with pre-integrated technology to > make your job > > easier Download IBM WebSphere Application Server > > v.1.0.1 based on Apache Geronimo > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057& > > dat=121642 > > _______________________________________________ > > Jstyx-users mailing list > > Jst...@li... > > https://lists.sourceforge.net/lists/listinfo/jstyx-users > > > |