Example #1
0
 @Override
 public DD_SK decode(Decoder dec) throws ASN1DecoderFail {
   String default_orgGID = null;
   String default_orgGIDH = null;
   Decoder d = dec.getContent();
   if (d.getTypeByte() == DD.TAG_AP0)
     version = d.getFirstObject(true).getInteger(DD.TAG_AP0).intValue();
   if (d.getTypeByte() == DD.TAG_AC0)
     sk = d.getFirstObject(true).getSequenceOfAL(DD_SK_Entry.getASN1Tag(), new DD_SK_Entry());
   if (d.getTypeByte() == DD.TAG_AC1)
     peer = d.getFirstObject(true).getSequenceOfAL(D_Peer.getASN1Type(), D_Peer.getEmpty());
   if (d.getTypeByte() == DD.TAG_AC2) {
     org =
         d.getFirstObject(true)
             .getSequenceOfAL(D_Organization.getASN1Type(), D_Organization.getEmpty());
     if (org.size() == 1) {
       default_orgGID = org.get(0).getGID();
       default_orgGIDH = org.get(0).getGIDH();
       if (DEBUG)
         System.out.println(
             "DD_SK: has a GID for orgs: " + default_orgGID + " H=" + default_orgGIDH);
     }
   }
   if (d.getTypeByte() == DD.TAG_AC3)
     neigh =
         d.getFirstObject(true)
             .getSequenceOfAL(D_Neighborhood.getASN1Type(), D_Neighborhood.getEmpty());
   if (d.getTypeByte() == DD.TAG_AC4)
     constit =
         d.getFirstObject(true)
             .getSequenceOfAL(D_Constituent.getASN1Type(), D_Constituent.getEmpty());
   if (d.getTypeByte() == DD.TAG_AC5)
     witn = d.getFirstObject(true).getSequenceOfAL(D_Witness.getASN1Type(), D_Witness.getEmpty());
   if (d.getTypeByte() == DD.TAG_AC6) {
     moti = d.getFirstObject(true).getSequenceOfAL(D_Motion.getASN1Type(), D_Motion.getEmpty());
     for (D_Motion m : moti) {
       if (m.getOrganizationGIDH() == null) {
         if (_DEBUG) System.out.println("DD_SK: put a GIDH for " + m);
         m.setOrganizationGID(default_orgGIDH);
         if (_DEBUG) System.out.println("DD_SK: did put a GIDH for " + m);
       } else if (DEBUG) System.out.println("DD_SK: had a GIDH for " + m);
     }
   }
   if (d.getTypeByte() == DD.TAG_AC7)
     just =
         d.getFirstObject(true)
             .getSequenceOfAL(D_Justification.getASN1Type(), D_Justification.getEmpty());
   if (d.getTypeByte() == DD.TAG_AC8)
     vote = d.getFirstObject(true).getSequenceOfAL(D_Vote.getASN1Type(), D_Vote.getEmpty());
   if (d.getTypeByte() == DD.TAG_AC10)
     tran =
         d.getFirstObject(true)
             .getSequenceOfAL(D_Translations.getASN1Type(), D_Translations.getEmpty());
   if (d.getTypeByte() == DD.TAG_AP1) sender = D_Peer.getEmpty().decode(d.getFirstObject(true));
   if (d.getTypeByte() == DD.TAG_AP2) signature = d.getFirstObject(true).getBytes(DD.TAG_AP2);
   return this;
 }
Example #2
0
 /**
  * @param d_SK
  * @param crt_justification
  * @param voting_constituent
  * @param alreadySupported
  */
 public static void addJustificationWithAnySupportToDSSK(
     DD_SK d_SK,
     D_Justification crt_justification,
     D_Constituent voting_constituent,
     boolean alreadySupported) {
   addJustificationToDSSK(d_SK, crt_justification);
   if (alreadySupported) return;
   D_Motion crt_motion = crt_justification.getMotionForce();
   D_Vote my_vote =
       D_Vote.getOneBroadcastedSupportForJustification(
           crt_motion, crt_justification, voting_constituent, crt_motion.getSupportChoice());
   if (my_vote != null) {
     addVoteIfNew(d_SK, my_vote);
     addConstituentToDSSK(d_SK, my_vote.getConstituent_force());
   }
 }
Example #3
0
 @Override
 public String getNiceDescription() {
   String result = "";
   for (DD_SK_Entry _sk : sk)
     result += "SK[: sk=" + _sk.name + "]"; // Util.concat(sk, ";;;", "NULL");
   for (D_Peer _peer : peer) result += " Safe=[" + _peer.getName() + "]";
   for (D_Organization _org : org) result += " Org=[" + _org.getName() + "]";
   for (D_Constituent _constit : constit) result += " Cons=[" + _constit.getNameFull() + "]";
   for (D_Witness _witn : witn) result += " Witn=[" + _witn.witnessed_global_constituentID + "]";
   for (D_Motion _moti : moti) result += " Moti=[" + _moti.getTitleStrOrMy() + "]";
   for (D_Justification _just : just) result += " Just=[" + _just.getTitleStrOrMy() + "]";
   for (D_News _news : news) result += " News=[" + _news.getTitleStrOrMy() + "]";
   for (D_Vote _vote : vote)
     result += " Vote=[" + _vote.getChoice() + " " + _vote.getMotionGID() + "]";
   // to implement
   if (tran.size() > 0) result += " tran=" + Util.concat(tran, ",,,", "NULL");
   result += "]";
   return result;
 }
Example #4
0
  public static boolean addMotionToDSSK(DD_SK d_SK, D_Motion crt_motion) {

    if (crt_motion == null) return false;
    // skip if no GID
    String mGID = crt_motion.getGID();
    if (mGID == null) return false;
    // skip if already in
    for (D_Motion old_m : d_SK.moti) {
      if (Util.equalStrings_and_not_null(old_m.getGID(), mGID)) return false;
    }

    D_Organization org = crt_motion.getOrganization();
    if (org == null) return false;

    d_SK.moti.add(crt_motion);

    D_Constituent constituent = crt_motion.getConstituent();
    addConstituentToDSSK(d_SK, constituent);

    addOrganizationToDSSK(d_SK, org);

    // identify myself
    D_Constituent crt_constituent = DD.getCrtConstituent(crt_motion.getOrganizationLID());
    long _constituentID_myself = -1;
    if (crt_constituent != null) {
      _constituentID_myself = crt_constituent.getLID();
    }

    // find a vote by me or supporters
    D_Vote my_vote = null;
    if (_constituentID_myself > 0) {
      try {
        my_vote = D_Vote.getOpinionForMotion(crt_motion.getLIDstr(), _constituentID_myself);
      } catch (P2PDDSQLException e) {
        e.printStackTrace();
      }
    }
    // if I did not vote this, find any support by someone else
    if (my_vote == null) {
      my_vote =
          D_Vote.getOneBroadcastedSupportForMotion(crt_motion, null, crt_motion.getSupportChoice());
    }

    if (my_vote != null) {
      addVoteIfNew(d_SK, my_vote);
      addConstituentToDSSK(d_SK, my_vote.getConstituent_force()); // crt_constituent);
      D_Justification j = my_vote.getJustificationFromObjOrLID();
      addJustificationToDSSK(d_SK, j);
    }
    return true;
  }