Example usage for java.lang IllegalStateException getMessage

List of usage examples for java.lang IllegalStateException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalStateException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.mimo.service.api.MimoHttpConnection.java

/**
 * Function for Making HTTP "get" request and getting server response.
 * /*w  ww.  j  av  a2s.c o m*/
 * @param p_url
 *            - Http Url
 * @throws ClientProtocolException
 * @throws IOException
 * @return HttpResponse- Returns the HttpResponse.
 */
public static synchronized HttpResponse getHttpUrlConnection(String p_url)
        throws ClientProtocolException, IOException // throws
// CustomException
{

    DefaultHttpClient m_httpClient = new DefaultHttpClient();
    HttpGet m_get = new HttpGet(p_url);

    String m_authString = MimoAPIConstants.USERNAME + ":" + MimoAPIConstants.PASSWORD;
    String m_authStringEnc = Base64.encodeToString(m_authString.getBytes(), Base64.NO_WRAP);
    m_get.addHeader(MimoAPIConstants.HEADER_TEXT_AUTHORIZATION,
            MimoAPIConstants.HEADER_TEXT_BASIC + m_authStringEnc);
    HttpResponse m_response = null;

    try {
        m_response = m_httpClient.execute(m_get);
    } catch (IllegalStateException e) {
        if (MimoAPIConstants.DEBUG) {
            Log.e(TAG, e.getMessage());
        }
    }

    return m_response;
}

From source file:com.mimo.service.api.MimoHttpConnection.java

/**
 * Function for Making HTTP "post" request and getting server response.
 * //from  w  ww  . j a va2 s  . c om
 * @param p_url
 *            - Http Url
 * @throws ClientProtocolException
 * @throws IOException
 * @return HttpResponse- Returns the HttpResponse.
 */
public static synchronized HttpResponse getHttpTransferUrlConnection(String p_url)
        throws ClientProtocolException, IOException // throws
// CustomException
{

    DefaultHttpClient m_httpClient = new DefaultHttpClient();
    HttpPost m_post = new HttpPost(p_url);

    String m_authString = MimoAPIConstants.USERNAME + ":" + MimoAPIConstants.PASSWORD;
    String m_authStringEnc = Base64.encodeToString(m_authString.getBytes(), Base64.NO_WRAP);
    m_post.addHeader(MimoAPIConstants.HEADER_TEXT_AUTHORIZATION,
            MimoAPIConstants.HEADER_TEXT_BASIC + m_authStringEnc);
    HttpResponse m_response = null;

    try {
        m_response = m_httpClient.execute(m_post);
    } catch (IllegalStateException e) {
        if (MimoAPIConstants.DEBUG) {
            Log.e(TAG, e.getMessage());
        }
    }

    return m_response;
}

From source file:com.aqnote.shared.encrypt.util.DesUtil.java

public synchronized static String encrypt(String plaintext) {
    String result = null;/*from   w  w w  . ja va2s  .c om*/
    try {
        if (plaintext == null) {
            return null;
        }
        result = new String(Hex.encodeHex(encodeCipher.doFinal(plaintext.getBytes(ENCODE_UTF_8))));
    } catch (IllegalStateException e) {
        logger.error(MSG(R.F, "encrypt", plaintext, e.getMessage()), e);
    } catch (IllegalBlockSizeException e) {
        logger.error(MSG(R.F, "encrypt", plaintext, e.getMessage()), e);
    } catch (BadPaddingException e) {
        logger.error(MSG(R.F, "encrypt", plaintext, e.getMessage()), e);
    } catch (UnsupportedEncodingException e) {
        logger.error(MSG(R.F, "encrypt", plaintext, e.getMessage()), e);
    } finally {
    }

    return result;
}

From source file:com.aqnote.shared.encrypt.util.DesUtil.java

public synchronized static String decrypt(String cryptotext) {
    String result = null;/*from   ww  w .  ja v  a 2 s.com*/
    try {
        byte[] clearByte;
        if (cryptotext == null) {
            return null;
        }
        clearByte = decodeCipher.doFinal(Hex.decodeHex(cryptotext.toCharArray()));
        result = new String(clearByte, ENCODE_UTF_8);
    } catch (IllegalStateException e) {
        logger.error(MSG(R.F, "decrypt", cryptotext, e.getMessage()), e);
    } catch (IllegalBlockSizeException e) {
        logger.error(MSG(R.F, "decrypt", cryptotext, e.getMessage()), e);
    } catch (BadPaddingException e) {
        logger.error(MSG(R.F, "decrypt", cryptotext, e.getMessage()), e);
    } catch (UnsupportedEncodingException e) {
        logger.error(MSG(R.F, "decrypt", cryptotext, e.getMessage()), e);
    } catch (DecoderException e) {
        logger.error(MSG(R.F, "decrypt", cryptotext, e.getMessage()), e);
    } finally {
    }
    return result;
}

