use of org.olat.modules.vitero.model.ErrorCode in project openolat by klemens.
the class ViteroManager method updateVmsUser.
protected boolean updateVmsUser(Identity identity, int vmsUserId) throws VmsNotAvailableException {
try {
UpdateUserRequest updateRequest = new UpdateUserRequest();
Completeusertype user = new Completeusertype();
user.setId(vmsUserId);
// mandatory
User olatUser = identity.getUser();
user.setUsername("olat." + WebappHelper.getInstanceId() + "." + identity.getName());
user.setSurname(olatUser.getProperty(UserConstants.LASTNAME, null));
user.setFirstname(olatUser.getProperty(UserConstants.FIRSTNAME, null));
user.setEmail(olatUser.getProperty(UserConstants.EMAIL, null));
// optional
String language = identity.getUser().getPreferences().getLanguage();
if (StringHelper.containsNonWhitespace(language) && language.startsWith("de")) {
user.setLocale("de_DE");
} else if (StringHelper.containsNonWhitespace(language) && language.startsWith("fr")) {
user.setLocale("fr_FR");
} else if (StringHelper.containsNonWhitespace(language) && language.startsWith("zh_CN")) {
user.setLocale("zh_CN");
} else {
user.setLocale("en_GB");
}
user.setPcstate("NOT_TESTED");
user.setTimezone(viteroModule.getTimeZoneId());
String street = olatUser.getProperty(UserConstants.STREET, null);
if (StringHelper.containsNonWhitespace(street)) {
user.setStreet(street);
}
String zip = olatUser.getProperty(UserConstants.ZIPCODE, null);
if (StringHelper.containsNonWhitespace(zip)) {
user.setZip(zip);
}
String city = olatUser.getProperty(UserConstants.CITY, null);
if (StringHelper.containsNonWhitespace(city)) {
user.setCity(city);
}
String country = olatUser.getProperty(UserConstants.COUNTRY, null);
if (StringHelper.containsNonWhitespace(country)) {
user.setCountry(country);
}
String mobile = olatUser.getProperty(UserConstants.TELMOBILE, null);
if (StringHelper.containsNonWhitespace(mobile)) {
user.setMobile(mobile);
}
String phonePrivate = olatUser.getProperty(UserConstants.TELPRIVATE, null);
if (StringHelper.containsNonWhitespace(phonePrivate)) {
user.setPhone(phonePrivate);
}
String phoneOffice = olatUser.getProperty(UserConstants.TELOFFICE, null);
if (StringHelper.containsNonWhitespace(phoneOffice)) {
user.setPhone(phoneOffice);
}
String institution = olatUser.getProperty(UserConstants.INSTITUTIONALNAME, null);
if (StringHelper.containsNonWhitespace(institution)) {
user.setCompany(institution);
}
updateRequest.setUser(user);
getUserWebService().updateUser(updateRequest);
return true;
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
default:
logAxisError("Cannot create vms user.", f);
}
return true;
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot create vms user.", e);
return true;
}
}
use of org.olat.modules.vitero.model.ErrorCode in project openolat by klemens.
the class ViteroManager method getVmsBookingById.
private Bookingtype getVmsBookingById(int id) throws VmsNotAvailableException {
if (id < 0)
return null;
try {
Bookingid bookingId = new Bookingid();
bookingId.setBookingid(id);
Bookingtype booking = getBookingWebService().getBookingById(bookingId);
return booking;
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
case invalidAttribut:
log.error("ids <= 0", f);
break;
case bookingDoesntExist:
log.error("The booking does not exist", f);
break;
default:
logAxisError("Cannot get booking by id: " + id, f);
}
return null;
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot get booking by id: " + id, e);
return null;
}
}
use of org.olat.modules.vitero.model.ErrorCode in project openolat by klemens.
the class ViteroManager method getCustomersUsers.
public List<Usertype> getCustomersUsers() throws VmsNotAvailableException {
try {
GetUserListByCustomerRequest listRequest = new GetUserListByCustomerRequest();
listRequest.setCustomerid(viteroModule.getCustomerId());
Userlist userList = getUserWebService().getUserListByCustomer(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 of customer: " + viteroModule.getCustomerId(), f);
}
return null;
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot get the list of users of customer: " + viteroModule.getCustomerId(), e);
return null;
}
}
use of org.olat.modules.vitero.model.ErrorCode in project openolat by klemens.
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 klemens.
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