[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gzz/mediaserver AddToMediaserver.java
From: |
Benja Fallenstein |
Subject: |
[Gzz-commits] gzz/gzz/mediaserver AddToMediaserver.java |
Date: |
Thu, 26 Sep 2002 08:28:10 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Benja Fallenstein <address@hidden> 02/09/26 08:28:10
Modified files:
gzz/mediaserver: AddToMediaserver.java
Log message:
Allow adding blocks in a canonicalized way, i.e. so that
the same file always produces the same block.
Necessary so that others can get the pdfs we use
in the demos themselves, and still get
the right blocks.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/mediaserver/AddToMediaserver.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: gzz/gzz/mediaserver/AddToMediaserver.java
diff -c gzz/gzz/mediaserver/AddToMediaserver.java:1.3
gzz/gzz/mediaserver/AddToMediaserver.java:1.4
*** gzz/gzz/mediaserver/AddToMediaserver.java:1.3 Sun Apr 7 09:30:06 2002
--- gzz/gzz/mediaserver/AddToMediaserver.java Thu Sep 26 08:28:10 2002
***************
*** 1,12 ****
! /*
AddToMediaserver.java
! *
* You may use and distribute under the terms of either the GNU Lesser
* General Public License, either version 2 of the license or,
* at your choice, any later version. Alternatively, you may use and
* distribute under the terms of the XPL.
*
! * See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of
* the licenses.
*
* This software is distributed in the hope that it will be useful,
--- 1,12 ----
! /*
AddToMediaserver.java
! *
* You may use and distribute under the terms of either the GNU Lesser
* General Public License, either version 2 of the license or,
* at your choice, any later version. Alternatively, you may use and
* distribute under the terms of the XPL.
*
! * See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of
* the licenses.
*
* This software is distributed in the hope that it will be useful,
***************
*** 30,36 ****
*/
public class AddToMediaserver {
! public static final String rcsid = "$Id: AddToMediaserver.java,v 1.3
2002/04/07 13:30:06 benja Exp $";
public static boolean dbg = false;
protected static void p(String s) { if(dbg) pa(s); }
protected static void pa(String s) { System.err.println(s); }
--- 30,36 ----
*/
public class AddToMediaserver {
! public static final String rcsid = "$Id: AddToMediaserver.java,v 1.4
2002/09/26 12:28:10 benja Exp $";
public static boolean dbg = false;
protected static void p(String s) { if(dbg) pa(s); }
protected static void pa(String s) { System.err.println(s); }
***************
*** 47,83 ****
public static void main(String argv[]) {
try {
Storer stor;
! if (argv.length < 3) {
pa("AddToMediaserver takes three arguments:");
pa("The mediaserver directory, the content type of the ");
pa("file to add (or \"guess\"), and the filename of the file to
add.");
return;
}
! System.out.println(argv[0]);
! stor = new DirStorer(new File(argv[0]));
! String content_type = argv[1];
! File file = new File(argv[2]);
if (content_type.equals("guess")) content_type =
guessContentType(file);
if(!file.exists()) {
pa("File "+file+" doesn't exist");
return;
}
Mediaserver ms = new SimpleMediaserver(stor,new IDSpace(), 0);
!
FileInputStream fis = new FileInputStream(file);
int len = fis.available();
byte[] bytes = new byte[len];
fis.read(bytes, 0, len);
fis.close();
! String id = ms.addDatum(bytes, content_type).getString();
!
out("The mediaserver block was created successfully. "+
"Its mediaserver ID is: ");
out(id);
out("You can view the MS block now by reading it from the ");
! out("mediaserver directory you specified, "+argv[0]+".");
}catch(IOException e) {
e.printStackTrace();
--- 47,98 ----
public static void main(String argv[]) {
try {
Storer stor;
! if (argv.length < 3 || (argv.length > 3 && !argv[0].equals("-c"))) {
pa("AddToMediaserver takes three arguments:");
pa("The mediaserver directory, the content type of the ");
pa("file to add (or \"guess\"), and the filename of the file to
add.");
+ pa("Optionally, you can supply -c as the first argument");
+ pa("(thus passing four parameters), meaning: use a canonical
header");
+ pa("(just Content-Type).");
return;
}
! boolean canon = argv.length > 3;
! int i = canon ? 1 : 0;
!
! System.out.println(argv[i]);
! stor = new DirStorer(new File(argv[i]));
! String content_type = argv[i+1];
! File file = new File(argv[i+2]);
if (content_type.equals("guess")) content_type =
guessContentType(file);
if(!file.exists()) {
pa("File "+file+" doesn't exist");
return;
}
Mediaserver ms = new SimpleMediaserver(stor,new IDSpace(), 0);
!
FileInputStream fis = new FileInputStream(file);
int len = fis.available();
byte[] bytes = new byte[len];
fis.read(bytes, 0, len);
fis.close();
! content_type = content_type.toLowerCase();
!
! String id;
! if(!canon)
! id = ms.addDatum(bytes, content_type).getString();
! else {
! List header = new ArrayList(1);
! header.add("Content-Type: "+content_type);
! id = ms.addDatum(bytes, header, null, false).getString();
! }
!
out("The mediaserver block was created successfully. "+
"Its mediaserver ID is: ");
out(id);
out("You can view the MS block now by reading it from the ");
! out("mediaserver directory you specified, "+argv[i]+".");
}catch(IOException e) {
e.printStackTrace();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/gzz/mediaserver AddToMediaserver.java,
Benja Fallenstein <=