public void check(CBlockPayload block) throws Exception { // Super class super.check(block); // Check Message if (!UTILS.BASIC.isDesc(mes, 1000)) throw new Exception("Invalid message - CTweetMesPayload.java"); // CommentID valid if (!UTILS.BASIC.validID(this.comID)) throw new Exception("Invalid message ID - CTweetMesPayload.java"); // Parent type if (!this.parent_type.equals("ID_POST") && !this.parent_type.equals("ID_COM")) throw new Exception("Invalid parent type - CTweetMesPayload.java"); // Already commented ? ResultSet rs = UTILS.DB.executeQuery( "SELECT * " + "FROM comments " + "WHERE parent_type='" + this.parent_type + "' " + "AND parentID='" + this.parentID + "' " + "AND adr='" + this.target_adr + "'"); if (UTILS.DB.hasData(rs)) throw new Exception("Already commented - CTweetMesPayload.java"); // Target valid if (!UTILS.BASIC.targetValid(this.parent_type, this.parentID)) throw new Exception("Invalid target type - CTweetMesPayload.java"); // Check Hash String h = UTILS.BASIC.hash(this.getHash() + this.parent_type + this.parentID + this.comID + this.mes); if (!h.equals(this.hash)) throw new Exception("Invalid hash - CTweetMesPayload.java"); }
public CCommentPayload(String adr, String parent_type, long parentID, String mes) throws Exception { // Superclass super(adr); // Parent type this.parent_type = parent_type; // Parent ID this.parentID = parentID; // Message this.mes = mes; // Row ID this.comID = UTILS.BASIC.getID(); // Hash hash = UTILS.BASIC.hash(this.getHash() + this.parent_type + this.parentID + this.comID + this.mes); // Sign this.sign(); }