/** * Performs a deep copy on <i>other</i>. */ public DRPCExecutionException(DRPCExecutionException other) { if (other.is_set_msg()) { this.msg = other.msg; } if (other.is_set_type()) { this.type = other.type; } }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case MSG: return is_set_msg(); case TYPE: return is_set_type(); } throw new java.lang.IllegalStateException(); }
@Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((is_set_msg()) ? 131071 : 524287); if (is_set_msg()) hashCode = hashCode * 8191 + msg.hashCode(); hashCode = hashCode * 8191 + ((is_set_type()) ? 131071 : 524287); if (is_set_type()) hashCode = hashCode * 8191 + type.getValue(); return hashCode; }
@Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("DRPCExecutionException("); boolean first = true; sb.append("msg:"); if (this.msg == null) { sb.append("null"); } else { sb.append(this.msg); } first = false; if (is_set_type()) { if (!first) sb.append(", "); sb.append("type:"); if (this.type == null) { sb.append("null"); } else { sb.append(this.type); } first = false; } sb.append(")"); return sb.toString(); }
@Override public void write(org.apache.storm.thrift.protocol.TProtocol prot, DRPCExecutionException struct) throws org.apache.storm.thrift.TException { org.apache.storm.thrift.protocol.TTupleProtocol oprot = (org.apache.storm.thrift.protocol.TTupleProtocol) prot; oprot.writeString(struct.msg); java.util.BitSet optionals = new java.util.BitSet(); if (struct.is_set_type()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.is_set_type()) { oprot.writeI32(struct.type.getValue()); } }
@Override public int compareTo(DRPCExecutionException other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(is_set_msg()).compareTo(other.is_set_msg()); if (lastComparison != 0) { return lastComparison; } if (is_set_msg()) { lastComparison = org.apache.storm.thrift.TBaseHelper.compareTo(this.msg, other.msg); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(is_set_type()).compareTo(other.is_set_type()); if (lastComparison != 0) { return lastComparison; } if (is_set_type()) { lastComparison = org.apache.storm.thrift.TBaseHelper.compareTo(this.type, other.type); if (lastComparison != 0) { return lastComparison; } } return 0; }
public boolean equals(DRPCExecutionException that) { if (that == null) return false; if (this == that) return true; boolean this_present_msg = true && this.is_set_msg(); boolean that_present_msg = true && that.is_set_msg(); if (this_present_msg || that_present_msg) { if (!(this_present_msg && that_present_msg)) return false; if (!this.msg.equals(that.msg)) return false; } boolean this_present_type = true && this.is_set_type(); boolean that_present_type = true && that.is_set_type(); if (this_present_type || that_present_type) { if (!(this_present_type && that_present_type)) return false; if (!this.type.equals(that.type)) return false; } return true; }
@Override public Response toResponse(DRPCExecutionException ex) { ResponseBuilder builder = Response.status(500); switch (ex.get_type()) { case FAILED_REQUEST: builder.status(400); break; case SERVER_SHUTDOWN: builder.status(503); //Not available break; case SERVER_TIMEOUT: builder.status(504); //proxy timeout break; case INTERNAL_ERROR: //fall throw on purpose default: //Empty (Still 500) break; } Map<String, String> body = new HashMap<>(); //TODO I would love to standardize this... body.put("error", ex.is_set_type() ? ex.get_type().toString() : "Internal Error"); body.put("errorMessage", ex.get_msg()); return builder.entity(JSONValue.toJSONString(body)).type("application/json").build(); }
public void write(org.apache.storm.thrift.protocol.TProtocol oprot, DRPCExecutionException struct) throws org.apache.storm.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.msg != null) { oprot.writeFieldBegin(MSG_FIELD_DESC); oprot.writeString(struct.msg); oprot.writeFieldEnd(); } if (struct.type != null) { if (struct.is_set_type()) { oprot.writeFieldBegin(TYPE_FIELD_DESC); oprot.writeI32(struct.type.getValue()); oprot.writeFieldEnd(); } } oprot.writeFieldStop(); oprot.writeStructEnd(); }