List of usage examples for java.net ConnectException getMessage
public String getMessage()
From source file:com.cws.esolutions.security.dao.usermgmt.impl.LDAPUserManager.java
/** * @see com.cws.esolutions.security.dao.usermgmt.interfaces.UserManager#addUserAccount(java.util.List, java.util.List) *//*from w ww . j av a 2 s. c om*/ public synchronized boolean addUserAccount(final List<String> userAccount, final List<String> roles) throws UserManagementException { final String methodName = LDAPUserManager.CNAME + "#addUserAccount(final List<String> userAccount, final List<String> roles) throws UserManagementException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", userAccount); DEBUGGER.debug("Value: {}", roles); } boolean isUserCreated = false; LDAPConnection ldapConn = null; LDAPConnectionPool ldapPool = null; try { final StringBuilder userDN = new StringBuilder() .append(userAttributes.getUserId() + "=" + userAccount.get(0) + ",") .append(repoConfig.getRepositoryUserBase() + "," + repoConfig.getRepositoryBaseDN()); if (DEBUG) { DEBUGGER.debug("StringBuilder: {}", userDN); } ldapPool = (LDAPConnectionPool) svcBean.getAuthDataSource(); if (DEBUG) { DEBUGGER.debug("LDAPConnectionPool: {}", ldapPool); } if (ldapPool.isClosed()) { throw new ConnectException("Failed to create LDAP connection using the specified information"); } ldapConn = ldapPool.getConnection(); if (DEBUG) { DEBUGGER.debug("LDAPConnection: {}", ldapConn); } if (!(ldapConn.isConnected())) { throw new ConnectException("Failed to create LDAP connection using the specified information"); } // have a connection, create the user List<Attribute> newAttributes = new ArrayList<Attribute>( Arrays.asList(new Attribute("objectClass", repoConfig.getBaseObject()), new Attribute(userAttributes.getCommonName(), userAccount.get(0)), new Attribute(userAttributes.getUserId(), userAccount.get(1)), new Attribute(userAttributes.getEmailAddr(), userAccount.get(2)), new Attribute(userAttributes.getGivenName(), userAccount.get(3)), new Attribute(userAttributes.getSurname(), userAccount.get(4)), new Attribute(userAttributes.getDisplayName(), userAccount.get(3) + " " + userAccount.get(4)), new Attribute(securityAttributes.getIsSuspended(), userAccount.get(5)), new Attribute(securityAttributes.getLockCount(), "0"), new Attribute(securityAttributes.getExpiryDate(), new Date().toString()))); if (DEBUG) { DEBUGGER.debug("List<Attribute>: {}", newAttributes); } AddRequest addRequest = new AddRequest(userDN.toString(), newAttributes); LDAPResult ldapResult = ldapConn.add(addRequest); if (DEBUG) { DEBUGGER.debug("LDAPResult: {}", ldapResult); } if (ldapResult.getResultCode() == ResultCode.SUCCESS) { for (String role : roles) { if (DEBUG) { DEBUGGER.debug("String: {}", role); } StringBuilder roleDN = new StringBuilder().append("cn=" + role) .append(repoConfig.getRepositoryRoleBase()); if (DEBUG) { DEBUGGER.debug("StringBuilder: {}", roleDN); } AddRequest addToGroup = new AddRequest(roleDN.toString(), new ArrayList<Attribute>(Arrays.asList(new Attribute("objectClass", "uniqueMember"), new Attribute("uniqueMember", userDN.toString())))); if (DEBUG) { DEBUGGER.debug("AddRequest: {}", addToGroup); } LDAPResult addToGroupResult = ldapConn.add(addToGroup); if (DEBUG) { DEBUGGER.debug("LDAPResult: {}", addToGroupResult); } if (addToGroupResult.getResultCode() != ResultCode.SUCCESS) { throw new UserManagementException("Failed to add user to group: " + role); } } return true; } } catch (ConnectException cx) { throw new UserManagementException(cx.getMessage(), cx); } catch (LDAPException lx) { throw new UserManagementException(lx.getMessage(), lx); } finally { if ((ldapPool != null) && ((ldapConn != null) && (ldapConn.isConnected()))) { ldapConn.close(); ldapPool.releaseConnection(ldapConn); } } return isUserCreated; }
From source file:com.cws.esolutions.security.dao.usermgmt.impl.LDAPUserManager.java
/** * @see com.cws.esolutions.security.dao.usermgmt.interfaces.UserManager#loadUserAccount(java.lang.String) *//* w w w .j a v a 2 s .c o m*/ public synchronized List<Object> loadUserAccount(final String userGuid) throws UserManagementException { final String methodName = LDAPUserManager.CNAME + "#loadUserAccount(final String userGuid) throws UserManagementException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", userGuid); } LDAPConnection ldapConn = null; List<Object> userAccount = null; LDAPConnectionPool ldapPool = null; try { ldapPool = (LDAPConnectionPool) svcBean.getAuthDataSource(); if (DEBUG) { DEBUGGER.debug("LDAPConnectionPool: {}", ldapPool); } if (ldapPool.isClosed()) { throw new ConnectException("Failed to create LDAP connection using the specified information"); } ldapConn = ldapPool.getConnection(); if (DEBUG) { DEBUGGER.debug("LDAPConnection: {}", ldapConn); } if (!(ldapConn.isConnected())) { throw new ConnectException("Failed to create LDAP connection using the specified information"); } Filter searchFilter = Filter.create("(&(objectClass=" + repoConfig.getBaseObject() + ")" + "(&(" + userAttributes.getCommonName() + "=" + userGuid + ")))"); if (DEBUG) { DEBUGGER.debug("searchFilter: {}", searchFilter); } SearchRequest searchRequest = new SearchRequest( repoConfig.getRepositoryUserBase() + "," + repoConfig.getRepositoryBaseDN(), SearchScope.SUB, searchFilter); if (DEBUG) { DEBUGGER.debug("searchRequest: {}", searchRequest); } SearchResult searchResult = ldapConn.search(searchRequest); if (DEBUG) { DEBUGGER.debug("searchResult: {}", searchResult); } if (searchResult.getResultCode() == ResultCode.SUCCESS) { if (searchResult.getEntryCount() == 1) { SearchResultEntry entry = searchResult.getSearchEntries().get(0); if (DEBUG) { DEBUGGER.debug("SearchResultEntry: {}", entry); } userAccount = new ArrayList<Object>(); for (String returningAttribute : userAttributes.getReturningAttributes()) { if (DEBUG) { DEBUGGER.debug("returningAttribute: {}", returningAttribute); } if (entry.hasAttribute(returningAttribute)) { userAccount.add(entry.getAttributeValue(returningAttribute)); } } if (DEBUG) { DEBUGGER.debug("userAccount: {}", userAccount); } if (StringUtils.isNotBlank(userAttributes.getMemberOf())) { Filter roleFilter = Filter.create( "(&(objectClass=groupOfUniqueNames)" + "(&(uniqueMember=" + entry.getDN() + ")))"); if (DEBUG) { DEBUGGER.debug("SearchFilter: {}", roleFilter); } SearchRequest roleSearch = new SearchRequest(repoConfig.getRepositoryRoleBase(), SearchScope.SUB, roleFilter, userAttributes.getCommonName()); if (DEBUG) { DEBUGGER.debug("SearchRequest: {}", roleSearch); } SearchResult roleResult = ldapConn.search(roleSearch); if (DEBUG) { DEBUGGER.debug("searchResult: {}", roleResult); } if ((roleResult.getResultCode() == ResultCode.SUCCESS) && (roleResult.getEntryCount() != 0)) { List<String> roles = new ArrayList<String>(); for (SearchResultEntry role : roleResult.getSearchEntries()) { if (DEBUG) { DEBUGGER.debug("SearchResultEntry: {}", role); } roles.add(role.getAttributeValue(userAttributes.getCommonName())); } userAccount.add(roles); } } if (DEBUG) { DEBUGGER.debug("UserAccount: {}", userAccount); } } else { throw new UserManagementException("Multiple users were located for the provided information"); } } else { throw new UserManagementException("Search request failed: " + searchResult.getResultCode()); } } catch (LDAPException lx) { throw new UserManagementException(lx.getMessage(), lx); } catch (ConnectException cx) { throw new UserManagementException(cx.getMessage(), cx); } finally { if ((ldapPool != null) && ((ldapConn != null) && (ldapConn.isConnected()))) { ldapConn.close(); ldapPool.releaseConnection(ldapConn); } } return userAccount; }
From source file:org.methodize.nntprss.feed.Channel.java
/** * Retrieves the latest RSS doc from the remote site *//*from ww w . j a v a 2s .co m*/ public synchronized void poll() { // Use method-level variable // Guard against change in history mid-poll polling = true; // boolean keepHistory = historical; long keepExpiration = expiration; lastPolled = new Date(); int statusCode = -1; HttpMethod method = null; String urlString = url.toString(); try { HttpClient httpClient = getHttpClient(); channelManager.configureHttpClient(httpClient); HttpResult result = null; try { connected = true; boolean redirected = false; int count = 0; do { URL currentUrl = new URL(urlString); method = new GetMethod(urlString); method.setRequestHeader("User-agent", AppConstants.getUserAgent()); method.setRequestHeader("Accept-Encoding", "gzip"); method.setFollowRedirects(false); method.setDoAuthentication(true); // ETag if (lastETag != null) { method.setRequestHeader("If-None-Match", lastETag); } // Last Modified if (lastModified != 0) { final String NAME = "If-Modified-Since"; //defend against such fun like net.freeroller.rickard got If-Modified-Since "Thu, 24 Aug 2028 12:29:54 GMT" if (lastModified < System.currentTimeMillis()) { final String DATE = httpDate.format(new Date(lastModified)); method.setRequestHeader(NAME, DATE); log.debug("channel " + this.name + " using " + NAME + " " + DATE); //ALEK } } method.setFollowRedirects(false); method.setDoAuthentication(true); HostConfiguration hostConfig = new HostConfiguration(); hostConfig.setHost(currentUrl.getHost(), currentUrl.getPort(), currentUrl.getProtocol()); result = executeHttpRequest(httpClient, hostConfig, method); statusCode = result.getStatusCode(); if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY || statusCode == HttpStatus.SC_SEE_OTHER || statusCode == HttpStatus.SC_TEMPORARY_REDIRECT) { redirected = true; // Resolve against current URI - may be a relative URI try { urlString = new java.net.URI(urlString).resolve(result.getLocation()).toString(); } catch (URISyntaxException use) { // Fall back to just using location from result urlString = result.getLocation(); } if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY && channelManager.isObserveHttp301()) { try { url = new URL(urlString); if (log.isInfoEnabled()) { log.info("Channel = " + this.name + ", updated URL from HTTP Permanent Redirect"); } } catch (MalformedURLException mue) { // Ignore URL permanent redirect for now... } } } else { redirected = false; } // method.getResponseBody(); // method.releaseConnection(); count++; } while (count < 5 && redirected); } catch (HttpRecoverableException hre) { if (log.isDebugEnabled()) { log.debug("Channel=" + name + " - Temporary Http Problem - " + hre.getMessage()); } status = STATUS_CONNECTION_TIMEOUT; statusCode = HttpStatus.SC_INTERNAL_SERVER_ERROR; } catch (ConnectException ce) { // @TODO Might also be a connection refused - not only a timeout... if (log.isDebugEnabled()) { log.debug("Channel=" + name + " - Connection Timeout, skipping - " + ce.getMessage()); } status = STATUS_CONNECTION_TIMEOUT; statusCode = HttpStatus.SC_INTERNAL_SERVER_ERROR; } catch (UnknownHostException ue) { if (log.isDebugEnabled()) { log.debug("Channel=" + name + " - Unknown Host Exception, skipping"); } status = STATUS_UNKNOWN_HOST; statusCode = HttpStatus.SC_INTERNAL_SERVER_ERROR; } catch (NoRouteToHostException re) { if (log.isDebugEnabled()) { log.debug("Channel=" + name + " - No Route To Host Exception, skipping"); } status = STATUS_NO_ROUTE_TO_HOST; statusCode = HttpStatus.SC_INTERNAL_SERVER_ERROR; } catch (SocketException se) { // e.g. Network is unreachable if (log.isDebugEnabled()) { log.debug("Channel=" + name + " - Socket Exception, skipping"); } status = STATUS_SOCKET_EXCEPTION; statusCode = HttpStatus.SC_INTERNAL_SERVER_ERROR; } // Only process if ok - if not ok (e.g. not modified), don't do anything if (connected && statusCode == HttpStatus.SC_OK) { PushbackInputStream pbis = new PushbackInputStream(new ByteArrayInputStream(result.getResponse()), PUSHBACK_BUFFER_SIZE); skipBOM(pbis); BufferedInputStream bis = new BufferedInputStream(pbis); DocumentBuilder db = AppConstants.newDocumentBuilder(); try { Document rssDoc = null; if (!parseAtAllCost) { try { rssDoc = db.parse(bis); } catch (InternalError ie) { // Crimson library throws InternalErrors if (log.isDebugEnabled()) { log.debug("InternalError thrown by Crimson", ie); } throw new SAXException("InternalError thrown by Crimson: " + ie.getMessage()); } } else { // Parse-at-all-costs selected // Read in document to local array - may need to parse twice ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] buf = new byte[1024]; int bytesRead = bis.read(buf); while (bytesRead > -1) { if (bytesRead > 0) { bos.write(buf, 0, bytesRead); } bytesRead = bis.read(buf); } bos.flush(); bos.close(); byte[] rssDocBytes = bos.toByteArray(); try { // Try the XML document parser first - just in case // the doc is well-formed rssDoc = db.parse(new ByteArrayInputStream(rssDocBytes)); } catch (SAXParseException spe) { if (log.isDebugEnabled()) { log.debug("XML parse failed, trying tidy"); } // Fallback to parse-at-all-costs parser rssDoc = LooseParser.parse(new ByteArrayInputStream(rssDocBytes)); } } processChannelDocument(expiration, rssDoc); // Update last modified / etag from headers // lastETag = httpCon.getHeaderField("ETag"); // lastModified = httpCon.getHeaderFieldDate("Last-Modified", 0); Header hdrETag = method.getResponseHeader("ETag"); lastETag = hdrETag != null ? hdrETag.getValue() : null; Header hdrLastModified = method.getResponseHeader("Last-Modified"); lastModified = hdrLastModified != null ? parseHttpDate(hdrLastModified.getValue()) : 0; log.debug("channel " + this.name + " parsed Last-Modifed " + hdrLastModified + " to " + (lastModified != 0 ? "" + (new Date(lastModified)) : "" + lastModified)); //ALEK status = STATUS_OK; } catch (SAXParseException spe) { if (log.isEnabledFor(Priority.WARN)) { log.warn("Channel=" + name + " - Error parsing RSS document - check feed"); } status = STATUS_INVALID_CONTENT; } bis.close(); // end if response code == HTTP_OK } else if (connected && statusCode == HttpStatus.SC_NOT_MODIFIED) { if (log.isDebugEnabled()) { log.debug("Channel=" + name + " - HTTP_NOT_MODIFIED, skipping"); } status = STATUS_OK; } else if (statusCode == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) { if (log.isEnabledFor(Priority.WARN)) { log.warn("Channel=" + name + " - Proxy authentication required"); } status = STATUS_PROXY_AUTHENTICATION_REQUIRED; } else if (statusCode == HttpStatus.SC_UNAUTHORIZED) { if (log.isEnabledFor(Priority.WARN)) { log.warn("Channel=" + name + " - Authentication required"); } status = STATUS_USER_AUTHENTICATION_REQUIRED; } // Update channel in database... channelDAO.updateChannel(this); } catch (FileNotFoundException fnfe) { if (log.isEnabledFor(Priority.WARN)) { log.warn("Channel=" + name + " - File not found returned by web server - check feed"); } status = STATUS_NOT_FOUND; } catch (Exception e) { if (log.isEnabledFor(Priority.WARN)) { log.warn("Channel=" + name + " - Exception while polling channel", e); } } catch (NoClassDefFoundError ncdf) { // Throw if SSL / redirection to HTTPS if (log.isEnabledFor(Priority.WARN)) { log.warn("Channel=" + name + " - NoClassDefFound", ncdf); } } finally { connected = false; polling = false; } }
From source file:com.evolveum.icf.dummy.connector.DummyConnector.java
private ConnectorObject convertToConnectorObject(DummyAccount account, Collection<String> attributesToGet) { DummyObjectClass objectClass;/* ww w . j a va2 s .c o m*/ try { objectClass = resource.getAccountObjectClass(); } catch (ConnectException e) { log.error(e, e.getMessage()); throw new ConnectionFailedException(e.getMessage(), e); } catch (FileNotFoundException e) { log.error(e, e.getMessage()); throw new ConnectorIOException(e.getMessage(), e); } ConnectorObjectBuilder builder = createConnectorObjectBuilderCommon(account, objectClass, attributesToGet, true); builder.setObjectClass(ObjectClass.ACCOUNT); // Password is not returned by default (hardcoded ICF specification) if (account.getPassword() != null && configuration.getReadablePassword() && attributesToGet != null && attributesToGet.contains(OperationalAttributes.PASSWORD_NAME)) { GuardedString gs = new GuardedString(account.getPassword().toCharArray()); builder.addAttribute(OperationalAttributes.PASSWORD_NAME, gs); } if (account.isLockout() != null) { builder.addAttribute(OperationalAttributes.LOCK_OUT_NAME, account.isLockout()); } return builder.build(); }
From source file:com.evolveum.icf.dummy.connector.DummyConnector.java
private ObjectClassInfo createAccountObjectClass(boolean supportsActivation) { // __ACCOUNT__ objectclass DummyObjectClass dummyAccountObjectClass; try {/*from w w w . ja va 2 s . co m*/ dummyAccountObjectClass = resource.getAccountObjectClass(); } catch (ConnectException e) { throw new ConnectionFailedException(e.getMessage(), e); } catch (FileNotFoundException e) { throw new ConnectorIOException(e.getMessage(), e); } catch (IllegalArgumentException e) { throw new ConnectorException(e.getMessage(), e); } // DO NOT catch IllegalStateException, let it pass ObjectClassInfoBuilder objClassBuilder = createCommonObjectClassBuilder(getAccountObjectClassName(), dummyAccountObjectClass, supportsActivation); // __PASSWORD__ attribute objClassBuilder.addAttributeInfo(OperationalAttributeInfos.PASSWORD); return objClassBuilder.build(); }
From source file:com.evolveum.icf.dummy.connector.DummyConnector.java
/** * {@inheritDoc}/* www . j a va 2s . c o m*/ */ public void executeQuery(ObjectClass objectClass, Filter query, ResultsHandler handler, OperationOptions options) { log.info("executeQuery({0},{1},{2},{3})", objectClass, query, handler, options); validate(objectClass); notNull(handler, "Results handled object can't be null."); Collection<String> attributesToGet = getAttrsToGet(options); log.ok("attributesToGet={0}", attributesToGet); try { if (ObjectClass.ACCOUNT.is(objectClass.getObjectClassValue())) { Collection<DummyAccount> accounts = resource.listAccounts(); for (DummyAccount account : accounts) { ConnectorObject co = convertToConnectorObject(account, attributesToGet); if (matches(query, co)) { co = filterOutAttributesToGet(co, attributesToGet); handler.handle(co); } } } else if (ObjectClass.GROUP.is(objectClass.getObjectClassValue())) { Collection<DummyGroup> groups = resource.listGroups(); for (DummyGroup group : groups) { ConnectorObject co = convertToConnectorObject(group, attributesToGet); if (matches(query, co)) { if (attributesToGetHasAttribute(attributesToGet, DummyGroup.ATTR_MEMBERS_NAME)) { resource.recordGroupMembersReadCount(); } co = filterOutAttributesToGet(co, attributesToGet); handler.handle(co); } } } else if (objectClass.is(OBJECTCLASS_PRIVILEGE_NAME)) { Collection<DummyPrivilege> privs = resource.listPrivileges(); for (DummyPrivilege priv : privs) { ConnectorObject co = convertToConnectorObject(priv, attributesToGet); if (matches(query, co)) { co = filterOutAttributesToGet(co, attributesToGet); handler.handle(co); } } } else { throw new ConnectorException("Unknown object class " + objectClass); } } catch (ConnectException e) { log.info("executeQuery::exception " + e); throw new ConnectionFailedException(e.getMessage(), e); } catch (FileNotFoundException e) { log.info("executeQuery::exception " + e); throw new ConnectorIOException(e.getMessage(), e); } log.info("executeQuery::end"); }
From source file:com.evolveum.icf.dummy.connector.DummyConnector.java
/** * {@inheritDoc}/*from www . ja v a2s . c o m*/ */ public void sync(ObjectClass objectClass, SyncToken token, SyncResultsHandler handler, final OperationOptions options) { log.info("sync::begin"); validate(objectClass); Collection<String> attributesToGet = getAttrsToGet(options); try { int syncToken = (Integer) token.getValue(); List<DummyDelta> deltas = resource.getDeltasSince(syncToken); for (DummyDelta delta : deltas) { Class<? extends DummyObject> deltaObjectClass = delta.getObjectClass(); if (objectClass.is(ObjectClass.ALL_NAME)) { // take all changes } else if (objectClass.is(ObjectClass.ACCOUNT_NAME)) { if (deltaObjectClass != DummyAccount.class) { log.ok("Skipping delta {0} because of objectclass mismatch", delta); continue; } } else if (objectClass.is(ObjectClass.GROUP_NAME)) { if (deltaObjectClass != DummyGroup.class) { log.ok("Skipping delta {0} because of objectclass mismatch", delta); continue; } } SyncDeltaBuilder deltaBuilder = new SyncDeltaBuilder(); if (deltaObjectClass == DummyAccount.class) { deltaBuilder.setObjectClass(ObjectClass.ACCOUNT); } else if (deltaObjectClass == DummyGroup.class) { deltaBuilder.setObjectClass(ObjectClass.GROUP); } else if (deltaObjectClass == DummyPrivilege.class) { deltaBuilder.setObjectClass(new ObjectClass(OBJECTCLASS_PRIVILEGE_NAME)); } else { throw new IllegalArgumentException("Unknown delta objectClass " + deltaObjectClass); } SyncDeltaType deltaType; if (delta.getType() == DummyDeltaType.ADD || delta.getType() == DummyDeltaType.MODIFY) { if (resource.getSyncStyle() == DummySyncStyle.DUMB) { deltaType = SyncDeltaType.CREATE_OR_UPDATE; } else { if (delta.getType() == DummyDeltaType.ADD) { deltaType = SyncDeltaType.CREATE; } else { deltaType = SyncDeltaType.UPDATE; } } if (deltaObjectClass == DummyAccount.class) { DummyAccount account = resource.getAccountById(delta.getObjectId()); if (account == null) { throw new IllegalStateException("We have delta for account '" + delta.getObjectId() + "' but such account does not exist"); } ConnectorObject cobject = convertToConnectorObject(account, attributesToGet); deltaBuilder.setObject(cobject); } else if (deltaObjectClass == DummyGroup.class) { DummyGroup group = resource.getGroupById(delta.getObjectId()); if (group == null) { throw new IllegalStateException("We have delta for group '" + delta.getObjectId() + "' but such group does not exist"); } ConnectorObject cobject = convertToConnectorObject(group, attributesToGet); deltaBuilder.setObject(cobject); } else if (deltaObjectClass == DummyPrivilege.class) { DummyPrivilege privilege = resource.getPrivilegeById(delta.getObjectId()); if (privilege == null) { throw new IllegalStateException("We have privilege for group '" + delta.getObjectId() + "' but such privilege does not exist"); } ConnectorObject cobject = convertToConnectorObject(privilege, attributesToGet); deltaBuilder.setObject(cobject); } else { throw new IllegalArgumentException("Unknown delta objectClass " + deltaObjectClass); } } else if (delta.getType() == DummyDeltaType.DELETE) { deltaType = SyncDeltaType.DELETE; } else { throw new IllegalStateException("Unknown delta type " + delta.getType()); } deltaBuilder.setDeltaType(deltaType); deltaBuilder.setToken(new SyncToken(delta.getSyncToken())); Uid uid; if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_NAME)) { uid = new Uid(delta.getObjectName()); } else if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_UUID)) { uid = new Uid(delta.getObjectId()); } else { throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode()); } deltaBuilder.setUid(uid); SyncDelta syncDelta = deltaBuilder.build(); log.info("sync::handle {0}", syncDelta); handler.handle(syncDelta); } } catch (ConnectException e) { log.info("sync::exception " + e); throw new ConnectionFailedException(e.getMessage(), e); } catch (FileNotFoundException e) { log.info("sync::exception " + e); throw new ConnectorIOException(e.getMessage(), e); } log.info("sync::end"); }
From source file:uk.ac.ebi.ontocat.bioportal.BioportalOntologyService.java
/** * Load url./* w ww .j a v a 2 s . c o m*/ * * @return the buffered input stream * @throws OntologyServiceException the ontology service exception */ private BufferedInputStream loadURL() throws OntologyServiceException { for (int i = 0; i < 10; i++) { try { return new BufferedInputStream(queryURL.openStream()); } catch (ConnectException e) { log.warn("Bioportal is timing out on us. Sleep for 5s and repeat"); try { Thread.sleep(5000); } catch (InterruptedException e1) { e1.printStackTrace(); throw new OntologyServiceException(e1); } } catch (FileNotFoundException e) { // no logging as this is expected behaviour for concept not // found and processed accordingly in searchConceptID throw new OntologyServiceException(e); } catch (IOException e) { // less expected usually means an error on BP side // other than response code 400 // or thrown in parents services // alternatively could implement this via // HttpURLConnection.getResponseCode() if (!e.getMessage().contains("HTTP response code: 400") && !e.getMessage().contains("No parents")) { log.error("Possible problems on BioPortal side - " + e + " on " + queryURL.toString()); } throw new OntologyServiceException(e); } } throw new OntologyServiceException("Could not access Bioportal REST services."); }
From source file:com.evolveum.midpoint.model.test.AbstractModelIntegrationTest.java
protected DummyAccount getDummyAccount(String dummyInstanceName, String username) { DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); try {/*ww w .j a va 2 s .c o m*/ return dummyResource.getAccountByUsername(username); } catch (ConnectException e) { throw new IllegalStateException(e.getMessage(), e); } catch (FileNotFoundException e) { throw new IllegalStateException(e.getMessage(), e); } }
From source file:com.evolveum.midpoint.model.test.AbstractModelIntegrationTest.java
protected DummyAccount getDummyAccountById(String dummyInstanceName, String id) { DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); try {/*from w ww . j a va 2s . c o m*/ return dummyResource.getAccountById(id); } catch (ConnectException e) { throw new IllegalStateException(e.getMessage(), e); } catch (FileNotFoundException e) { throw new IllegalStateException(e.getMessage(), e); } }