diff --git a/src/main/java/com/frentix/olat/vitero/manager/ViteroManager.java b/src/main/java/com/frentix/olat/vitero/manager/ViteroManager.java index 1995f9825af0fe54771aae5ad8197adc0acddd04..cfbc74cdeeaeb956566e14b38f55ef655bd6a30b 100644 --- a/src/main/java/com/frentix/olat/vitero/manager/ViteroManager.java +++ b/src/main/java/com/frentix/olat/vitero/manager/ViteroManager.java @@ -77,11 +77,13 @@ import com.frentix.olat.vitero.manager.stubs.UserServiceStub; import com.frentix.olat.vitero.manager.stubs.UserServiceStub.Userid; import com.frentix.olat.vitero.manager.stubs.UserServiceStub.Userlist; import com.frentix.olat.vitero.manager.stubs.UserServiceStub.Usertype; +import com.frentix.olat.vitero.model.ErrorCode; import com.frentix.olat.vitero.model.GroupRole; import com.frentix.olat.vitero.model.ViteroBooking; import com.frentix.olat.vitero.model.ViteroCustomer; import com.frentix.olat.vitero.model.ViteroGroup; import com.frentix.olat.vitero.model.ViteroGroupRoles; +import com.frentix.olat.vitero.model.ViteroStatus; import com.frentix.olat.vitero.model.ViteroUser; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.CompactWriter; @@ -146,7 +148,7 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { Booking[] bookings = bookingList.getBooking(); return convert(bookings); } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { default: logAxisError("Cannot get the list of bookings by date.", f); } @@ -191,7 +193,7 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { CustomerServiceStub.Customertype[] customerTypes = response.getCustomer(); return convert(customerTypes); } catch (AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { default: logAxisError("Cannot get the list of customers.", f); } @@ -213,7 +215,7 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { CustomerServiceStub.Customertype[] customerTypes = response.getCustomer(); return convert(customerTypes); } catch (AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { default: logAxisError("Cannot get the list of customers.", f); } @@ -253,14 +255,14 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { Codetype myCode = response.getCreatePersonalBookingSessionCodeResponse(); return myCode.getCode(); } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { - case 53: logError("User does not exist.", f); break; - case 153: logError("User not assigned to group.", f); break; - case 303: logError("Invalid attribute.", f); break; - case 304: logError("Invalid time zone.", f); break; - case 506: - case 509: logError("Booking does not exist.", f); break; + case userDoesntExist: logError("User does not exist.", f); break; + case userNotAssignedToGroup: logError("User not assigned to group.", f); break; + case invalidAttribut: logError("Invalid attribute.", f); break; + case invalidTimezone: logError("Invalid time zone.", f); break; + case bookingDoesntExist: + case bookingDoesntExistPrime: logError("Booking does not exist.", f); break; default: logAxisError("Cannot create session code.", f); } return null; @@ -311,7 +313,7 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { return groupRoles; } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { default: logAxisError("Cannot get group roles",f); } @@ -338,7 +340,7 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { Usertype[] userTypes = userList.getUser(); return userTypes; } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { default: logAxisError("Cannot get the list of users in group: " + groupId, f); } @@ -426,9 +428,12 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { if(StringHelper.containsNonWhitespace(phoneOffice)) { user.setPhone(phoneOffice); } + String institution = olatUser.getProperty(UserConstants.INSTITUTIONALNAME, null); + if(StringHelper.containsNonWhitespace(institution)) { + user.setCompany(institution); + } /* user.setTitle(""); - user.setCompany(""); */ user.setTechnicalnote("Generated by OpenOLAT"); @@ -439,7 +444,7 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { storePortrait(identity, userId.getUserid()); return userId.getUserid(); } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { default: logAxisError("Cannot create vms user.", f); } @@ -474,7 +479,7 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { } return false; } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { default: logAxisError("Cannot store the portrait of " + userId, f); } @@ -510,7 +515,7 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { userWs.deleteUser(delRequest); } catch (AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { default: logAxisError("Cannot delete vms user: " + userId, f); } @@ -539,9 +544,9 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { } } } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { - case 303: logError("ids <=0 or invalid attributs", f); break; + case invalidAttribut: logError("ids <=0 or invalid attributs", f); break; default: logAxisError("Cannot get licence for customer: " + viteroModule.getCustomerId(), f); } } catch (RemoteException e) { @@ -571,7 +576,7 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { } } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { default: logAxisError("Cannot get licence for available room by dates.", f); } @@ -596,7 +601,7 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { return groupId.getGroupid(); } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { default: logAxisError("Cannot create a group",f); } @@ -622,7 +627,7 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { return convert(groupType); } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { default: logAxisError("Cannot create a group",f); } @@ -644,10 +649,10 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { groupWs.deleteGroup(deleteRequest); return true; } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { - case 151: logError("Group doesn't exist!", f); break; - case 303: logError("Group id <= 0!", f); + case groupDoesntExist: logError("Group doesn't exist!", f); break; + case invalidAttribut: logError("Group id <= 0!", f); default: logAxisError("Cannot delete group: " + vBooking.getGroupId(), f); } return false; @@ -685,12 +690,12 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { return true; } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { - case 53: logError("The user doesn Ìt exist!", f); break; - case 103: logError("The user is not attached to the customer (to which this group belongs)", f); break; - case 151: logError("The group doesn Ìt exist", f); break; - case 303: logError("An id <= 0", f); break; + case userDoesntExist: logError("The user doesn Ìt exist!", f); break; + case userNotAttachedToCustomer: logError("The user is not attached to the customer (to which this group belongs)", f); break; + case groupDoesntExist: logError("The group doesn Ìt exist", f); break; + case invalidAttribut: logError("An id <= 0", f); break; default: logAxisError("Cannot add an user to a group", f); } return false; @@ -712,7 +717,6 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { public boolean removeFromRoom(ViteroBooking booking, int userId) throws VmsNotAvailableException { try { - GroupServiceStub groupWs = getGroupWebService(); GroupServiceStub.RemoveUserFromGroupRequest removeRequest = new GroupServiceStub.RemoveUserFromGroupRequest(); GroupServiceStub.Groupiduserid groupuserId = new GroupServiceStub.Groupiduserid(); @@ -722,11 +726,11 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { groupWs.removeUserFromGroup(removeRequest); return true; } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { - case 53: logError("The user doesn Ìt exist!", f); break; - case 151: logError("The group doesn Ìt exist", f); break; - case 303: logError("An id <= 0", f); break; + case userDoesntExist: logError("The user doesn Ìt exist!", f); break; + case groupDoesntExist: logError("The group doesn Ìt exist", f); break; + case invalidAttribut: logError("An id <= 0", f); break; default: logAxisError("Cannot remove an user from a group", f); } return false; @@ -761,10 +765,10 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { cal.set(Calendar.MILLISECOND, 0); booking.setStart(cal.getTime()); - booking.setStartBuffer(0); + booking.setStartBuffer(15); cal.add(Calendar.HOUR, 1); booking.setEnd(cal.getTime()); - booking.setEndBuffer(0); + booking.setEndBuffer(15); List<Integer> roomSizes = getLicencedRoomSizes(); if(!roomSizes.isEmpty()) { @@ -773,19 +777,19 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { return booking; } - public boolean createBooking(BusinessGroup group, OLATResourceable ores, ViteroBooking vBooking) + public ViteroStatus createBooking(BusinessGroup group, OLATResourceable ores, ViteroBooking vBooking) throws VmsNotAvailableException { Bookingtype booking = getBookingById(vBooking.getBookingId()); if(booking != null) { logInfo("Booking already exists: " + vBooking.getBookingId()); - return true; + return new ViteroStatus(); } try { //a group per meeting int groupId = createGroup(); if(groupId < 0) { - return false; + return new ViteroStatus(ErrorCode.unkown); } vBooking.setGroupId(groupId); @@ -826,26 +830,28 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { boolean moduleCollision = response.getModulecollision(); int bookingId = response.getBookingid(); - if(!bookingCollision && !moduleCollision) { - vBooking.setBookingId(bookingId); - getOrCreateProperty(group, ores, vBooking); - return true; + if(bookingCollision) { + return new ViteroStatus(ErrorCode.bookingCollision); + } else if(moduleCollision) { + return new ViteroStatus(ErrorCode.moduleCollision); } - return false; + vBooking.setBookingId(bookingId); + getOrCreateProperty(group, ores, vBooking); + return new ViteroStatus(); } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { - case 304: logError("Invalid time zone!", f); break; - case 501: logError("Booking collision!", f); break; - case 502: logError("Invalid module selection!", f); break; - case 505: logError("Booking in the past!", f); break; - case 703: logError("License/customer expired!", f); break; + case invalidTimezone: logError("Invalid time zone!", f); break; + case bookingCollision: logError("Booking collision!", f); break; + case moduleCollision: logError("Invalid module selection!", f); break; + case bookingInPast: logError("Booking in the past!", f); break; + case licenseExpired: logError("License/customer expired!", f); break; default: logAxisError("Cannot create a booking.", f); } - return false; + return new ViteroStatus(code); } catch (RemoteException e) { logError("Cannot create a booking.", e); - return false; + return new ViteroStatus(ErrorCode.remoteException); } } @@ -886,10 +892,10 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { deleteProperty(vBooking); return state != null; } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { - case 506: - case 509: { + case bookingDoesntExist: + case bookingDoesntExistPrime: { deleteGroup(vBooking); deleteProperty(vBooking); return true;//ok, vms deleted, group deleted... @@ -990,11 +996,11 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { return bookingList.getBooking(); } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { - case 53: logError("The user does not exist!", f); break; - case 303: logError("ids <= 0!", f); break; - case 304: logError("Invalid time zone!", f); break; + case userDoesntExist: logError("The user does not exist!", f); break; + case invalidAttribut: logError("ids <= 0!", f); break; + case invalidTimezone: logError("Invalid time zone!", f); break; default: logAxisError("Cannot get booking in future for custom: " + userId, f); } return null; @@ -1018,10 +1024,10 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { Bookingtype booking = response.getGetBookingByIdResponse(); return booking; } catch(AxisFault f) { - int code = handleAxisFault(f); + ErrorCode code = handleAxisFault(f); switch(code) { - case 303: logError("ids <= 0", f); break; - case 506: logError("The booking does not exist", f); break; + case invalidAttribut: logError("ids <= 0", f); break; + case bookingDoesntExist: logError("The booking does not exist", f); break; default: logAxisError("Cannot get booking by id: " + id, f); } return null; @@ -1067,7 +1073,7 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { } //Utilities - private final int handleAxisFault(final AxisFault f) + private final ErrorCode handleAxisFault(final AxisFault f) throws VmsNotAvailableException { if(f.getFaultDetailElement() != null) { String msg = f.getFaultDetailElement().toString(); @@ -1075,11 +1081,11 @@ public class ViteroManager extends BasicManager implements UserDataDeletable { int endIndex = msg.indexOf("</errorCode>"); String errorCode = msg.substring(beginIndex + "<errorCode>".length(), endIndex); int code = Integer.parseInt(errorCode); - return code; + return ErrorCode.find(code); } else if (f.getCause() instanceof ConnectTimeoutException) { throw new VmsNotAvailableException(f); } - return -1; + return ErrorCode.unkown; } private void logAxisError(String message, AxisFault f) { diff --git a/src/main/java/com/frentix/olat/vitero/model/ErrorCode.java b/src/main/java/com/frentix/olat/vitero/model/ErrorCode.java new file mode 100644 index 0000000000000000000000000000000000000000..5c3d0f0b7b37ee3436bf83b3919e0216889382a9 --- /dev/null +++ b/src/main/java/com/frentix/olat/vitero/model/ErrorCode.java @@ -0,0 +1,72 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * 12.10.2011 by frentix GmbH, http://www.frentix.com + * <p> + */ +package com.frentix.olat.vitero.model; + +/** + * + * Description:<br> + * + * <P> + * Initial Date: 16 janv. 2012 <br> + * + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + */ +public enum ErrorCode { + remoteException(-2, "error.remoteException"), + unkown(-1, "error.unkown"), + userDoesntExist(53, "error.userDoesntExist"), + userNotAttachedToCustomer(103, "error.userNotAttachedToCustomer"), + groupDoesntExist(151, "error.groupDoesntExist"), + userNotAssignedToGroup(153, "error.userNotAssignedToGroup"), + invalidAttribut(303, "error.invalidAttribut"),//invalid attribute or ids <= 0 + invalidTimezone(304, "error.invalidTimezone"), + bookingCollision(501, "error.bookingCollision"), + moduleCollision(502, "error.moduleCollision"), + bookingInPast(505, "error.bookingInPast"), + bookingDoesntExist(506, "error.bookingDoesntExist"), + bookingDoesntExistPrime(509, "error.bookingDoesntExist"), + licenseExpired(703, "error.licenseExpired"); + + private final int code; + private final String i18nKey; + + private ErrorCode(int code, String i18nKey) { + this.code = code; + this.i18nKey = i18nKey; + } + + public int code() { + return code; + } + + public String i18nKey() { + return i18nKey; + } + + public static ErrorCode find(int code) { + for(ErrorCode error :values()) { + if(error.code() == code) { + return error; + } + } + return unkown; + } + +} diff --git a/src/main/java/com/frentix/olat/vitero/model/ViteroStatus.java b/src/main/java/com/frentix/olat/vitero/model/ViteroStatus.java new file mode 100644 index 0000000000000000000000000000000000000000..ab0da9fba5ebde0643aed4e37d885844bc36c263 --- /dev/null +++ b/src/main/java/com/frentix/olat/vitero/model/ViteroStatus.java @@ -0,0 +1,50 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * 12.10.2011 by frentix GmbH, http://www.frentix.com + * <p> + */ +package com.frentix.olat.vitero.model; + +/** + * + * Description:<br> + * + * <P> + * Initial Date: 16 janv. 2012 <br> + * + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + */ +public class ViteroStatus { + + private final ErrorCode error; + + public ViteroStatus() { + this.error = null; + } + + public ViteroStatus(ErrorCode error) { + this.error = error; + } + + public boolean isOk() { + return error == null; + } + + public ErrorCode getError() { + return error; + } +} diff --git a/src/main/java/com/frentix/olat/vitero/ui/ViteroBookingEditController.java b/src/main/java/com/frentix/olat/vitero/ui/ViteroBookingEditController.java index 4e6cb197f5df0d192f44b7b9112859c7c19bacf6..039076480ea7b8c72987a4684c3fb83fd08c99c6 100644 --- a/src/main/java/com/frentix/olat/vitero/ui/ViteroBookingEditController.java +++ b/src/main/java/com/frentix/olat/vitero/ui/ViteroBookingEditController.java @@ -40,6 +40,7 @@ import org.olat.group.BusinessGroup; import com.frentix.olat.vitero.manager.ViteroManager; import com.frentix.olat.vitero.manager.VmsNotAvailableException; import com.frentix.olat.vitero.model.ViteroBooking; +import com.frentix.olat.vitero.model.ViteroStatus; /** * @@ -231,23 +232,23 @@ public class ViteroBookingEditController extends FormBasicController { if(booking.getBookingId() >= 0) { ViteroBooking updatedBooking = viteroManager.updateBooking(group, ores, booking); if(updatedBooking != null) { - showInfo("check.ok"); + showInfo("booking.ok"); fireEvent(ureq, Event.DONE_EVENT); } else { - showError("check.nok"); + showError("error.unkown"); } } else { - if(viteroManager.createBooking(group, ores, booking)) { - showInfo("check.ok"); + ViteroStatus status = viteroManager.createBooking(group, ores, booking); + if(status.isOk()) { + showInfo("booking.ok"); fireEvent(ureq, Event.DONE_EVENT); } else { - showError("check.nok"); + showError(status.getError().i18nKey()); } } } catch (VmsNotAvailableException e) { showError(VmsNotAvailableException.I18N_KEY); } - } @Override diff --git a/src/main/java/com/frentix/olat/vitero/ui/ViteroBookingsRunController.java b/src/main/java/com/frentix/olat/vitero/ui/ViteroBookingsRunController.java index 2258983a00bd18c1fbacd95ecf321e4a7eb8ddda..222901c32b21259ab0f7d13ed128488393c23816 100644 --- a/src/main/java/com/frentix/olat/vitero/ui/ViteroBookingsRunController.java +++ b/src/main/java/com/frentix/olat/vitero/ui/ViteroBookingsRunController.java @@ -65,7 +65,7 @@ public class ViteroBookingsRunController extends BasicController { this.resourceName = resourceName; if(ureq.getUserSession().getRoles().isGuestOnly()) { - + //no accessible to guests } else if(admin) { mainVC = createVelocityContainer("run_admin"); diff --git a/src/main/java/com/frentix/olat/vitero/ui/ViteroUserToGroupController.java b/src/main/java/com/frentix/olat/vitero/ui/ViteroUserToGroupController.java index 917a5613511d7bd5b75a170012f00d9bb8ced3fa..654030c15ee2a0f8a4ec1065ecb482f28de5df49 100644 --- a/src/main/java/com/frentix/olat/vitero/ui/ViteroUserToGroupController.java +++ b/src/main/java/com/frentix/olat/vitero/ui/ViteroUserToGroupController.java @@ -215,7 +215,7 @@ public class ViteroUserToGroupController extends BasicController { try { ViteroGroupRoles groupRoles = viteroManager.getGroupRoles(booking.getGroupId()); - ResourceMembers members = getIdentitiesInResource(); + ResourceMembers members = getIdentitiesInResource(groupRoles); tableCtr.setTableDataModel(new UserToGroupDataModel(members, groupRoles)); int numOfFreePlaces = booking.getRoomSize() - groupRoles.size(); @@ -225,10 +225,11 @@ public class ViteroUserToGroupController extends BasicController { } } - private ResourceMembers getIdentitiesInResource() { + private ResourceMembers getIdentitiesInResource(ViteroGroupRoles groupRoles) { Set<Identity> owners = new HashSet<Identity>(); Set<Identity> coaches = new HashSet<Identity>(); Set<Identity> participants = new HashSet<Identity>(); + Set<Identity> selfParticipants = new HashSet<Identity>(); if(group != null) { owners.addAll(securityManager.getIdentitiesOfSecurityGroup(group.getOwnerGroup())); @@ -258,27 +259,55 @@ public class ViteroUserToGroupController extends BasicController { coaches.addAll(repoTutors); } } - return new ResourceMembers(owners, coaches, participants); + + //add all self signed participants + if(booking.isAutoSignIn()) { + List<String> emailsOfParticipants = groupRoles.getEmailsOfParticipants(); + //remove owners, coaches and already participating users + for(Identity owner:owners) { + emailsOfParticipants.remove(owner.getUser().getProperty(UserConstants.EMAIL, null)); + } + for(Identity coach:coaches) { + emailsOfParticipants.remove(coach.getUser().getProperty(UserConstants.EMAIL, null)); + } + for(Identity participant:participants) { + emailsOfParticipants.remove(participant.getUser().getProperty(UserConstants.EMAIL, null)); + } + + if(!emailsOfParticipants.isEmpty()) { + List<Identity> selfSignedParticipants = UserManager.getInstance().findIdentitiesByEmail(emailsOfParticipants); + selfParticipants.addAll(selfSignedParticipants); + } + } + return new ResourceMembers(owners, coaches, participants, selfParticipants); } public class ResourceMembers { private final List<Identity> owners = new ArrayList<Identity>(); private final List<Identity> coaches = new ArrayList<Identity>(); private final List<Identity> participants = new ArrayList<Identity>(); + private final List<Identity> selfParticipants = new ArrayList<Identity>(); public ResourceMembers() { // } - public ResourceMembers(Collection<Identity> owners, Collection<Identity> coaches, Collection<Identity> participants) { + public ResourceMembers(Collection<Identity> owners, Collection<Identity> coaches, Collection<Identity> participants, + Collection<Identity> selfParticipants) { this.owners.addAll(owners); this.coaches.addAll(coaches); this.participants.addAll(participants); + this.selfParticipants.addAll(selfParticipants); //remove duplicates coaches.removeAll(owners); + participants.removeAll(owners); participants.removeAll(coaches); + + selfParticipants.remove(owners); + selfParticipants.remove(coaches); + selfParticipants.remove(participants); } public List<Identity> getOwners() { @@ -292,6 +321,10 @@ public class ViteroUserToGroupController extends BasicController { public List<Identity> getParticipants() { return participants; } + + public List<Identity> getSelfParticipants() { + return selfParticipants; + } } public class UserToGroupDataModel implements TableDataModel { @@ -308,6 +341,7 @@ public class ViteroUserToGroupController extends BasicController { identities.addAll(members.getOwners()); identities.addAll(members.getCoaches()); identities.addAll(members.getParticipants()); + identities.addAll(members.getSelfParticipants()); } public ResourceMembers getMembers() { diff --git a/src/main/java/com/frentix/olat/vitero/ui/_i18n/LocalStrings_de.properties b/src/main/java/com/frentix/olat/vitero/ui/_i18n/LocalStrings_de.properties index fe928419b33fda437bd14b32586ba2f25d84bb78..39e6cf9740ba0ac951e9ad3c58796cecbfe0d1ae 100644 --- a/src/main/java/com/frentix/olat/vitero/ui/_i18n/LocalStrings_de.properties +++ b/src/main/java/com/frentix/olat/vitero/ui/_i18n/LocalStrings_de.properties @@ -41,6 +41,7 @@ booking.autoSignIn=Einschreibung durch Benutzer booking.roomSize=Raumgrösse booking.raw=Termin booking.raw.title=Detailinformationen Termin +booking.ok=Termin erfolgreich gespeichert group.id=Gruppenidentifikator group.name=Gruppenname group.numOfParticipants=Teilnehmerzahl @@ -53,8 +54,21 @@ option.baseurl=URL vitero Server option.adminlogin=Web Service Benutzername option.adminpassword=Web Service Passwort option.customerId=Kundenidentifikator +error.remoteException=$\:error.unkown +error.unkown=Ein unerwartended Fehler passiert +error.userDoesntExist=Der Benutzer existiert nicht +error.userNotAttachedToCustomer=Der benutzer gehört nicht zu diesem Customer +error.groupDoesntExist=Die Gruppe existiert nicht +error.userNotAssignedToGroup=Der benutzer ist nicht in der Gruppe +error.invalidAttribut=Ein Attribut ist ungültig +error.invalidTimezone=Time zone ist ungültig +error.bookingCollision=Im gewählten Zeitraum ist keine Buchung möglich. +error.moduleCollision=Der gewählte Module steht nicht zur Verfügung +error.bookingDoesntExist=Das Buchung existiert nicht +error.bookingDoesntExistPrime=$\:error.bookingDoesntExist error.bookingInPast=Der Termin kann sich nicht in der Vergangenheit befinden. error.bookingDatesInverted=Das Datum für das Ende des Termins darf nicht vor dem Beginn Datum sein. +error.licenseExpired=License expired error.vmsNotAvailable=vitero Server ist nicht verfügbar error.url.invalid=Die angegebene vitero Server URL ist nicht gültig error.customer.invalid=Der angegebene Kundenidentifikator ist nicht gültig diff --git a/src/main/java/com/frentix/olat/vitero/ui/_i18n/LocalStrings_en.properties b/src/main/java/com/frentix/olat/vitero/ui/_i18n/LocalStrings_en.properties index 796fdb8a22433ed86f054200c9c1034850436de1..fc8eef775924953cd194369a19e455bfdb5240e1 100644 --- a/src/main/java/com/frentix/olat/vitero/ui/_i18n/LocalStrings_en.properties +++ b/src/main/java/com/frentix/olat/vitero/ui/_i18n/LocalStrings_en.properties @@ -41,6 +41,7 @@ booking.autoSignIn=User can sign in themselves booking.roomSize=Room size booking.raw=Meeting booking.raw.title=Meeting detail information +booking.ok=Meeting successfully saved group.id=Group identifyer group.name=Group name group.numOfParticipants=Booked seats @@ -53,6 +54,18 @@ option.baseurl=URL vitero server option.adminlogin=Web service user name option.adminpassword=Web service password option.customerId=Client identifyer +error.remoteException=$\:error.unkown +error.unkown=An unexpected error occured +error.userDoesntExist=The user does not exist +error.userNotAttachedToCustomer=The user is not attached to the customer +error.groupDoesntExist=The group does not exist +error.userNotAssignedToGroup=The user is not attached to the group +error.invalidAttribut=A value is invalid +error.invalidTimezone=The time zone is invalid +error.bookingCollision=Booking collision +error.moduleCollision=Invalid module selection +error.bookingDoesntExist=The booking does not exist +error.bookingDoesntExistPrime=$\:error.bookingDoesntExist error.bookingInPast=The meeting date can not be in the past. error.bookingDatesInverted=The end date of the meeting must not be before the start date. error.vmsNotAvailable=The vitero server is not available diff --git a/src/main/java/org/olat/core/gui/control/generic/closablewrapper/CloseableModalController.java b/src/main/java/org/olat/core/gui/control/generic/closablewrapper/CloseableModalController.java index cd7240baee166a91dfa5b59656532de2bfbebcdd..a52c43699012d6f5f00658f75880f0deaff7d316 100644 --- a/src/main/java/org/olat/core/gui/control/generic/closablewrapper/CloseableModalController.java +++ b/src/main/java/org/olat/core/gui/control/generic/closablewrapper/CloseableModalController.java @@ -59,8 +59,6 @@ import org.olat.core.util.Util; * * </pre> * - * @deprecated don't use this anymore. Use BasicController methods or - * controllers from org.core.gui.control.modal package */ public class CloseableModalController extends DefaultController { /** diff --git a/src/main/java/org/olat/properties/PropertyManager.java b/src/main/java/org/olat/properties/PropertyManager.java index cec3668891696d495712933c3d390c39cfbff829..616330c44a73b624c0d7139eb6e70e609bf7f7cb 100644 --- a/src/main/java/org/olat/properties/PropertyManager.java +++ b/src/main/java/org/olat/properties/PropertyManager.java @@ -180,7 +180,7 @@ public class PropertyManager extends BasicManager implements UserDataDeletable { * @param name * @return a list of Property objects */ - public List listProperties(Identity identity, BusinessGroup grp, OLATResourceable resourceable, String category, String name) { + public List<Property> listProperties(Identity identity, BusinessGroup grp, OLATResourceable resourceable, String category, String name) { if (resourceable == null) return listProperties(identity, grp, null, null, category, name); else @@ -198,7 +198,7 @@ public class PropertyManager extends BasicManager implements UserDataDeletable { * @param name * @return a list of Property objects */ - public List listProperties(Identity identity, BusinessGroup grp, String resourceTypeName, Long resourceTypeId, String category, String name) { + public List<Property> listProperties(Identity identity, BusinessGroup grp, String resourceTypeName, Long resourceTypeId, String category, String name) { StringBuilder query = new StringBuilder(); ArrayList objs = new ArrayList(); ArrayList types = new ArrayList(); @@ -332,7 +332,7 @@ public class PropertyManager extends BasicManager implements UserDataDeletable { * @param name * @return a list of Property objects. */ - public List findProperties(Identity identity, BusinessGroup grp, OLATResourceable resourceable, String category, String name) { + public List<Property> findProperties(Identity identity, BusinessGroup grp, OLATResourceable resourceable, String category, String name) { if (resourceable == null) return findProperties(identity, grp, null, null, category, name); else @@ -349,7 +349,7 @@ public class PropertyManager extends BasicManager implements UserDataDeletable { * @param name * @return List of properties */ - public List findProperties(Identity identity, BusinessGroup grp, String resourceTypeName, Long resourceTypeId, String category, String name) { + public List<Property> findProperties(Identity identity, BusinessGroup grp, String resourceTypeName, Long resourceTypeId, String category, String name) { StringBuilder query = new StringBuilder(); ArrayList objs = new ArrayList(); ArrayList types = new ArrayList(); @@ -489,7 +489,7 @@ public class PropertyManager extends BasicManager implements UserDataDeletable { */ public Property findProperty(Identity identity, BusinessGroup grp, OLATResourceable resourceable, String category, String name) { - List props = findProperties(identity, grp, resourceable, category, name); + List<Property> props = findProperties(identity, grp, resourceable, category, name); if (props == null || props.size() == 0) { if(Tracing.isDebugEnabled(PropertyManager.class)) Tracing.logDebug("Could not find property: " + name, PropertyManager.class); return null; diff --git a/src/main/java/org/olat/user/UserManager.java b/src/main/java/org/olat/user/UserManager.java index 34c2786931cbcdce331d534372301e7dbf55ee70..2ab1d0a465f8d033e8fc036bb3bf5a1c551dfe5a 100644 --- a/src/main/java/org/olat/user/UserManager.java +++ b/src/main/java/org/olat/user/UserManager.java @@ -96,6 +96,15 @@ public abstract class UserManager extends BasicManager { * @return The identity found for this email or null if not found */ public abstract Identity findIdentityByEmail(String email); + + /** + * Find the identity (and the user) that match the given email address. The + * match is an exact match + * + * @param email A list of emails to search with + * @return The identities found for these emails + */ + public abstract List<Identity> findIdentitiesByEmail(List<String> emails); /** * Find user by its email diff --git a/src/main/java/org/olat/user/UserManagerImpl.java b/src/main/java/org/olat/user/UserManagerImpl.java index feda00e42c7e4a9dacfd19900fc351a117086c3e..38475dded30c37c6d2eeb0bf511bf76be39ab03c 100644 --- a/src/main/java/org/olat/user/UserManagerImpl.java +++ b/src/main/java/org/olat/user/UserManagerImpl.java @@ -20,6 +20,8 @@ package org.olat.user; import java.nio.charset.Charset; +import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -160,6 +162,48 @@ public class UserManagerImpl extends UserManager { } return null; } + + @Override + public List<Identity> findIdentitiesByEmail(List<String> emails) { + for(Iterator<String> emailIt=emails.iterator(); emailIt.hasNext(); ) { + String email = emailIt.next(); + if (!MailHelper.isValidEmailAddress(email)) { + emailIt.remove(); + logWarn("Invalid email address: " + email, null); + } + } + + if(emails.isEmpty()) { + return Collections.emptyList(); + } + + DB db = DBFactory.getInstance(); + StringBuilder sb = new StringBuilder("select identity from ").append(IdentityImpl.class.getName()).append(" identity ") + .append(" inner join identity.user user ") + .append(" where "); + + //search email + StringBuilder emailSb = new StringBuilder(sb); + emailSb.append(" user.properties['").append(UserConstants.EMAIL).append("'] in (:emails) "); + DBQuery emailQuery = db.createQuery(emailSb.toString()); + emailQuery.setParameterList("emails", emails); + List<Identity> identities = emailQuery.list(); + + //search institutional email + StringBuilder institutionalSb = new StringBuilder(sb); + institutionalSb.append(" user.properties['").append(UserConstants.INSTITUTIONALEMAIL).append("'] in (:emails) "); + if(!identities.isEmpty()) { + institutionalSb.append(" and identity not in (:identities) "); + } + DBQuery institutionalQuery = db.createQuery(institutionalSb.toString()); + institutionalQuery.setParameterList("emails", emails); + if(!identities.isEmpty()) { + institutionalQuery.setParameterList("identities", identities); + } + List<Identity> instIdentities = institutionalQuery.list(); + identities.addAll(instIdentities); + return identities; + } /** * @see org.olat.user.UserManager#findUserByEmail(java.lang.String)