Ejemplo n.º 1
0
  public static void updateTesterIntroducer(
      long testerIntroducerID, D_TesterIntroducer testerIntroducer) {
    String params[] = new String[net.ddp2p.common.table.tester_introducer.F_FIELDS];

    params[net.ddp2p.common.table.tester_introducer.F_TESTER_LID] =
        Util.getStringID(testerIntroducer.testerLID);
    params[net.ddp2p.common.table.tester_introducer.F_INTRODUCER_PEER_LID] =
        Util.getStringID(testerIntroducer.introducerPeerLID);
    params[net.ddp2p.common.table.tester_introducer.F_SIGNATURE] =
        Util.stringSignatureFromByte(testerIntroducer.signature);
    params[net.ddp2p.common.table.tester_introducer.F_WEIGH] = testerIntroducer.weight;
    params[net.ddp2p.common.table.tester_introducer.F_CREATION_DATE] =
        Encoder.getGeneralizedTime(testerIntroducer.creation_date);
    params[net.ddp2p.common.table.tester_introducer.F_TESTER_REJECTING_DATE] =
        Encoder.getGeneralizedTime(testerIntroducer.testerRejectingDate);
    params[net.ddp2p.common.table.tester_introducer.F_ATTACK_BY_INTRODUCER] =
        Util.getString(testerIntroducer.attackByIntroducer);
    // ID:
    params[net.ddp2p.common.table.tester_introducer.F_ID] = Util.getStringID(testerIntroducerID);

    try {
      Application.db.update(
          net.ddp2p.common.table.tester_introducer.TNAME,
          net.ddp2p.common.table.tester_introducer._fields_tester_introducer_no_ID,
          new String[] {net.ddp2p.common.table.tester_introducer.testerIntroducerID},
          params,
          DEBUG);
    } catch (P2PDDSQLException e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
  public static void insertTesterIntroducerInfo(D_TesterIntroducer testerIntroducer) {
    String params[] = new String[net.ddp2p.common.table.tester_introducer.F_FIELDS_NOID];

    params[net.ddp2p.common.table.tester_introducer.F_TESTER_LID] =
        Util.getStringID(testerIntroducer.testerLID);
    params[net.ddp2p.common.table.tester_introducer.F_INTRODUCER_PEER_LID] =
        Util.getStringID(testerIntroducer.introducerPeerLID);
    params[net.ddp2p.common.table.tester_introducer.F_SIGNATURE] =
        Util.stringSignatureFromByte(testerIntroducer.signature);
    params[net.ddp2p.common.table.tester_introducer.F_WEIGH] = testerIntroducer.weight;
    params[net.ddp2p.common.table.tester_introducer.F_CREATION_DATE] =
        Encoder.getGeneralizedTime(testerIntroducer.creation_date);
    // the following should be null!!
    params[net.ddp2p.common.table.tester_introducer.F_TESTER_REJECTING_DATE] =
        null; // Encoder.getGeneralizedTime(testerIntroducer.testerRejectingDate);
    params[net.ddp2p.common.table.tester_introducer.F_ATTACK_BY_INTRODUCER] =
        "0"; // Util.getString(testerIntroducer.attackByIntroducer);
    //			// ID:
    //			params[table.tester_introducer.F_ID] =
    // Util.getStringID(testerIntroducer.testerIntroducerID);

    try {
      Application.db.insert(
          net.ddp2p.common.table.tester_introducer.TNAME,
          net.ddp2p.common.table.tester_introducer._fields_tester_introducer_no_ID,
          params,
          DEBUG);
    } catch (P2PDDSQLException e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 3
0
  public void __run() throws P2PDDSQLException {
    for (DD_SK_Entry d : ds.sk) {
      try {
        String params[] = new String[net.ddp2p.common.table.key.fields.length];
        PK pk = d.key.getPK();
        params[net.ddp2p.common.table.key.COL_SK] = Util.stringSignatureFromByte(d.key.encode());
        params[net.ddp2p.common.table.key.COL_NAME] = d.name;
        params[net.ddp2p.common.table.key.COL_TYPE] = d.type;
        params[net.ddp2p.common.table.key.COL_CREATION_DATE] =
            Encoder.getGeneralizedTime(d.creation);
        params[net.ddp2p.common.table.key.COL_PK] = Util.stringSignatureFromByte(pk.encode());
        params[net.ddp2p.common.table.key.COL_IDHASH] =
            Util.getGIDhash((String) params[net.ddp2p.common.table.key.COL_PK]);
        Application.db.insert(
            net.ddp2p.common.table.key.TNAME, net.ddp2p.common.table.key.fields, params, DEBUG);
      } catch (Exception e) {
        String localized = "";
        if (e.getLocalizedMessage() != null)
          localized = "\n" + __("Error:") + e.getLocalizedMessage();
        Application_GUI.warning(
            __("Error saving key:") + d + localized + "\nError:" + e, __("Error saving key"));
        e.printStackTrace();
      }
    }
    /*
     	for (D_Peer p : ds.peer) {
    if (DEBUG) System.out.println("WB_Messages: store: handle peer: "+p);
    if (! p.verifySignature()) {
    	if (DEBUG) System.out.println("WB_Messages: store: failed signature for: "+p);
    	continue;
    }
    p.fillLocals(null, null);
    if (DEBUG) System.out.println("WB_Messages: store: nou="+p);
    D_Peer old = D_Peer.getPeerByGID_or_GIDhash(p.getGID(), null, true, true, true, ds.sender);
    if (DEBUG) System.out.println("WB_Messages: store: old="+old);
    if (old.loadRemote(p, null, null)) {
    	if (old.dirty_any()) {
    		old.setArrivalDate();
    		old.storeRequest();

    		config.Application_GUI.inform_arrival(old, null);
    	}
    }
    old.releaseReference();
     	}
     	*/
    WB_Messages wm = new WB_Messages();
    wm.peers.addAll(ds.peer);
    if (ds.sender != null) wm.peers.add(0, ds.sender);
    wm.orgs.addAll(ds.org);
    wm.neig.addAll(ds.neigh);
    wm.cons.addAll(ds.constit);
    wm.witn.addAll(ds.witn);
    wm.moti.addAll(ds.moti);
    wm.just.addAll(ds.just);
    wm.sign.addAll(ds.vote);
    wm.news.addAll(ds.news);
    wm.tran.addAll(ds.tran);

    Hashtable<String, RequestData> missing_sr = new Hashtable<String, RequestData>();
    Hashtable<String, RequestData> obtained_sr = new Hashtable<String, RequestData>();
    HashSet<String> orgs = new HashSet<String>();
    String dbg_msg = __("Importing manually!");
    D_Peer myself = ds.sender; // data.HandlingMyself_Peer.get_myself_or_null();
    WB_Messages.store(null, myself, wm, missing_sr, obtained_sr, orgs, dbg_msg);
  }