use of cz.metacentrum.perun.core.api.exceptions.RpcException in project perun by CESNET.
the class JsonSerializer method write.
@Override
public void write(Object object) throws RpcException, IOException {
JsonGenerator gen = jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8);
try {
gen.writeObject(object);
gen.flush();
gen.close();
} catch (JsonProcessingException ex) {
throw new RpcException(RpcException.Type.CANNOT_SERIALIZE_VALUE, ex);
}
}
use of cz.metacentrum.perun.core.api.exceptions.RpcException in project perun by CESNET.
the class JsonSerializer method write.
@Override
public void write(Object object) throws RpcException, IOException {
JsonGenerator gen = jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8);
if (object instanceof Throwable) {
throw new IllegalArgumentException("Tried to serialize a throwable object using write()", (Throwable) object);
}
try {
gen.writeObject(object);
gen.close();
} catch (JsonProcessingException ex) {
throw new RpcException(RpcException.Type.CANNOT_SERIALIZE_VALUE, ex);
}
}
use of cz.metacentrum.perun.core.api.exceptions.RpcException in project perun by CESNET.
the class JsonSerializerJSONP method write.
@Override
public void write(Object object) throws RpcException, IOException {
JsonGenerator gen = jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8);
if (object instanceof Throwable) {
throw new IllegalArgumentException("Tried to serialize a throwable object using write()", (Throwable) object);
}
try {
gen.writeRaw(callback + "(");
gen.writeObject(object);
gen.writeRaw(");");
gen.flush();
gen.close();
} catch (JsonProcessingException ex) {
throw new RpcException(RpcException.Type.CANNOT_SERIALIZE_VALUE, ex);
}
}
use of cz.metacentrum.perun.core.api.exceptions.RpcException in project perun by CESNET.
the class JsonSerializerGWT method writePerunException.
@Override
public void writePerunException(PerunException pex) throws IOException {
JsonGenerator gen = jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8);
if (pex == null) {
throw new IllegalArgumentException("pex is null");
} else {
gen.writeStartObject();
gen.writeStringField("errorId", pex.getErrorId());
if (pex instanceof RpcException) {
gen.writeStringField("type", ((RpcException) pex).getType());
gen.writeStringField("errorInfo", ((RpcException) pex).getErrorInfo());
} else {
gen.writeStringField("type", pex.getClass().getSimpleName());
gen.writeStringField("errorInfo", pex.getMessage());
}
// write reason param for this case
if (pex instanceof ExtendMembershipException) {
gen.writeStringField("reason", ((ExtendMembershipException) pex).getReason().toString());
}
gen.writeEndObject();
}
gen.close();
}
use of cz.metacentrum.perun.core.api.exceptions.RpcException in project perun by CESNET.
the class JsonSerializerJSONSIMPLE method write.
@Override
public void write(Object object) throws RpcException, IOException {
JsonGenerator gen = jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8);
try {
gen.writeObject(object);
gen.flush();
gen.close();
} catch (JsonProcessingException ex) {
throw new RpcException(RpcException.Type.CANNOT_SERIALIZE_VALUE, ex);
}
}
Aggregations