Example usage for java.io UnsupportedEncodingException getMessage

List of usage examples for java.io UnsupportedEncodingException getMessage

Introduction

In this page you can find the example usage for java.io UnsupportedEncodingException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.mitre.stixwebtools.services.TaxiiService.java

public String getTaxxiCollections(URI serverUrl) {
    HttpClient taxiiClient = getTaxiiClient("gatekeeper.mitre.org", 80);
    ObjectFactory factory = new ObjectFactory();
    String content;/*from  ww  w. j  av a  2 s.co m*/

    CollectionInformationRequest request = factory.createCollectionInformationRequest()
            .withMessageId(MessageHelper.generateMessageId());

    try {

        Object responseObj = taxiiClient.callTaxiiService(serverUrl, request);
        content = taxiiXml.marshalToString(responseObj, true);
    } catch (JAXBException e) {
        content = e.getMessage();
    } catch (UnsupportedEncodingException eee) {
        content = eee.getMessage();
    } catch (IOException eeee) {
        content = eeee.getMessage();
    }

    return content;

}

From source file:com.wizarpos.atool.net.volley2.CustomStringRequest.java

@Override
public byte[] getBody() throws AuthFailureError {
    if (TextUtils.isEmpty(params)) {
        return null;
    }/*w  ww  .  j  a v  a2 s  .co  m*/
    try {
        return params.getBytes(getParamsEncoding());
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        VolleyError error = new VolleyError(e.getMessage());
        deliverError(error);// ?
    }
    return null;
}

From source file:org.mitre.stixwebtools.services.TaxiiService.java

/**
 * Query a Taxii server to get a list of availbe services this server supplies.
 * Expected results Discovery, Inbox, poll
 * /*from   w  w w .j av a  2s  .co  m*/
 * @param serverUrl
 * @return 
 */
public String getTaxiiServices(URI serverUrl) {

    HttpClient taxiiClient = getTaxiiClient("gatekeeper.mitre.org", 80);

    String content;

    ObjectFactory factory = new ObjectFactory();

    DiscoveryRequest request = factory.createDiscoveryRequest()
            .withMessageId(MessageHelper.generateMessageId());

    try {

        Object responseObj = taxiiClient.callTaxiiService(serverUrl, request);
        content = taxiiXml.marshalToString(responseObj, true);
    } catch (JAXBException e) {
        content = e.getMessage();
    } catch (UnsupportedEncodingException eee) {
        content = eee.getMessage();
    } catch (IOException eeee) {
        content = eeee.getMessage();
    }

    return content;
}

From source file:com.knurld.alphabank.com.knurld.alphabank.request.MultipartRequest.java

@Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {

    try {//w  w  w  . j  av  a2 s. c om
        Log.i(TAG, "Network Response " + new String(response.data, "UTF-8"));
        return Response.success(new String(response.data, "UTF-8"), getCacheEntry());
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        Log.wtf(TAG, e.getMessage());
        return Response.success(new String(response.data), getCacheEntry());
    }
}

From source file:com.mnxfst.testing.handler.exec.client.PTestPlanExecutorClientCallable.java

/**
 * Initializes the plan executor//from  w w w . jav a2 s  . com
 * @param hostname
 * @param port
 * @param uri
 * @param testplan
 */
public PTestPlanExecutorClientCallable(String hostname, int port, String uri, byte[] testplan) {

    this.httpHost = new HttpHost(hostname, port);
    this.postMethod = new HttpPost(uri);

    try {
        String encodedTestplan = new String(testplan, "UTF-8");
        postMethod.setEntity(new StringEntity(PTestPlanExecutorClient.REQUEST_PARAMETER_TESTPLAN + "="
                + URLEncoder.encode(encodedTestplan, "UTF-8"), "UTF-8"));
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException("Unsupported encoding exception. Error: " + e.getMessage());
    }

    // TODO setting?
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
    schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));

    ThreadSafeClientConnManager threadSafeClientConnectionManager = new ThreadSafeClientConnManager(
            schemeRegistry);
    threadSafeClientConnectionManager.setMaxTotal(20);
    threadSafeClientConnectionManager.setDefaultMaxPerRoute(20);

    this.httpClient = new DefaultHttpClient(threadSafeClientConnectionManager);
}

