use of org.olat.modules.vitero.model.ErrorCode in project OpenOLAT by OpenOLAT.
the class ViteroManager method deleteGroup.
public boolean deleteGroup(ViteroBooking vBooking) throws VmsNotAvailableException {
try {
Groupid groupId = new Groupid();
groupId.setGroupid(vBooking.getGroupId());
getGroupWebService().deleteGroup(groupId);
return true;
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
case groupDoesntExist:
log.error("Group doesn't exist!", f);
break;
case invalidAttribut:
log.error("Group id <= 0!", f);
default:
logAxisError("Cannot delete group: " + vBooking.getGroupId(), f);
}
return false;
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot delete group: " + vBooking.getGroupId(), e);
return false;
}
}
use of org.olat.modules.vitero.model.ErrorCode in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class ViteroManager method createPersonalBookingSessionCode.
/**
* Create a session code with a one hour expiration date
* @param identity
* @param booking
* @return
*/
protected String createPersonalBookingSessionCode(Identity identity, ViteroBooking booking) throws VmsNotAvailableException {
try {
GetUserInfo userInfo = getVmsUserId(identity, true);
int userId = userInfo.getUserId();
// update user information
if (!userInfo.isCreated()) {
try {
updateVmsUser(identity, userId);
storePortrait(identity, userId);
} catch (Exception e) {
log.error("Cannot update user on vitero system:" + identity.getName(), e);
}
}
CreatePersonalBookingSessionCodeRequest.Sessioncode code = new CreatePersonalBookingSessionCodeRequest.Sessioncode();
code.setBookingid(booking.getBookingId());
code.setUserid(userId);
code.setTimezone(viteroModule.getTimeZoneId());
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.HOUR, 1);
code.setExpirationdate(format(cal.getTime()));
CreatePersonalBookingSessionCodeRequest codeRequest = new CreatePersonalBookingSessionCodeRequest();
codeRequest.setSessioncode(code);
Codetype myCode = getSessionCodeWebService().createPersonalBookingSessionCode(codeRequest);
return myCode.getCode();
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
case userDoesntExist:
log.error("User does not exist.", f);
break;
case userNotAssignedToGroup:
log.error("User not assigned to group.", f);
break;
case invalidAttribut:
log.error("Invalid attribute.", f);
break;
case invalidTimezone:
log.error("Invalid time zone.", f);
break;
case bookingDoesntExist:
case bookingDoesntExistPrime:
log.error("Booking does not exist.", f);
break;
default:
logAxisError("Cannot create session code.", f);
}
return null;
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot create session code.", e);
return null;
}
}
use of org.olat.modules.vitero.model.ErrorCode in project OpenOLAT by OpenOLAT.
the class ViteroManager method getLicencedRoomSizes.
public List<Integer> getLicencedRoomSizes() throws VmsNotAvailableException {
List<Integer> roomSizes = new ArrayList<Integer>();
try {
GetModulesForCustomerRequest licenceRequest = new GetModulesForCustomerRequest();
licenceRequest.setCustomerid(viteroModule.getCustomerId());
Modulestype modules = getLicenceWebService().getModulesForCustomer(licenceRequest);
Modules modulesType = modules.getModules();
for (Module module : modulesType.getModule()) {
if ("ROOM".equals(module.getType())) {
Integer roomSize = module.getRoomsize();
if (!roomSizes.contains(roomSize)) {
roomSizes.add(roomSize);
}
}
}
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
case invalidAttribut:
log.error("ids <=0 or invalid attributs", f);
break;
default:
logAxisError("Cannot get licence for customer: " + viteroModule.getCustomerId(), f);
}
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot get licence for customer: " + viteroModule.getCustomerId(), e);
}
return roomSizes;
}
use of org.olat.modules.vitero.model.ErrorCode in project OpenOLAT by OpenOLAT.
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;
}
}
Aggregations