List of usage examples for javax.xml.ws WebServiceException getCause
public synchronized Throwable getCause()
From source file:org.marketcetera.marketdata.core.webservice.impl.MarketDataServiceClientImpl.java
@Override public synchronized void start() { Validate.notNull(hostname);/*from w w w.jav a 2 s.c om*/ Validate.notNull(username); Validate.notNull(password); Validate.isTrue(port > 0); serviceClient = new Client(hostname, port, APP_ID, contextClassProvider); try { serviceClient.login(username, password.toCharArray()); } catch (WebServiceException e) { if (e.getCause() != null && e.getCause() instanceof ConnectException) { throw new ConnectionException(hostname, port); } } catch (RemoteException e) { throw new CredentialsException(username); } catch (Exception e) { SLF4JLoggerProxy.warn(this, e); throw new RuntimeException(e); } marketDataService = serviceClient.getService(MarketDataService.class); // do one test heartbeat to catch a bad (lazy-loaded) connection exception here try { marketDataService.heartbeat(serviceClient.getContext()); } catch (RemoteException | WebServiceException e) { if (e.getCause() != null) { if (e.getCause() instanceof java.net.UnknownHostException) { throw new UnknownHostException(hostname, port); } } throw new RuntimeException(e); } heartbeatToken = heartbeatExecutor.scheduleAtFixedRate(new Runnable() { @Override public void run() { try { marketDataService.heartbeat(serviceClient.getContext()); } catch (Exception e) { heartbeatError(e); } } }, heartbeatInterval, heartbeatInterval, TimeUnit.MILLISECONDS); running.set(true); }
From source file:org.olat.modules.vitero.manager.ViteroManager.java
public List<ViteroBooking> getBookingByDate(Date start, Date end) throws VmsNotAvailableException { try {/*from w w w .ja v a 2 s . c o m*/ Booking bookingWs = getBookingWebService(); GetBookingListByDateRequest dateRequest = new GetBookingListByDateRequest(); dateRequest.setStart(format(start)); dateRequest.setEnd(format(end)); dateRequest.setTimezone(viteroModule.getTimeZoneId()); dateRequest.setCustomerid(viteroModule.getCustomerId()); Bookinglist bookingList = bookingWs.getBookingListByDate(dateRequest); List<Booking_Type> bookings = bookingList.getBooking(); return convert(bookings); } catch (SOAPFaultException f) { ErrorCode code = handleAxisFault(f); switch (code) { default: logAxisError("Cannot get the list of bookings by date.", f); } return Collections.emptyList(); } catch (WebServiceException e) { if (e.getCause() instanceof ConnectException) { throw new VmsNotAvailableException(); } return Collections.emptyList(); } }
From source file:org.olat.modules.vitero.manager.ViteroManager.java
public ViteroGroupRoles getGroupRoles(int id) throws VmsNotAvailableException { try {/*from w w w . jav a 2 s. co m*/ 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); } } } 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; } }
From source file:org.olat.modules.vitero.manager.ViteroManager.java
public List<Usertype> getCustomersUsers() throws VmsNotAvailableException { try {/* w w w . j a va 2 s . c om*/ 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(); } logError("Cannot get the list of users of customer: " + viteroModule.getCustomerId(), e); return null; } }
From source file:org.olat.modules.vitero.manager.ViteroManager.java
protected List<Usertype> getVmsUsersByGroup(int groupId) throws VmsNotAvailableException { try {//from w w w . j ava2s. com 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(); } logError("Cannot get the list of users in group: " + groupId, e); return null; } }
From source file:org.olat.modules.vitero.manager.ViteroManager.java
protected boolean updateVmsUser(Identity identity, int vmsUserId) throws VmsNotAvailableException { try {//from ww w .j a v a2 s . com 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"); } else { user.setLocale("en"); } 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(); } logError("Cannot create vms user.", e); return true; } }
From source file:org.olat.modules.vitero.manager.ViteroManager.java
private final int createVmsUser(Identity identity) throws VmsNotAvailableException { String username = null;//from ww w . j a v a 2s . co m try { CreateUserRequest createRequest = new CreateUserRequest(); Newusertype user = new Newusertype(); //mandatory User olatUser = identity.getUser(); username = "olat." + WebappHelper.getInstanceId() + "." + identity.getName(); user.setUsername(username); user.setSurname(olatUser.getProperty(UserConstants.LASTNAME, null)); user.setFirstname(olatUser.getProperty(UserConstants.FIRSTNAME, null)); user.setEmail(olatUser.getProperty(UserConstants.EMAIL, null)); user.setPassword("changeme"); int customerId = viteroModule.getCustomerId(); user.getCustomeridlist().add(new Integer(customerId)); //optional String language = identity.getUser().getPreferences().getLanguage(); if (StringHelper.containsNonWhitespace(language) && language.startsWith("de")) { user.setLocale("de"); } else { user.setLocale("en"); } 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); } /* user.setTitle(""); */ user.setTechnicalnote("Generated by OpenOLAT"); createRequest.setUser(user); Userid userId = getUserWebService().createUser(createRequest); storePortrait(identity, userId.getUserid()); return userId.getUserid(); } catch (SOAPFaultException f) { ErrorCode code = handleAxisFault(f); switch (code) { default: logAxisError("Cannot create vms user.", f); } return -1; } catch (WebServiceException e) { if (e.getCause() instanceof ConnectException) { throw new VmsNotAvailableException(); } logError("Cannot create vms user.", e); return -1; } }
From source file:org.olat.modules.vitero.manager.ViteroManager.java
protected boolean storePortrait(Identity identity, int userId) throws VmsNotAvailableException { try {//w w w .ja v a 2 s. c o m 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(); } logError("Cannot store the portrait of " + userId, e); return false; } }
From source file:org.olat.modules.vitero.manager.ViteroManager.java
protected void deleteVmsUser(int userId) throws VmsNotAvailableException { try {/* w w w. j a v a 2 s .co m*/ Userid userIdType = new Userid(); userIdType.setUserid(userId); getUserWebService().deleteUser(userIdType); } catch (SOAPFaultException f) { ErrorCode code = handleAxisFault(f); switch (code) { default: logAxisError("Cannot delete vms user: " + userId, f); } } catch (WebServiceException e) { if (e.getCause() instanceof ConnectException) { throw new VmsNotAvailableException(); } logError("Cannot delete vms user: " + userId, e); } }
From source file:org.olat.modules.vitero.manager.ViteroManager.java
public List<Integer> getLicencedRoomSizes() throws VmsNotAvailableException { List<Integer> roomSizes = new ArrayList<Integer>(); try {/*w w w . j a v a2 s. co m*/ 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: logError("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(); } logError("Cannot get licence for customer: " + viteroModule.getCustomerId(), e); } return roomSizes; }