Java Code Examples for java.net.MalformedURLException#getMessage()

The following examples show how to use java.net.MalformedURLException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DnsContextFactory.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static Context urlToContext(String url, Hashtable<?,?> env)
        throws NamingException {

    DnsUrl[] urls;
    try {
        urls = DnsUrl.fromList(url);
    } catch (MalformedURLException e) {
        throw new ConfigurationException(e.getMessage());
    }
    if (urls.length == 0) {
        throw new ConfigurationException(
                "Invalid DNS pseudo-URL(s): " + url);
    }
    String domain = urls[0].getDomain();

    // If multiple urls, all must have the same domain.
    for (int i = 1; i < urls.length; i++) {
        if (!domain.equalsIgnoreCase(urls[i].getDomain())) {
            throw new ConfigurationException(
                    "Conflicting domains: " + url);
        }
    }
    return getContext(domain, urls, env);
}
 
Example 2
Source File: WorkspaceProbesFactory.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Get {@link WorkspaceProbes} for servers of the specified machines
 *
 * @throws InfrastructureException when the operation fails
 */
public WorkspaceProbes getProbes(
    RuntimeIdentity runtimeId, Map<String, ? extends Machine> machines)
    throws InfrastructureException {
  List<ProbeFactory> factories = new ArrayList<>();
  try {
    for (Entry<String, ? extends Machine> entry : machines.entrySet()) {
      fillProbes(runtimeId, entry.getKey(), factories, entry.getValue().getServers());
    }
  } catch (MalformedURLException e) {
    throw new InternalInfrastructureException(
        "Server liveness probes creation failed. Error: " + e.getMessage());
  }

  return new WorkspaceProbes(runtimeId.getWorkspaceId(), factories);
}
 
Example 3
Source File: IntraHubServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public GetTransactionResponse getTransaction(SAMLToken token, GetTransactionRequest request) throws IntraHubBusinessConnectorException, TechnicalConnectorException {
   if (SessionUtil.getEncryptionCrypto() == null) {
      LOG.error("No Personal Crypto defined... Have you created a session that also loads your Personal eHealth Certificate?");
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.SECURITY_NO_CERTIFICATE, new Object[]{"Decryption for GetTransaction"});
   } else {
      LOG.debug("adding request with encryption id codes");
      request.setRequest(RequestTypeBuilder.init().addAuthorWithEncryptionInformation().build());
      GetTransactionRequest encryptedRequest = (GetTransactionRequest)IntrahubEncryptionUtil.encryptFolder(request, "hub.id", "hub.application");
      LOG.debug("Sending message with KMEHR headers to hub");

      try {
         GenericRequest genReq = ServiceFactory.getIntraHubPortWithFolderEncryption(token, "urn:be:fgov:ehealth:interhub:protocol:v1:GetTransaction");
         genReq.setPayload((Object)encryptedRequest);
         GenericResponse genResp = be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(genReq);
         return (GetTransactionResponse)genResp.asObject(GetTransactionResponse.class);
      } catch (SOAPException var6) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var6, new Object[]{var6.getMessage()});
      } catch (WebServiceException var7) {
         throw ServiceHelper.handleWebServiceException(var7);
      } catch (MalformedURLException var8) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var8, new Object[]{var8.getMessage()});
      }
   }
}
 
Example 4
Source File: IntraHubServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public GetTransactionListResponse getTransactionList(SAMLToken token, GetTransactionListRequest request) throws IntraHubBusinessConnectorException, TechnicalConnectorException {
   request.setRequest(RequestTypeBuilder.init().addGenericAuthor().build());

   try {
      GenericRequest genReq = ServiceFactory.getIntraHubPort(token, "urn:be:fgov:ehealth:interhub:protocol:v1:GetTransactionList");
      genReq.setPayload((Object)request);
      GenericResponse genResp = be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(genReq);
      return (GetTransactionListResponse)genResp.asObject(GetTransactionListResponse.class);
   } catch (SOAPException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var5, new Object[]{var5.getMessage()});
   } catch (WebServiceException var6) {
      throw ServiceHelper.handleWebServiceException(var6);
   } catch (MalformedURLException var7) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var7, new Object[]{var7.getMessage()});
   }
}
 