From source file:es.deustotech.piramide.utils.net.JSONParser.java

public static Vector<Point> parseFromUrl(HttpEntity httpEntity) {
    if (httpEntity != null) {
        InputStream inStream;/*from  ww w  .  ja v a 2 s.  co m*/
        try {
            inStream = httpEntity.getContent();
            result = convertStreamToString(inStream);
            points = new Vector<Point>();
            final JSONObject jsonObj = new JSONObject(result);

            final JSONObject result = jsonObj.getJSONObject(Constants.JSON_RESPONSE_DATA);

            //show 8 results
            for (int i = 0; i < 8; i++) {
                final JSONObject resultAux = (JSONObject) result.getJSONArray(Constants.JSON_RESULTS).get(i);
                //               final JSONObject phoneAux    = (JSONObject) resultAux.getJSONArray(Constants.JSON_PHONE_NUMBERS).get(0);

                final Point point = new Point(resultAux.getString(Constants.JSON_TITLE),
                        resultAux.getString(Constants.JSON_STREET), resultAux.getString(Constants.JSON_LAT),
                        resultAux.getString(Constants.JSON_LNG)

                /*new PhoneNumbers(phoneAux.getString(Constants.JSON_TYPE), 
                phoneAux.getString(Constants.JSON_NUMBER)), 
                resultAux.getString(Constants.JSON_CITY), 
                resultAux.getString(Constants.JSON_TITLE), 
                resultAux.getString(Constants.JSON_REGION), 
                resultAux.getString(Constants.JSON_TITLE_NO_FORMATTING), 
                resultAux.getString(Constants.JSON_STREET), 
                resultAux.getJSONArray(Constants.JSON_ADDRESS_LINES).getString(0), 
                resultAux.getString(Constants.JSON_COUNTRY), 
                resultAux.getString(Constants.JSON_LAT), 
                resultAux.getString(Constants.JSON_LNG),
                resultAux.getString(Constants.JSON_TO_HERE), 
                resultAux.getString(Constants.JSON_FROM_HERE)*/);

                points.add(point);
            }

            //            final JSONObject phoneAux    = (JSONObject) result.getJSONArray(Constants.JSON_PHONE_NUMBERS).get(0);

            /*
            Log.i(Constants.TAG, "<jsonobject>\n" + jsonObj.toString() + "\n</jsonobject>");
                    
            final JSONArray nameArray    = jsonObj.names();
            final JSONArray valArray    = jsonObj.toJSONArray(nameArray);
                    
            for(int i=0; i<valArray.length(); i++) {
               Log.e(Constants.TAG, "<jsonname" + i + ">\n" + nameArray.getString(i) + "\n</jsonname" + i + ">\n" 
             + "<jsonvalue" + i + ">\n" + valArray.getString(i) + "\n</jsonvalue" + i + ">");
            }
            jsonObj.put(Constants.SAMPLE_KEY, Constants.SAMPLE_VALUE);
                    
            Log.i(Constants.TAG, "<jsonobject>\n" + jsonObj.toString() + "\n</jsonobject>");
             */

            inStream.close();
        } catch (IllegalStateException ise) {
            Log.d(Constants.TAG, ise.getMessage());
        } catch (IOException ioe) {
            Log.d(Constants.TAG, ioe.getMessage());
        } catch (JSONException je) {
            Log.d(Constants.TAG, je.getMessage());
        }
    } // If the response does not enclose an entity, there is no need
      // to worry about connection release
    return points;
}

From source file:org.mitre.mpf.nms.AddressParser.java

public static Pair<String, NodeTypes> parse(Address address) {
    String addrString = address.toString();
    Matcher matcher = FQN_PATTERN.matcher(addrString);

    if (!matcher.matches() || matcher.groupCount() < 3) {
        IllegalStateException e = new IllegalStateException("Address " + address
                + " is not in the form <node-type>" + FQN_SEP + "<host>" + FQN_SEP + "<description>.");
        LOG.warn(e.getMessage(), e);
        return null;
    }//from  w w w  . jav a2s.  c  om

    NodeTypes nodeType = NodeTypes.lookup(matcher.group(1));
    if (nodeType == null) {
        LOG.warn("Unknown Node Type: {}", matcher.group(1));
        return null;
    }

    String addrHost = matcher.group(2);
    return Pair.of(addrHost, nodeType);
}

From source file:org.apache.whirr.service.FirewallManager.java

