On Friday 22 February 2008 14:50, Cl?ment wrote:
> Hi,
>
> >>
> > fcp.publishFile(ht,progress,this.getFrontPageUrl().substring(("USK@" +
> > fcp.getInsertURI() + "/" + fcp.getTitle() + "/" + fcp.getEdition()
> > + "/").length()),getArchivePath());
> >
> > This is rather odd - what are you doing here? I mean, why do you construct
the
> > string, which presumably is identical to the first part of the other
string,
> > and then use the first part of the other string anyway?
> >
> Now, I'm doing this, is that better :
> int index = this.getFrontPageUrl().lastIndexOf("/");
> String defaultName = this.getFrontPageUrl().substring(index+1);
> boolean result =
> fcp.publishFile(ht,progress,defaultName,getArchivePath(),this.getTitle());
> ?
It makes a bit more sense. :)
> >> + if(finalURI != null){
> >> + edition =
> >>
> > Integer.parseInt(finalURI.substring(finalURI.length()-1)) + 1;
> >
> >> + }
> >> return success;
> >> }
> >>
> >
> > And is this horrible hack necessary? Can't you keep the edition number as
an
> > integer or something? For that matter, can't you keep the URI as a URI?
(Feel
> > free to reuse code from Freenet itself e.g. FreenetURI).
> >
> Yes, I know, I had to look a little closer on the code, because in fact,
> I'm reusing the code of TBWeblog for the flog, adding a type field,
> which leads me to not use URI. (I am creating a new TBFlog class, to use
> URI instead of String, and to have more flexibility. But I have a little
> technical issue with my IDE, so I have to change it, so it will take a
> little more time I expected)
Ok.
> And, for the other point, I use String because the edition number is
> stock in a xml file.
You can store *anything* in an XML file, if you control the spec. And anyway
you could split it up once you've loaded it into edition number, default
name, main URI/USK, etc.
> Anyway, I prefer to look at the finalURI that the
> node gives to know the edition number, because I'm sure it's the good
> one (so, if there is a bug in another part of the application, I'm sure
> the edition number is the right one). But perhaps it's not a good idea,
> I don't know...
I agree you should get the edition number from the node, but you should store
it (in RAM) as an integer, anything else is inefficient and asking for
trouble. But maybe I'm missing something... perhaps you don't store it for
any length of time?
> >>
> >> - private FileEntry createFileEntry(File file, int edition){
> >> + private FileEntry createFileEntry(File file, int edition, String
path){
> >> String content = DefaultMIMETypes.guessMIMEType(file.getName());
> >> - System.out.println(content);
> >> - FileEntry fileEntry = new DiskFileEntry(file.getName(), content,
> >>
> > file.getPath());
> >
> >> + FileEntry fileEntry = new DiskFileEntry(path + file.getName(),
> >>
> > content, file.getPath());
> >
> >> return fileEntry;
> >> }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20080222/2991c2f4/attachment.pgp>