/[storm]/storm/org/nongnu/storm/pointers/PointerIndex.java
ViewVC logotype

Diff of /storm/org/nongnu/storm/pointers/PointerIndex.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by benja, Thu May 22 00:14:08 2003 UTC revision 1.6 by benja, Thu May 22 21:31:00 2003 UTC
# Line 61  public class PointerIndex { Line 61  public class PointerIndex {
61          return result;          return result;
62      }      }
63    
64      public BlockId get(PointerId id)      public BlockId get(PointerId id)
65            throws IOException, GeneralSecurityException {
66            PointerBlock b = getPointerBlock(id);
67            if(b == null) return null;
68            return b.getTarget();
69        }
70    
71        public PointerBlock getPointerBlock(PointerId id)
72          throws IOException, GeneralSecurityException {          throws IOException, GeneralSecurityException {
73          if(dbg) p("Get: "+id);          if(dbg) p("Get: "+id);
74    
75          Collector c = db.get(id.toString()).block();          Collector c = db.get(id.toString()).block();
76          long maxstamp = 0;          long maxstamp = 0;
77          BlockId result = null;          PointerBlock result = null;
78          for(Iterator i=c.iterator(); i.hasNext();) {          for(Iterator i=c.iterator(); i.hasNext();) {
79              IndexedPool.Mapping m = (IndexedPool.Mapping)i.next();              IndexedPool.Mapping m = (IndexedPool.Mapping)i.next();
80              if(dbg) p("Process: "+m.block+" "+m.value);              if(dbg) p("Process: "+m.block+" "+m.value);
# Line 90  public class PointerIndex { Line 97  public class PointerIndex {
97    
98                  if(p.getPointer().equals(id) &&                  if(p.getPointer().equals(id) &&
99                     p.getTimestamp() == timestamp) {                     p.getTimestamp() == timestamp) {
100                      result = p.getTarget();                      result = p;
101                      maxstamp = timestamp;                      maxstamp = timestamp;
102                  }                  }
103              }              }
# Line 101  public class PointerIndex { Line 108  public class PointerIndex {
108    
109      public void set(PointerId id, BlockId target, KeyPair keyPair)      public void set(PointerId id, BlockId target, KeyPair keyPair)
110          throws IOException, GeneralSecurityException {          throws IOException, GeneralSecurityException {
111            set(id, target, keyPair, null);
112        }
113    
114        public void set(PointerId id, BlockId target, KeyPair keyPair,
115                        String newName)
116            throws IOException, GeneralSecurityException {
117          // XXX this assumes that the computer clock          // XXX this assumes that the computer clock
118          // is always set correctly: if there is an existing          // is always set correctly: if there is an existing
119          // pointer block with a later timestamp (because          // pointer block with a later timestamp (because
# Line 117  public class PointerIndex { Line 130  public class PointerIndex {
130              timestamp + "\n" +              timestamp + "\n" +
131              target.toString();              target.toString();
132    
133            if(newName != null) {
134                if(newName.indexOf("\n") >= 0)
135                    throw new IllegalArgumentException("Newline in ptr name");
136                data += "\n" + newName;
137            }
138    
139          Signature s = Signature.getInstance("SHA1withDSA");          Signature s = Signature.getInstance("SHA1withDSA");
140          s.initSign(keyPair.getPrivate());          s.initSign(keyPair.getPrivate());
141          s.update(data.getBytes("US-ASCII"));          s.update(data.getBytes("US-ASCII"));

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26