use of com.remswork.project.alice.web.service.exception.TeacherServiceException in project classify-system by anverliedoit.
the class TeacherServiceImpl method deleteTeacherById.
@Override
public Teacher deleteTeacherById(long id) throws TeacherException {
try {
StringBuilder uri = new StringBuilder();
uri.append(targetProperties.getDomain());
uri.append("/");
uri.append(targetProperties.getBaseUri());
uri.append("/");
uri.append(payload);
uri.append("/");
uri.append(id);
Client client = ClientBuilder.newClient();
WebTarget target = client.target(uri.toString());
Builder builder = target.request();
builder.accept("application/json");
Response response = builder.delete();
if (response.getStatus() == 200) {
return (Teacher) response.readEntity(Teacher.class);
} else if (response.getStatus() == 400) {
Message message = (Message) response.readEntity(Message.class);
throw new TeacherServiceException(message.getMessage());
} else
throw new TeacherServiceException("The request might invalid or server is down");
} catch (TeacherServiceException e) {
throw new TeacherException(e.getMessage());
}
}
Aggregations