Example 5
Source File: DnsContextFactory.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static Context urlToContext(String url, Hashtable<?,?> env)
        throws NamingException {

    DnsUrl[] urls;
    try {
        urls = DnsUrl.fromList(url);
    } catch (MalformedURLException e) {
        throw new ConfigurationException(e.getMessage());
    }
    if (urls.length == 0) {
        throw new ConfigurationException(
                "Invalid DNS pseudo-URL(s): " + url);
    }
    String domain = urls[0].getDomain();

    // If multiple urls, all must have the same domain.
    for (int i = 1; i < urls.length; i++) {
        if (!domain.equalsIgnoreCase(urls[i].getDomain())) {
            throw new ConfigurationException(
                    "Conflicting domains: " + url);
        }
    }
    return getContext(domain, urls, env);
}
 
Example 6
Source File: IntraHubServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public RevokeHCPartyConsentResponse revokeHCPartyConsent(SAMLToken token, RevokeHCPartyConsentRequest request) throws IntraHubBusinessConnectorException, TechnicalConnectorException {
   request.setRequest(RequestTypeBuilder.init().addGenericAuthor().build());

   try {
      GenericRequest genReq = ServiceFactory.getIntraHubPort(token, "urn:be:fgov:ehealth:interhub:protocol:v1:RevokeHCPartyConsent");
      genReq.setPayload((Object)request);
      GenericResponse genResp = be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(genReq);
      return (RevokeHCPartyConsentResponse)genResp.asObject(RevokeHCPartyConsentResponse.class);
   } catch (SOAPException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var5, new Object[]{var5.getMessage()});
   } catch (WebServiceException var6) {
      throw ServiceHelper.handleWebServiceException(var6);
   } catch (MalformedURLException var7) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var7, new Object[]{var7.getMessage()});
   }
}
 
Example 7
Source File: IntraHubServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public RequestPublicationResponse requestPublication(SAMLToken token, RequestPublicationRequest request) throws IntraHubBusinessConnectorException, TechnicalConnectorException {
   request.setRequest(RequestTypeBuilder.init().addGenericAuthor().build());

   try {
      GenericRequest genReq = ServiceFactory.getIntraHubPort(token, "urn:be:fgov:ehealth:interhub:protocol:v1:RequestPublication");
      genReq.setPayload((Object)request);
      GenericResponse genResp = be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(genReq);
      return (RequestPublicationResponse)genResp.asObject(RequestPublicationResponse.class);
   } catch (SOAPException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var5, new Object[]{var5.getMessage()});
   } catch (WebServiceException var6) {
      throw this.handleWebServiceException(var6);
   } catch (MalformedURLException var7) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var7, new Object[]{var7.getMessage()});
   }
}
 
Example 8
Source File: GenInsServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public GetInsurabilityAsFlatResponse getInsurabilityAsFlat(SAMLToken token, GetInsurabilityAsXmlOrFlatRequestType request) throws GenInsBusinessConnectorException, TechnicalConnectorException, SessionManagementException {
   GetInsurabilityAsFlatResponse response = null;
   GetInsurabilityAsFlatRequest genericReq = new GetInsurabilityAsFlatRequest();
   this.dozer(request, genericReq);

   try {
      GenericRequest service = ServiceFactory.getGeninsPort(token);
      service.setPayload((Object)genericReq);
      GenericResponse xmlResponse = be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(service);
      response = (GetInsurabilityAsFlatResponse)xmlResponse.asObject(GetInsurabilityAsFlatResponse.class);
      return response;
   } catch (MalformedURLException var7) {
      LOG.error("GeninsServiceImpl : " + var7.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.MALFORMED_URL, var7, new Object[]{"genins " + var7.getMessage()});
   } catch (SOAPException var8) {
      LOG.error("GeninsServiceImpl : " + var8.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var8, new Object[]{var8.getMessage()});
   }
}
 
