List of usage examples for java.net MalformedURLException toString
public String toString()
From source file:com.dfki.av.sudplan.vis.wiz.DataSourceSelectionPanel.java
public Object getSelectedDataSource() { if (jRadioButton1.isSelected()) { return this.file; } else if (jRadioButton2.isSelected()) { try {//from w w w. j a v a2 s . com this.url = new URL(this.jTextField2.getText()); } catch (MalformedURLException ex) { log.error(ex.toString()); } return this.url; } return null; }
From source file:com.omertron.fanarttvapi.tools.ApiBuilder.java
/** * Convert the string into a URL/*w ww. jav a2 s . c o m*/ * * @param searchUrl * @return * @throws FanartTvException */ private URL convertUrl(StringBuilder searchUrl) throws FanartTvException { try { LOG.trace("URL: {}", searchUrl.toString()); return new URL(searchUrl.toString()); } catch (MalformedURLException ex) { LOG.warn(FAILED_TO_CREATE_URL, searchUrl.toString(), ex.toString()); throw new FanartTvException(ApiExceptionType.INVALID_URL, "Unable to conver String to URL", 0, searchUrl.toString(), ex); } }
From source file:de.fuberlin.wiwiss.r2r.LoadingFunctionManager.java
public Function getFunctionByUri(String URI) { if (basicFunctions.containsFunctionByUri(URI)) return basicFunctions.getFunctionByUri(URI); // Try to load function if not present in this manager if (!functions.containsKey(URI)) { if (ffLoader == null) throw new IllegalArgumentException("No function found with URI/ID: " + URI); else {/* w ww .ja v a2 s .co m*/ try { FunctionFactory ff = ffLoader.getFunctionFactory(URI); if (ff != null) { synchronized (functions) { functions.put(URI, ff); } } else return null;// Could not load Function } catch (MalformedURLException e) { if (log.isDebugEnabled()) log.debug("TransformationFunction <" + URI + "> could not be loaded: " + e.toString()); if (Config.rethrowActivated()) throw new R2RException( "TransformationFunction <" + URI + "> could not be loaded: " + e.toString(), e); return null; } } } FunctionFactory factory = functions.get(URI); if (factory instanceof MultiFunctionFactory) { return ((MultiFunctionFactory) factory).getInstance(URI); } return functions.get(URI).getInstance(); }
From source file:fi.vrk.xroad.catalog.collector.actors.ListMethodsActor.java
@Override protected boolean handleMessage(Object message) { if (message instanceof ClientType) { log.info("{} onReceive {}", COUNTER.addAndGet(1), this.hashCode()); ClientType clientType = (ClientType) message; Subsystem subsystem = new Subsystem( new Member(clientType.getId().getXRoadInstance(), clientType.getId().getMemberClass(), clientType.getId().getMemberCode(), clientType.getName()), clientType.getId().getSubsystemCode()); log.info("{} Handling subsystem {} ", COUNTER, subsystem); log.info("Fetching methods for the client with listMethods -service..."); XRoadClientIdentifierType xroadId = new XRoadClientIdentifierType(); xroadId.setXRoadInstance(xroadInstance); xroadId.setMemberClass(memberClass); xroadId.setMemberCode(memberCode); xroadId.setSubsystemCode(subsystemCode); xroadId.setObjectType(XRoadObjectType.SUBSYSTEM); try {//from ww w .j av a 2 s.c om // fetch the methods log.info("calling web service at {}", webservicesEndpoint); List<XRoadServiceIdentifierType> result = XRoadClient.getMethods(webservicesEndpoint, xroadId, clientType); log.info("Received all methods for client {} ", ClientTypeUtil.toString(clientType)); // Save services for subsystems List<Service> services = new ArrayList<>(); for (XRoadServiceIdentifierType service : result) { services.add(new Service(subsystem, service.getServiceCode(), service.getServiceVersion())); } catalogService.saveServices(subsystem.createKey(), services); // get wsdls for (XRoadServiceIdentifierType service : result) { log.info("{} Sending service {} to new MethodActor ", COUNTER, service.getServiceCode()); fetchWsdlPoolRef.tell(service, getSender()); } return true; } catch (MalformedURLException e) { log.error("Failed to get methods for subsystem {} \n {}", subsystem, e.toString()); throw new CatalogCollectorRuntimeException("Malformed URL", e); } } else { return false; } }
From source file:org.eclipse.smila.connectivity.framework.crawler.web.http.Http.java
/** * Loads HTTP client configuration for this web site. *//*w w w. j av a 2 s . c om*/ private void configureClient() { final HttpConnectionManagerParams params = s_connectionManager.getParams(); if (_timeout != 0) { params.setConnectionTimeout(_timeout); params.setSoTimeout(_timeout); } else { params.setConnectionTimeout(_connectTimeout); params.setSoTimeout(_readTimeout); } params.setSendBufferSize(BUFFER_SIZE); params.setReceiveBufferSize(BUFFER_SIZE); final HostConfiguration hostConf = s_client.getHostConfiguration(); final List<Header> headers = new ArrayList<Header>(); // prefer English headers.add(new Header("Accept-Language", "en-us,en-gb,en;q=0.7,*;q=0.3")); // prefer UTF-8 headers.add(new Header("Accept-Charset", "utf-8,ISO-8859-1;q=0.7,*;q=0.7")); // prefer understandable formats headers.add(new Header("Accept", "text/html,application/xml;q=0.9,application/xhtml+xml,text/xml;q=0.9,text/plain;q=0.8")); // accept GZIP content headers.add(new Header("Accept-Encoding", "x-gzip, gzip")); final String[] webSiteHeaders = getConf().get(HttpProperties.HEADERS).split(SEMICOLON); for (String header : webSiteHeaders) { final String[] headerInformation = header.split(COLON); if (headerInformation.length > 2) { headers.add(new Header(headerInformation[0].trim(), headerInformation[1].trim())); } } hostConf.getParams().setParameter("http.default-headers", headers); if (_useProxy) { hostConf.setProxy(_proxyHost, _proxyPort); if (_proxyLogin.length() > 0) { final Credentials proxyCreds = new UsernamePasswordCredentials(_proxyLogin, _proxyPassword); s_client.getState().setProxyCredentials(new AuthScope(AuthScope.ANY), proxyCreds); } } final List<Rfc2617Authentication> httpAuthentications = _authentication.getRfc2617Authentications(); for (Rfc2617Authentication auth : httpAuthentications) { s_client.getState().setCredentials( new AuthScope(auth.getHost(), Integer.valueOf(auth.getPort()), auth.getRealm()), new UsernamePasswordCredentials(auth.getLogin(), auth.getPassword())); } final SslCertificateAuthentication sslAuth = _authentication.getSslCertificateAuthentication(); if (sslAuth != null) { try { final URL truststoreURL = new File(sslAuth.getTruststoreUrl()).toURL(); final URL keystoreURL = new File(sslAuth.getKeystoreUrl()).toURL(); final ProtocolSocketFactory sslFactory = new AuthSSLProtocolSocketFactory(keystoreURL, sslAuth.getKeystorePassword(), truststoreURL, sslAuth.getTruststorePassword()); _https = new Protocol(sslAuth.getProtocolName(), sslFactory, Integer.valueOf(sslAuth.getPort())); Protocol.registerProtocol(sslAuth.getProtocolName(), _https); } catch (MalformedURLException exception) { LOG.error("unable to bind https protocol" + exception.toString()); } } }
From source file:org.apache.hadoop.gateway.websockets.GatewayWebsocketHandler.java
/** * This method looks at the context path and returns the backend websocket * url. If websocket url is found it is used as is, or we default to * ws://{host}:{port} which might or might not be right. * //from w ww . jav a2 s . c o m * @param The context path * @return Websocket backend url */ private synchronized String getMatchedBackendURL(final String path) { final ServiceRegistry serviceRegistryService = services .getService(GatewayServices.SERVICE_REGISTRY_SERVICE); final ServiceDefinitionRegistry serviceDefinitionService = services .getService(GatewayServices.SERVICE_DEFINITION_REGISTRY); /* Filter out the /cluster/topology to get the context we want */ String[] pathInfo = path.split(REGEX_SPLIT_CONTEXT); final ServiceDefEntry entry = serviceDefinitionService.getMatchingService(pathInfo[1]); if (entry == null) { throw new RuntimeException(String.format("Cannot find service for the given path: %s", path)); } final File servicesDir = new File(config.getGatewayServicesDir()); final Set<ServiceDefinition> serviceDefs = ServiceDefinitionsLoader.getServiceDefinitions(servicesDir); /* URL used to connect to websocket backend */ String backendURL = urlFromServiceDefinition(serviceDefs, serviceRegistryService, entry, path); try { /* if we do not find websocket URL we default to HTTP */ if (!StringUtils.contains(backendURL, WEBSOCKET_PROTOCOL_STRING)) { URL serviceUrl = new URL(backendURL); final StringBuffer backend = new StringBuffer(); /* Use http host:port if ws url not configured */ final String protocol = (serviceUrl.getProtocol() == "ws" || serviceUrl.getProtocol() == "wss") ? serviceUrl.getProtocol() : "ws"; backend.append(protocol).append("://"); backend.append(serviceUrl.getHost()).append(":"); backend.append(serviceUrl.getPort()).append("/"); ; backend.append(serviceUrl.getPath()); backendURL = backend.toString(); } } catch (MalformedURLException e) { LOG.badUrlError(e); throw new RuntimeException(e.toString()); } return backendURL; }
From source file:com.easy.facebook.android.apicall.RestApi.java
private String inviteEventCall(String eventID, String userID, String message) throws EasyFacebookError { Bundle params = new Bundle(); params.putString("method", "events.invite"); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); params.putString("eid", eventID); params.putString("uids", userID); params.putString("personal_message", message); String jsonResponse = ""; try {//ww w . j av a 2 s . co m jsonResponse = Util.openUrl("https://api.facebook.com/restserver.php", "POST", params); } catch (MalformedURLException e) { throw new EasyFacebookError(e.toString(), "MalformedURLException"); } catch (IOException e) { throw new EasyFacebookError(e.toString(), "IOException"); } return jsonResponse; }
From source file:com.easy.facebook.android.apicall.RestApi.java
private String setStatusCall(String message, String urlPicture) throws EasyFacebookError { Bundle params = new Bundle(); params.putString("format", "json"); params.putString("method", "status.set"); params.putString("access_token", facebook.getAccessToken()); params.putString("status", message); if (urlPicture != null) params.putString("picture", urlPicture); String jsonResponse = ""; try {//from w w w .j a v a 2 s .c o m jsonResponse = Util.openUrl("https://api.facebook.com/restserver.php", "POST", params); } catch (MalformedURLException e) { throw new EasyFacebookError(e.toString(), "MalformedURLException"); } catch (IOException e) { throw new EasyFacebookError(e.toString(), "IOException"); } return jsonResponse; }
From source file:com.easy.facebook.android.apicall.RestApi.java
private List<Album> getAlbumsCall(String friendID) throws EasyFacebookError { Bundle params = new Bundle(); params.putString("format", "json"); params.putString("method", "photos.getAlbums"); params.putString("access_token", facebook.getAccessToken()); String jsonResponse;/*from w ww.j a v a 2s .c o m*/ List<Album> albumList = new ArrayList<Album>(); try { jsonResponse = Util.openUrl("https://api.facebook.com/restserver.php", "POST", params); JSONObjectDecode jsonArray = new JSONObjectDecode(jsonResponse); for (int i = 0; i < jsonArray.length(); i++) albumList.add(jsonArray.getAlbum(i)); } catch (MalformedURLException e) { throw new EasyFacebookError(e.toString(), "MalformedURLException"); } catch (IOException e) { throw new EasyFacebookError(e.toString(), "IOException"); } catch (JSONException e) { throw new EasyFacebookError(e.toString(), "JSONException"); } return albumList; }
From source file:com.easy.facebook.android.facebook.FBLoginManager.java
public void logout(Facebook facebook) throws EasyFacebookError { SharedPreferences preferences = this.getActivity().getSharedPreferences(appID, 0); android.content.SharedPreferences.Editor editor = preferences.edit(); editor.putString("accessToken", ""); editor.putString("uid", ""); editor.clear();//from w w w. j av a2 s . co m editor.commit(); CookieSyncManager.createInstance(activity); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); Bundle params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); params.putString("method", "auth.expireSession"); String jsonResponse = ""; try { jsonResponse = Util.openUrl("https://api.facebook.com/restserver.php", "GET", params); if (!jsonResponse.equals("true")) { JSONObject objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error_msg")) { throw new EasyFacebookError(jsonResponse); } } } catch (MalformedURLException e) { throw new EasyFacebookError(e.toString(), "MalformedURLException"); } catch (IOException e) { throw new EasyFacebookError(e.toString(), "IOException"); } catch (JSONException e) { throw new EasyFacebookError(e.toString(), "JSONException"); } ((LoginListener) activity).logoutSuccess(); }