use of org.olat.modules.vitero.model.ViteroStatus in project openolat by klemens.
the class ViteroBookingWebService method handleNotAvailableException.
private Response handleNotAvailableException() {
ViteroStatus status = new ViteroStatus(ErrorCode.unkown);
ViteroErrorVO error = new ViteroErrorVO(status, "vitero server is probable not avalailable at this time");
return Response.serverError().entity(error).status(Status.SERVICE_UNAVAILABLE).build();
}
use of org.olat.modules.vitero.model.ViteroStatus in project OpenOLAT by OpenOLAT.
the class ViteroManager method addToRoom.
public ViteroStatus addToRoom(ViteroBooking booking, Identity identity, GroupRole role) throws VmsNotAvailableException {
try {
GetUserInfo userInfo = getVmsUserId(identity, true);
int userId = userInfo.getUserId();
if (userId < 0) {
return new ViteroStatus(ErrorCode.userDoesntExist);
}
if (!userInfo.isCreated()) {
// update user information
try {
updateVmsUser(identity, userId);
// storePortrait(identity, userId);
} catch (Exception e) {
log.error("Cannot update user on vitero system:" + identity.getName(), e);
}
}
Group groupWs = getGroupWebService();
Groupiduserid groupuserId = new Groupiduserid();
groupuserId.setGroupid(booking.getGroupId());
groupuserId.setUserid(userId);
groupWs.addUserToGroup(groupuserId);
if (role != null) {
groupWs = getGroupWebService();
ChangeGroupRoleRequest roleRequest = new ChangeGroupRoleRequest();
roleRequest.setGroupid(booking.getGroupId());
roleRequest.setUserid(userId);
roleRequest.setRole(role.getVmsValue());
groupWs.changeGroupRole(roleRequest);
}
return new ViteroStatus();
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
case userDoesntExist:
log.error("The user doesn ́t exist!", f);
break;
case userNotAttachedToCustomer:
log.error("The user is not attached to the customer (to which this group belongs)", f);
break;
case groupDoesntExist:
log.error("The group doesn ́t exist", f);
break;
case invalidAttribut:
log.error("An id <= 0", f);
break;
default:
logAxisError("Cannot add an user to a group", f);
}
return new ViteroStatus(code);
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot add an user to a group", e);
return new ViteroStatus(ErrorCode.unkown);
}
}
use of org.olat.modules.vitero.model.ViteroStatus in project OpenOLAT by OpenOLAT.
the class ViteroManager method updateVmsBooking.
public ViteroStatus updateVmsBooking(ViteroBooking vBooking) throws VmsNotAvailableException {
try {
UpdateBookingRequest updateRequest = new UpdateBookingRequest();
updateRequest.setBookingid(vBooking.getBookingId());
if (StringHelper.containsNonWhitespace(vBooking.getEventName())) {
updateRequest.setEventname(vBooking.getEventName());
}
updateRequest.setEnd(format(vBooking.getEnd()));
updateRequest.setEndbuffer(vBooking.getEndBuffer());
updateRequest.setStart(format(vBooking.getStart()));
updateRequest.setStartbuffer(vBooking.getStartBuffer());
updateRequest.setTimezone(viteroModule.getTimeZoneId());
getBookingWebService().updateBooking(updateRequest);
return new ViteroStatus();
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
case unsufficientRights:
case bookingCollision:
case bookingInPast:
case noRoomsAvailable:
return new ViteroStatus(code);
case bookingDoesntExist:
case bookingDoesntExistPrime:
{
deleteGroup(vBooking);
deleteProperty(vBooking);
// ok, vms deleted, group deleted...
return new ViteroStatus(code);
}
default:
{
logAxisError("Cannot update a booking.", f);
}
}
return new ViteroStatus(ErrorCode.unkown);
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot update a booking.", e);
return new ViteroStatus(ErrorCode.unkown);
}
}
use of org.olat.modules.vitero.model.ViteroStatus in project OpenOLAT by OpenOLAT.
the class ViteroBookingEditController method formOK.
@Override
protected void formOK(UserRequest ureq) {
String name = groupName.getValue();
booking.setGroupName(name);
Date begin = beginChooser.getDate();
booking.setStart(begin);
int beginBuffer = 0;
if (beginBufferEl.isOneSelected()) {
beginBuffer = Integer.parseInt(beginBufferEl.getSelectedKey());
}
booking.setStartBuffer(beginBuffer);
Date end = endChooser.getDate();
booking.setEnd(end);
int endBuffer = 0;
if (endBufferEl.isOneSelected()) {
endBuffer = Integer.parseInt(endBufferEl.getSelectedKey());
}
booking.setEndBuffer(endBuffer);
int roomSize = -1;
if (roomSizeEl.isOneSelected()) {
roomSize = Integer.parseInt(roomSizeEl.getSelectedKey());
}
booking.setRoomSize(roomSize);
boolean auto = autoSignIn.isMultiselect() && autoSignIn.isSelected(0);
booking.setAutoSignIn(auto);
try {
if (booking.getBookingId() >= 0) {
ViteroBooking updatedBooking = viteroManager.updateBooking(group, ores, subIdentifier, booking);
if (updatedBooking != null) {
showInfo("booking.ok");
fireEvent(ureq, Event.DONE_EVENT);
} else {
showError("error.unkown");
}
} else {
ViteroStatus status = viteroManager.createBooking(group, ores, subIdentifier, booking);
if (status.isOk()) {
showInfo("booking.ok");
fireEvent(ureq, Event.DONE_EVENT);
} else {
showError(status.getError().i18nKey());
}
}
} catch (VmsNotAvailableException e) {
showError(VmsNotAvailableException.I18N_KEY);
}
}
use of org.olat.modules.vitero.model.ViteroStatus in project OpenOLAT by OpenOLAT.
the class ViteroBookingsController method signOutVitero.
protected void signOutVitero(UserRequest ureq, ViteroBooking booking) {
try {
ViteroStatus status = viteroManager.removeFromRoom(booking, ureq.getIdentity());
if (status.isOk()) {
showInfo("signout.ok");
} else {
showError("signout.nok");
}
loadModel();
} catch (VmsNotAvailableException e) {
showError(VmsNotAvailableException.I18N_KEY);
}
}
Aggregations