Example 9
Source File: IntraHubServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public PutTransactionResponse putTransaction(SAMLToken token, PutTransactionRequest request) throws IntraHubBusinessConnectorException, TechnicalConnectorException {
   if (SessionUtil.getEncryptionCrypto() == null) {
      LOG.error("No Personal Crypto defined... Have you created a session that also loads your Personal eHealth Certificate?");
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.SECURITY_NO_CERTIFICATE, new Object[]{"Encryption for PutTransaction"});
   } else {
      request.setRequest(RequestTypeBuilder.init().addAuthorWithEncryptionInformation().build());
      PutTransactionRequest encryptedRequest = (PutTransactionRequest)IntrahubEncryptionUtil.encryptFolder(request, "hub.id", "hub.application");

      try {
         GenericRequest genReq = ServiceFactory.getIntraHubPortWithFolderEncryption(token, "urn:be:fgov:ehealth:interhub:protocol:v1:PutTransaction");
         genReq.setPayload((Object)encryptedRequest);
         GenericResponse genResp = be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(genReq);
         return (PutTransactionResponse)genResp.asObject(PutTransactionResponse.class);
      } catch (SOAPException var6) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var6, new Object[]{var6.getMessage()});
      } catch (WebServiceException var7) {
         throw ServiceHelper.handleWebServiceException(var7);
      } catch (MalformedURLException var8) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var8, new Object[]{var8.getMessage()});
      }
   }
}
 
Example 10
Source File: IntraHubServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public PutTransactionResponse putTransaction(SAMLToken token, PutTransactionRequest request) throws IntraHubBusinessConnectorException, TechnicalConnectorException {
   if (SessionUtil.getEncryptionCrypto() == null) {
      LOG.error("No Personal Crypto defined... Have you created a session that also loads your Personal eHealth Certificate?");
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.SECURITY_NO_CERTIFICATE, new Object[]{"Encryption for PutTransaction"});
   } else {
      request.setRequest(RequestTypeBuilder.init().addAuthorWithEncryptionInformation().build());
      PutTransactionRequest encryptedRequest = (PutTransactionRequest)IntrahubEncryptionUtil.encryptFolder(request, "hub.id", "hub.application");

      try {
         GenericRequest genReq = ServiceFactory.getIntraHubPortWithFolderEncryption(token, "urn:be:fgov:ehealth:interhub:protocol:v1:PutTransaction");
         genReq.setPayload((Object)encryptedRequest);
         GenericResponse genResp = be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(genReq);
         return (PutTransactionResponse)genResp.asObject(PutTransactionResponse.class);
      } catch (SOAPException var6) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var6, new Object[]{var6.getMessage()});
      } catch (WebServiceException var7) {
         throw ServiceHelper.handleWebServiceException(var7);
      } catch (MalformedURLException var8) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var8, new Object[]{var8.getMessage()});
      }
   }
}
 
Example 11
Source File: OkHttpFetcher.java    From ache with Apache License 2.0 5 votes vote down vote up
public FetchedResult get(String url, Payload payload) throws BaseFetchException {
    try {
        URL realUrl = new URL(url);
        String protocol = realUrl.getProtocol();
        if (!protocol.equals("http") && !protocol.equals("https")) {
            throw new BadProtocolFetchException(url);
        }
    } catch (MalformedURLException e) {
        throw new UrlFetchException(url, e.getMessage());
    }

    return request(url, payload);
}
 
