use of com.remswork.project.alice.web.service.exception.ClassServiceException in project classify-system by anverliedoit.
the class ClassServiceImpl method updateClassById.
@Override
public Class updateClassById(long id, Class newClass, long teacherId, long subjectId, long sectionId) throws ClassException {
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.queryParam("teacherId", teacherId).queryParam("subjectId", subjectId).queryParam("sectionId", sectionId).request();
builder.accept("application/json");
Response response = builder.put(Entity.json(newClass));
if (response.getStatus() == 200) {
return (Class) response.readEntity(Class.class);
} else if (response.getStatus() == 400) {
Message message = (Message) response.readEntity(Message.class);
throw new ClassServiceException(message.getMessage());
} else
throw new ClassServiceException("The request might invalid or server is down");
} catch (ClassServiceException e) {
throw new ClassException(e.getMessage());
}
}
Aggregations