public static void authorizeIngress(ComputeServiceContext computeServiceContext, Set<Instance> instances,
        ClusterSpec clusterSpec, List<String> cidrs, int... ports) {

    if (computeServiceContext.getProviderSpecificContext().getApi() instanceof EC2Client) {
        // This code (or something like it) may be added to jclouds (see
        // http://code.google.com/p/jclouds/issues/detail?id=336).
        // Until then we need this temporary workaround.
        String region = AWSUtils.parseHandle(Iterables.get(instances, 0).getId())[0];
        EC2Client ec2Client = EC2Client.class.cast(computeServiceContext.getProviderSpecificContext().getApi());
        String groupName = "jclouds#" + clusterSpec.getClusterName() + "#" + region;
        for (String cidr : cidrs) {
            for (int port : ports) {
                try {
                    ec2Client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(region,
                            groupName, IpProtocol.TCP, port, port, cidr);
                } catch (IllegalStateException e) {
                    LOG.warn(e.getMessage());
                    /* ignore, it means that this permission was already granted */
                }//ww w .  j a  va  2 s .  com
            }
        }
    }
}

From source file:jp.terasoluna.fw.util.GenericPropertyUtil.java

/**
 * ??????? <code>Generics</code>?????
 * @param genericClass <code>Generics</code>? ???
 * @param clazz ???//from w ww. j a v  a 2 s.  c o  m
 * @param type ????? <code>Type</code>
 * @param index ??
 * @return <code>Generics</code>??? ???????<code>Object</code>???
 * @throws IllegalArgumentException <code>genericClass</code>? <code>null</code>?? <code>clazz</code>?
 *             <code>null</code>?? <code>index</code>?<code>0</code>???????? ????
 * @throws IllegalStateException ?<code>WildCardType</code>???
 */
@SuppressWarnings("unchecked")
protected static Class<?> resolveType(Class<?> genericClass, @SuppressWarnings("rawtypes") Class clazz,
        Type type, int index) throws IllegalArgumentException, IllegalStateException {
    if (genericClass == null) {
        throw new IllegalArgumentException("Argument 'genericsClass' (" + Class.class.getName() + ") is null");
    }
    if (clazz == null || !genericClass.isAssignableFrom(clazz)) {
        throw new IllegalStateException(genericClass + " is not assignable from " + clazz);
    }

    List<ParameterizedType> ancestorTypeList = null;
    try {
        ancestorTypeList = GenericsUtil.getAncestorTypeList(genericClass, clazz);
    } catch (IllegalStateException e) {
        if (log.isTraceEnabled()) {
            log.trace(e.getMessage());
        }
    }
    if (ancestorTypeList == null) {
        ancestorTypeList = new ArrayList<ParameterizedType>();
    }
    if (type instanceof ParameterizedType) {
        ancestorTypeList.add(0, (ParameterizedType) type);
    }
    if (ancestorTypeList.size() <= 0) {
        throw new IllegalStateException("No parameterizedType was detected.");
    }
    ParameterizedType parameterizedType = ancestorTypeList.get(ancestorTypeList.size() - 1);
    Type[] actualTypes = parameterizedType.getActualTypeArguments();

    // ??????
    if (index < 0 || index >= actualTypes.length) {
        throw new IllegalArgumentException("Argument 'index'(" + Integer.toString(index)
                + ") is out of bounds of" + " generics parameters");
    }

    Class<?> resolved = Object.class;
    try {
        resolved = GenericsUtil.resolveTypeVariable(actualTypes[index], ancestorTypeList);
    } catch (IllegalStateException e) {
        if (log.isTraceEnabled()) {
            log.trace(e.getMessage());
        }
    }
    return resolved;
}

From source file:io.goodway.navitia_android.Request.java

public static void getWays(Action a, ArrayList<Pair> pairs, Address from, Address to, ErrorAction error) {
    try {/*  w w  w.j av  a2s . co m*/
        new GetWays(a, pairs, from, to, error).execute();
        Log.d("getWays", "getWays");
    } catch (IllegalStateException e) {
        Log.e(e.getMessage(), "exception");
    }

}

From source file:brooklyn.config.BrooklynServerPaths.java

public static File getBrooklynWebTmpDir(ManagementContext mgmt) {
    String brooklynMgmtBaseDir = getMgmtBaseDir(mgmt);
    File webappTempDir = new File(Os.mergePaths(brooklynMgmtBaseDir, "planes", mgmt.getManagementPlaneId(),
            mgmt.getManagementNodeId(), "jetty"));
    try {/* www . j  ava 2s .  c o m*/
        FileUtils.forceMkdir(webappTempDir);
        Os.deleteOnExitRecursivelyAndEmptyParentsUpTo(webappTempDir, new File(brooklynMgmtBaseDir));
        return webappTempDir;
    } catch (Exception e) {
        Exceptions.propagateIfFatal(e);
        IllegalStateException e2 = new IllegalStateException(
                "Cannot create working directory " + webappTempDir + " for embedded jetty server: " + e, e);
        log.warn(e2.getMessage() + " (rethrowing)");
        throw e2;
    }
}