Example 12
Source File: URL.java    From FATE-Serving with Apache License 2.0 5 votes vote down vote up
public java.net.URL toJavaURL() {
    try {
        return new java.net.URL(toString());
    } catch (MalformedURLException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
Example 13
Source File: WorkspaceProbesFactory.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Get {@link WorkspaceProbes} for servers of a machine from a workspace runtime
 *
 * @throws InfrastructureException when the operation fails
 */
public WorkspaceProbes getProbes(
    RuntimeIdentity runtimeId, String machineName, Map<String, ? extends Server> servers)
    throws InfrastructureException {
  List<ProbeFactory> factories = new ArrayList<>();
  try {
    fillProbes(runtimeId, machineName, factories, servers);
  } catch (MalformedURLException e) {
    throw new InternalInfrastructureException(
        "Server liveness probes creation failed. Error: " + e.getMessage());
  }
  return new WorkspaceProbes(runtimeId.getWorkspaceId(), factories);
}
 
Example 14
Source File: SimpleHttpFetcher.java    From ache with Apache License 2.0 5 votes vote down vote up
@Override
public FetchedResult get(String url, Payload payload) throws BaseFetchException {
    try {
        URL realUrl = new URL(url);
        String protocol = realUrl.getProtocol();
        if (!protocol.equals("http") && !protocol.equals("https")) {
            throw new BadProtocolFetchException(url);
        }
    } catch (MalformedURLException e) {
        throw new UrlFetchException(url, e.getMessage());
    }

    return request(new HttpGet(), url, payload);
}
 
Example 15
Source File: GangliaResourceMonitor.java    From oodt with Apache License 2.0 5 votes vote down vote up
@Override
public ResourceNode getNodeById(String nodeId) throws MonitorException {
	try {
		return this.nodeFromMap(this.locateNode(nodeId));
	} catch (MalformedURLException e) {
		LOG.log(Level.SEVERE, e.getMessage());
		throw new MonitorException(e.getMessage());
	}
}
 
Example 16
Source File: ConfigUtils.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
private static URL parseUrl(ConfigurationSection section, String path, @Nullable String value, URL def) {
    try {
        return value == null ? def : new URL(value);
    } catch(MalformedURLException e) {
        throw new InvalidConfigurationException(section, path, e.getMessage());
    }
}
 
Example 17
Source File: MultiProtocolURL.java    From yacy_grid_mcp with GNU Lesser General Public License v2.1 5 votes vote down vote up
public String getName() throws IOException {
    if (isFile()) return getFSFile().getName();
    if (isSMB()) try {
        return getSmbFile().getName();
    } catch (final MalformedURLException e) {
        throw new IOException("SMB.getName MalformedURLException (" + e.getMessage() + ") for " + toNormalform(false) );
    }
    if (isFTP()) {
        return this.getFileName();
    }
    return null;
}
 
Example 18
Source File: JMXServiceURL.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private void readObject(ObjectInputStream  inputStream) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField gf = inputStream.readFields();
    String h = (String)gf.get("host", null);
    int p = (int)gf.get("port", -1);
    String proto = (String)gf.get("protocol", null);
    String url = (String)gf.get("urlPath", null);

    if (proto == null || url == null || h == null) {
        StringBuilder sb = new StringBuilder(INVALID_INSTANCE_MSG).append('[');
        boolean empty = true;
        if (proto == null) {
            sb.append("protocol=null");
            empty = false;
        }
        if (h == null) {
            sb.append(empty ? "" : ",").append("host=null");
            empty = false;
        }
        if (url == null) {
            sb.append(empty ? "" : ",").append("urlPath=null");
        }
        sb.append(']');
        throw new InvalidObjectException(sb.toString());
    }

    if (h.contains("[") || h.contains("]")) {
        throw new InvalidObjectException("Invalid host name: " + h);
    }

    try {
        validate(proto, h, p, url);
        this.protocol = proto;
        this.host = h;
        this.port = p;
        this.urlPath = url;
    } catch (MalformedURLException e) {
        throw new InvalidObjectException(INVALID_INSTANCE_MSG + ": " +
                                         e.getMessage());
    }

}
 
Example 19
Source File: BaseApi.java    From letv with Apache License 2.0 4 votes vote down vote up
public void onMalformedURLException(MalformedURLException malformedURLException) {
    Message obtainMessage = this.mHandler.obtainMessage();
    obtainMessage.obj = malformedURLException.getMessage();
    obtainMessage.what = -3;
    this.mHandler.sendMessage(obtainMessage);
}
 
Example 20
Source File: ComponentXMLAttributes.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Returns the URL location value of specified XML attribute
 * 
 * @param key
 *            name of the attribute
 * @return The qualified name value
 * @throws AttributeNotFoundException
 *             if attribute does not exist or if can not resolve reference to global parameter/property included in
 *             atribute's textual/string value
 */
public URL getURL(String key) throws AttributeNotFoundException {
	try {
		return new URL(getString(key));
	} catch (MalformedURLException urle) {
		throw new AttributeNotFoundException(key, urle.getMessage());
	}
}