use of org.olat.modules.vitero.model.ErrorCode in project OpenOLAT by OpenOLAT.
the class ViteroManager method removeFromRoom.
public ViteroStatus removeFromRoom(ViteroBooking booking, int userId) throws VmsNotAvailableException {
try {
Groupiduserid groupuserId = new Groupiduserid();
groupuserId.setGroupid(booking.getGroupId());
groupuserId.setUserid(userId);
getGroupWebService().removeUserFromGroup(groupuserId);
return new ViteroStatus();
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
case userDoesntExist:
log.error("The user doesn ́t exist!", 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 remove an user from a group", f);
}
return new ViteroStatus(code);
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot remove an user from a group", e);
return new ViteroStatus(ErrorCode.unkown);
}
}
use of org.olat.modules.vitero.model.ErrorCode in project OpenOLAT by OpenOLAT.
the class ViteroManager method createBooking.
public ViteroStatus createBooking(BusinessGroup group, OLATResourceable ores, String subIdentifier, ViteroBooking vBooking) throws VmsNotAvailableException {
Bookingtype booking = getVmsBookingById(vBooking.getBookingId());
if (booking != null) {
log.info("Booking already exists: " + vBooking.getBookingId());
return new ViteroStatus();
}
try {
// a group per meeting
String groupName = vBooking.getGroupName();
int groupId = createGroup(groupName);
if (groupId < 0) {
return new ViteroStatus(ErrorCode.unkown);
}
vBooking.setGroupId(groupId);
// create the meeting with the new group
Booking bookingWs = getBookingWebService();
CreateBookingRequest createRequest = new CreateBookingRequest();
Newbookingtype newBooking = new Newbookingtype();
// mandatory
newBooking.setStart(format(vBooking.getStart()));
newBooking.setEnd(format(vBooking.getEnd()));
newBooking.setStartbuffer(vBooking.getStartBuffer());
newBooking.setEndbuffer(vBooking.getEndBuffer());
newBooking.setGroupid(groupId);
newBooking.setRoomsize(vBooking.getRoomSize());
newBooking.setTimezone(viteroModule.getTimeZoneId());
if (StringHelper.containsNonWhitespace(vBooking.getEventName())) {
newBooking.setEventname(vBooking.getEventName());
}
createRequest.setBooking(newBooking);
CreateBookingResponse response = bookingWs.createBooking(createRequest);
Boolean bookingCollision = response.isBookingcollision();
Boolean moduleCollision = response.isModulecollision();
int bookingId = response.getBookingid();
if (bookingCollision != null && bookingCollision.booleanValue()) {
return new ViteroStatus(ErrorCode.bookingCollision);
} else if (moduleCollision != null && moduleCollision.booleanValue()) {
return new ViteroStatus(ErrorCode.moduleCollision);
}
vBooking.setBookingId(bookingId);
getOrCreateProperty(group, ores, subIdentifier, vBooking);
return new ViteroStatus();
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
case invalidTimezone:
log.error("Invalid time zone!", f);
break;
case bookingCollision:
log.error("Booking collision!", f);
break;
case moduleCollision:
log.error("Invalid module selection!", f);
break;
case bookingInPast:
log.error("Booking in the past!", f);
break;
case licenseExpired:
log.error("License/customer expired!", f);
break;
default:
logAxisError("Cannot create a booking.", f);
}
return new ViteroStatus(code);
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot create a booking.", e);
return new ViteroStatus(ErrorCode.remoteException);
}
}
use of org.olat.modules.vitero.model.ErrorCode in project OpenOLAT by OpenOLAT.
the class ViteroManager method getVmsUsersByGroup.
protected List<Usertype> getVmsUsersByGroup(int groupId) throws VmsNotAvailableException {
try {
GetUserListByGroupRequest listRequest = new GetUserListByGroupRequest();
listRequest.setGroupid(groupId);
Userlist userList = getUserWebService().getUserListByGroup(listRequest);
List<Usertype> userTypes = userList.getUser();
return userTypes;
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
default:
logAxisError("Cannot get the list of users in group: " + groupId, f);
}
return null;
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot get the list of users in group: " + groupId, e);
return null;
}
}
use of org.olat.modules.vitero.model.ErrorCode in project OpenOLAT by OpenOLAT.
the class ViteroManager method storePortrait.
protected boolean storePortrait(Identity identity, int userId) throws VmsNotAvailableException {
try {
File portrait = DisplayPortraitManager.getInstance().getBigPortrait(identity.getName());
if (portrait != null && portrait.exists()) {
Mtom mtomWs = getMtomWebService();
CompleteAvatarWrapper avatar = new CompleteAvatarWrapper();
avatar.setType(BigInteger.ZERO);
avatar.setUserid(BigInteger.valueOf(userId));
avatar.setFilename(portrait.getName());
DataHandler portraitHandler = new DataHandler(new FileDataSource(portrait));
avatar.setFile(portraitHandler);
mtomWs.storeAvatar(avatar);
return true;
}
return false;
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
default:
logAxisError("Cannot store the portrait of " + userId, f);
}
return false;
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot store the portrait of " + userId, e);
return false;
}
}
use of org.olat.modules.vitero.model.ErrorCode in project OpenOLAT by OpenOLAT.
the class ViteroManager method getGroupRoles.
/**
* @param id The group id
* @return
* @throws VmsNotAvailableException
*/
public ViteroGroupRoles getGroupRoles(int id) throws VmsNotAvailableException {
try {
Group groupWs = getGroupWebService();
Groupid groupId = new Groupid();
groupId.setGroupid(id);
Group_Type group = groupWs.getGroup(groupId);
Completegrouptype groupType = group.getGroup();
List<Completegrouptype.Participant> participants = groupType.getParticipant();
int numOfParticipants = participants == null ? 0 : participants.size();
ViteroGroupRoles groupRoles = new ViteroGroupRoles();
if (numOfParticipants > 0) {
Map<Integer, String> idToEmails = new HashMap<Integer, String>();
List<Usertype> vmsUsers = getVmsUsersByGroup(id);
if (vmsUsers != null) {
for (Usertype vmsUser : vmsUsers) {
Integer userId = new Integer(vmsUser.getId());
String email = vmsUser.getEmail();
groupRoles.getEmailsOfParticipants().add(email);
idToEmails.put(userId, email);
}
}
for (int i = 0; i < numOfParticipants; i++) {
Completegrouptype.Participant participant = participants.get(i);
Integer userId = new Integer(participant.getUserid());
String email = idToEmails.get(userId);
if (email != null) {
GroupRole role = GroupRole.valueOf(participant.getRole());
groupRoles.getEmailsToRole().put(email, role);
groupRoles.getEmailsToVmsUserId().put(email, userId);
}
}
}
return groupRoles;
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
default:
logAxisError("Cannot get group roles", f);
}
return null;
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
return null;
}
}
Aggregations