33 |
import java.security.*; |
import java.security.*; |
34 |
|
|
35 |
public class PointerIndex { |
public class PointerIndex { |
36 |
|
public static boolean dbg = true; |
37 |
|
private static void p(String s) { System.out.println("PointerIndex:: "+s); } |
38 |
|
|
39 |
public static final String uri = |
public static final String uri = |
40 |
"http://fenfire.org/2003/05/pointer-index-0.1"; |
"http://fenfire.org/2003/05/pointer-index-0.1"; |
41 |
|
|
46 |
|
|
47 |
public BlockId get(PointerId id) |
public BlockId get(PointerId id) |
48 |
throws IOException, GeneralSecurityException { |
throws IOException, GeneralSecurityException { |
49 |
|
if(dbg) p("Get: "+id); |
50 |
|
|
51 |
Collector c = db.get(id.toString()).block(); |
Collector c = db.get(id.toString()).block(); |
52 |
long maxstamp = 0; |
long maxstamp = 0; |
53 |
BlockId result = null; |
BlockId result = null; |
54 |
for(Iterator i=c.iterator(); i.hasNext();) { |
for(Iterator i=c.iterator(); i.hasNext();) { |
55 |
IndexedPool.Mapping m = (IndexedPool.Mapping)i.next(); |
IndexedPool.Mapping m = (IndexedPool.Mapping)i.next(); |
56 |
|
if(dbg) p("Process: "+m.block+" "+m.value); |
57 |
|
|
58 |
long timestamp; |
long timestamp; |
59 |
try { |
try { |
60 |
timestamp = Long.parseLong(m.value); |
timestamp = Long.parseLong(m.value); |
104 |
BlockOutputStream bos = pool.getBlockOutputStream("text/plain"); |
BlockOutputStream bos = pool.getBlockOutputStream("text/plain"); |
105 |
String header = |
String header = |
106 |
PointerBlock.COOKIE + "\n" + |
PointerBlock.COOKIE + "\n" + |
107 |
Base32.encode(signature); |
Base32.encode(signature) + "\n"; |
108 |
bos.write(header.getBytes("US-ASCII")); |
bos.write(header.getBytes("US-ASCII")); |
109 |
bos.write(data.getBytes("US-ASCII")); |
bos.write(data.getBytes("US-ASCII")); |
110 |
bos.close(); |
bos.close(); |
116 |
try { |
try { |
117 |
p = new PointerBlock(block); |
p = new PointerBlock(block); |
118 |
} catch(Throwable _) { |
} catch(Throwable _) { |
119 |
|
if(dbg) _.printStackTrace(); |
120 |
return Collections.EMPTY_SET; |
return Collections.EMPTY_SET; |
121 |
} |
} |
122 |
|
|