From source file:org.akvo.flow.api.FlowApi.java

@SuppressLint("SimpleDateFormat")
private String getTimestamp() {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));

    try {//from  w w  w  . jav  a  2  s.com
        return URLEncoder.encode(dateFormat.format(new Date()), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, e.getMessage());
        return null;
    }
}

From source file:org.dataconservancy.ui.it.support.MetadataFileRequest.java

public HttpPost asHttpPost() {

    String depositUrl = urlConfig.getMetadataFileUrl().toString();
    HttpPost post = new HttpPost(depositUrl);
    MultipartEntity entity = new MultipartEntity();
    try {/*from w  ww . ja va  2  s .  co m*/
        entity.addPart("parentID", new StringBody(parentId, Charset.forName("UTF-8")));
        if (name != null && !name.isEmpty()) {
            entity.addPart("metadataFile.name", new StringBody(name, Charset.forName("UTF-8")));
        }

        if (metadataFormat != null && !metadataFormat.isEmpty()) {
            entity.addPart("metadataFile.metadataFormatId",
                    new StringBody(metadataFormat, Charset.forName("UTF-8")));
        }

        if (id != null && !id.isEmpty()) {
            entity.addPart("metadataFileID", new StringBody(id, Charset.forName("UTF-8")));
        }

        if (isCollection) {
            entity.addPart("redirectUrl", new StringBody("viewCollectionDetails", Charset.forName("UTF-8")));
        }

        entity.addPart(event, new StringBody(event, Charset.forName("UTF-8")));

    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e.getMessage(), e);
    }

    if (fileToDeposit != null) {
        FileBody fileBody = new FileBody(fileToDeposit);
        entity.addPart("uploadedFile", fileBody);
        post.setEntity(entity);
    }
    return post;
}

From source file:net.duckling.ddl.service.authenticate.impl.UmtSsoLoginProvider.java

public PageView logout(HttpServletRequest request, String acceptUrl) {
    VWBContainer container = VWBContainerImpl.findContainer();
    String ssourl = container.getProperty("duckling.umt.logout");
    try {// w  w  w  . ja va 2s .co  m
        ssourl = ssourl + "?WebServerURL=" + URLEncoder.encode(acceptUrl, "UTF-8") + "&sid="
                + request.getSession().getId() + "&appname="
                + URLEncoder.encode(container.getProperty("duckling.dct.localName"), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        LOG.error(e.getMessage(), e);
    }
    return new PageView(true, ssourl);
}

From source file:net.duckling.ddl.service.authenticate.impl.UmtSsoLoginProvider.java

private String makeSsoLoginUrl(HttpServletRequest request, String acceptUrl) {
    VWBContainer container = VWBContainerImpl.findContainer();
    String ssourl = loginUrl;// www.  j  ava  2 s .c  o  m
    try {
        String registerURL = container.getProperty("duckling.umt.link.regist");
        ssourl = loginUrl + "?WebServerURL=" + URLEncoder.encode(acceptUrl, "UTF-8") + "&appname="
                + URLEncoder.encode(container.getProperty("duckling.dct.localName"), "UTF-8") + "&theme="
                + container.getProperty("duckling.umt.theme") + "&sid=" + request.getSession(true).getId()
                + "&logoutURL="
                + URLEncoder.encode(container.getURL("plain", "logout", "umtSsoLogout=true", true), "UTF-8")
                + "&" + ILoginHandle.APP_REGISTER_URL_KEY + "=" + URLEncoder.encode(registerURL, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        LOG.error(e.getMessage(), e);
    }
    return ssourl;
}

From source file:org.sakaiproject.shortenedurl.impl.BitlyUrlService.java

/**
 * Helper to URL encode a string// w  w  w .  j  a  v a2  s  .  c  om
 * @param s    string to encode
 * @return
 */
private String encode(String s) {
    try {
        return URLEncoder.encode(s, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        log.error(e.getClass() + ":" + e.getMessage());
    }
    return null;
}