Example usage for java.lang IllegalStateException toString

List of usage examples for java.lang IllegalStateException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:mx.edu.ittepic.proyectofinal.ejbs.webservicesusers.java

public String updateUser(@PathParam("username") String userid, @PathParam("apikey") String apikey) {

    Message m = new Message();
    Users r = new Users();
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();//from  ww  w. j av a 2 s .c om
    try {
        Query q = entity.createNamedQuery("Users.updateUser").

                setParameter("apikey", apikey).setParameter("userid", Integer.parseInt(userid));

        String idapi = userid;
        String md5 = DigestUtils.md5Hex(idapi);

        Query a = entity.createNamedQuery("Users.updateUserE").setParameter("apikey", userid)
                .setParameter("userid", Integer.parseInt(userid));

        if (q.executeUpdate() == 1 && a.executeUpdate() == 1) {
            m.setCode(200);
            m.setMsg("Se actualizo correctamente.");
            m.setDetail("OK");
        } else {
            m.setCode(404);
            m.setMsg("No se realizo la actualizacion");
            m.setDetail("");
        }

    } catch (IllegalStateException e) {
        m.setCode(404);
        m.setMsg("No se realizo la actualizacion");
        m.setDetail(e.toString());
    } catch (TransactionRequiredException e) {
        m.setCode(404);
        m.setMsg("No se realizo la actualizacion");
        m.setDetail(e.toString());
    } catch (QueryTimeoutException e) {
        m.setCode(404);
        m.setMsg("No se realizo la actualizacion");
        m.setDetail(e.toString());
    } catch (PersistenceException e) {
        m.setCode(404);
        m.setMsg("No se realizo la actualizacion");
        m.setDetail(e.toString());
    }
    return gson.toJson(m);
}

From source file:cn.com.mozilla.sync.utils.HttpsTransport.java

public HttpResponse execHttpMethod(HttpRequestBase method, String userName, String passWord)
        throws IOException {
    DefaultHttpClient client = new DefaultHttpClient(mClientConMgr, sHttpParams);
    if (userName.length() > 0 && passWord.length() > 0) {
        Credentials defaultcreds = new UsernamePasswordCredentials(userName, passWord);
        client.getCredentialsProvider().setCredentials(AuthScope.ANY, defaultcreds);
    }/*w ww .  j  a  v a2 s.c o  m*/

    // retry 3 times
    DefaultHttpRequestRetryHandler retryHandler = new DefaultHttpRequestRetryHandler(3, true);
    client.setHttpRequestRetryHandler(retryHandler);

    HttpResponse response = null;
    try {
        response = client.execute(method);
    } catch (IllegalStateException e) {
        // Deals with the situation that ClientConnectionManager shuts down during
        // connection
        throw new IOException(e.toString());
    }
    return response;

}

From source file:uk.org.crimetalk.fragments.SearchFragment.java

@Override
public void onLoadFinished(Loader<List<ArticleListItem>> loader, List<ArticleListItem> data) {

    this.setListAdapter(mArticleListAdapter);

    // Sometimes this method is called before content view is created
    new Handler().postDelayed(new Runnable() {

        @Override/*from  w  w  w.  ja v  a  2  s  .  c  o m*/
        public void run() {

            try {

                setListShown(true);

            } catch (IllegalStateException illegalStateException) {

                Log.e(TAG, illegalStateException.toString());

            }

        }

    }, 1000);

    // The Loader returned no results
    if (data.size() == 0) {

        // The device has Internet so something strange happened
        if (InternetUtils.hasInternet(getActivity())) {

            this.setEmptyText(getResources().getString(R.string.search_error));
            ((TextView) this.getListView().getEmptyView()).setTextColor(Color.GRAY);
            ((TextView) this.getListView().getEmptyView()).setTextSize(22);

            // The device has no Internet so remind the user
        } else {

            this.setEmptyText(getResources().getString(R.string.internet_none));
            ((TextView) this.getListView().getEmptyView()).setTextColor(Color.GRAY);
            ((TextView) this.getListView().getEmptyView()).setTextSize(22);

        }

        // The Loader returned results
    } else {

        this.mArticleListAdapter.setData(data);

    }

}

From source file:com.nubits.nubot.bot.NuBotBase.java

public void shutdownBot() {

    LOG.info("Bot shutting down sequence started.");

    //Interrupt all BotTasks

    if (Global.taskManager != null) {
        if (Global.taskManager.isInitialized()) {
            try {
                LOG.info("try to shutdown all tasks");
                Global.taskManager.stopAll();
            } catch (IllegalStateException e) {
                LOG.error(e.toString());
            }//from  w w  w  .ja v  a2 s.  c  o  m
        }
    }

    //Try to cancel all orders, if any
    if (Global.exchange.getTrade() != null && Global.options.getPair() != null) {

        LOG.info("Clearing out active orders ... ");

        ApiResponse deleteOrdersResponse = Global.exchange.getTrade().clearOrders(Global.options.getPair());
        if (deleteOrdersResponse.isPositive()) {
            boolean deleted = (boolean) deleteOrdersResponse.getResponseObject();

            if (deleted) {
                LOG.info("Order clear request successful");
            } else {
                LOG.error("Could not submit request to clear orders");
            }
        } else {
            LOG.error("error canceling orders: " + deleteOrdersResponse.getError().toString());
        }
    }

    //reset liquidity info
    if (Global.options.isSubmitliquidity()) {
        if (Global.rpcClient.isConnected()) {
            //tier 1
            LOG.info("Resetting Liquidity Info before quit");

            JSONObject responseObject1 = Global.rpcClient.submitLiquidityInfo(Global.rpcClient.USDchar, 0, 0,
                    1);
            if (null == responseObject1) {
                LOG.error("Something went wrong while sending liquidityinfo");
            } else {
                LOG.debug(responseObject1.toJSONString());
            }

            JSONObject responseObject2 = Global.rpcClient.submitLiquidityInfo(Global.rpcClient.USDchar, 0, 0,
                    2);
            if (null == responseObject2) {
                LOG.error("Something went wrong while sending liquidityinfo");
            } else {
                LOG.debug(responseObject2.toJSONString());
            }
        }
    }

    LOG.info("Logs of this session saved in " + Global.sessionPath);
    SessionManager.setModeHalted();
    SessionManager.sessionStopped = System.currentTimeMillis();
    LOG.info("** end of the session **");

    logSessionStatistics();

}

From source file:mx.edu.ittepic.proyectofinal.ejbs.ejbUsers.java

public String updateUser(String userid, String apikey) {

    Message m = new Message();
    Users r = new Users();
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();/*from w w  w  .ja v  a2  s  . c o  m*/
    try {
        Query q = entity.createNamedQuery("Users.updateUser").

                setParameter("apikey", apikey).setParameter("userid", Integer.parseInt(userid));

        String idapi = userid;
        String md5 = DigestUtils.md5Hex(idapi);

        Query a = entity.createNamedQuery("Users.updateUserE").setParameter("apikey", md5)
                .setParameter("userid", Integer.parseInt(userid));

        if (q.executeUpdate() == 1 && a.executeUpdate() == 1) {
            m.setCode(200);
            m.setMsg("Se actualizo correctamente.");
            m.setDetail("OK");
        } else {
            m.setCode(404);
            m.setMsg("No se realizo la actualizacion");
            m.setDetail("");
        }

    } catch (IllegalStateException e) {
        m.setCode(404);
        m.setMsg("No se realizo la actualizacion");
        m.setDetail(e.toString());
    } catch (TransactionRequiredException e) {
        m.setCode(404);
        m.setMsg("No se realizo la actualizacion");
        m.setDetail(e.toString());
    } catch (QueryTimeoutException e) {
        m.setCode(404);
        m.setMsg("No se realizo la actualizacion");
        m.setDetail(e.toString());
    } catch (PersistenceException e) {
        m.setCode(404);
        m.setMsg("No se realizo la actualizacion");
        m.setDetail(e.toString());
    }
    return gson.toJson(m);
}

From source file:org.deviceconnect.message.http.impl.factory.AbstractHttpMessageFactory.java

/**
 * HTTP???dConnect???.//from   ww w . j  av a  2 s.co  m
 * @param dmessage dConnect
 * @param message HTTP
 */
protected void parseHttpBody(final DConnectMessage dmessage, final M message) {
    mLogger.entering(getClass().getName(), "newDConnectMessage", new Object[] { dmessage, message });

    HttpEntity entity = getHttpEntity(message);
    if (entity != null) {

        MimeStreamParser parser = new MimeStreamParser(new MimeEntityConfig());
        MultipartContentHandler handler = new MultipartContentHandler(dmessage);
        parser.setContentHandler(handler);

        StringBuilder headerBuffer = new StringBuilder();

        for (Header header : message.getAllHeaders()) {
            headerBuffer.append(header.getName());
            headerBuffer.append(": ");
            headerBuffer.append(header.getValue());
            headerBuffer.append(Character.toChars(HTTP.CR));
            headerBuffer.append(Character.toChars(HTTP.LF));
            mLogger.fine("header: " + header.getName() + ":" + header.getValue());
        }
        headerBuffer.append(Character.toChars(HTTP.CR));
        headerBuffer.append(Character.toChars(HTTP.LF));

        try {
            parser.parse(new SequenceInputStream(
                    new ByteArrayInputStream(headerBuffer.toString().getBytes("US-ASCII")),
                    entity.getContent()));
        } catch (IllegalStateException e) {
            mLogger.log(Level.FINE, e.toString(), e);
            mLogger.warning(e.toString());
        } catch (MimeException e) {
            mLogger.log(Level.FINE, e.toString(), e);
            mLogger.warning(e.toString());
        } catch (IOException e) {
            mLogger.log(Level.FINE, e.toString(), e);
            mLogger.warning(e.toString());
        }
    }

    mLogger.exiting(getClass().getName(), "newDConnectMessage");
}

From source file:com.empsoft.safe_meal.MainActivity.java

public void changeFragment(Fragment frag, String tag, boolean saveInBackstack) {

    try {/*w  w  w .  j  a  va2  s .  c  o  m*/
        FragmentManager manager = getSupportFragmentManager();
        //fragment not in back stack, create it.
        FragmentTransaction transaction = manager.beginTransaction();

        transaction.replace(R.id.content_layout, frag, tag);

        if (saveInBackstack) {
            Log.d(TAG, "Change Fragment: addToBackTack " + tag);
            transaction.addToBackStack(tag);
        } else {
            Log.d(TAG, "Change Fragment: NO addToBackTack");
        }
        transaction.commit();
        // custom effect if fragment is already instanciated

    } catch (IllegalStateException exception) {
        Log.w(TAG, "Unable to commit fragment, could be activity as been killed in background. "
                + exception.toString());
    }
}

From source file:com.taobao.weex.ui.view.WXCircleViewPager.java

private void superSetCurrentItem(int item, boolean smooth) {
    try {//from w  w  w.  j av  a2s .co  m
        super.setCurrentItem(item, smooth);
    } catch (IllegalStateException e) {
        WXLogUtils.e(e.toString());
        if (getAdapter() != null) {
            getAdapter().notifyDataSetChanged();
            super.setCurrentItem(item, smooth);
        }
    }
}

From source file:com.taobao.weex.ui.view.WXCircleViewPager.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    try {//from   w  w  w.j ava2  s.c o  m
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    } catch (IllegalStateException e) {
        WXLogUtils.e(e.toString());
        if (getAdapter() != null) {
            getAdapter().notifyDataSetChanged();
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        }
    }
}

From source file:com.vmware.identity.samlservice.impl.LogoutStateValidator.java

/**
 * Validate LogoutRequest/*  ww w.jav a 2s .co m*/
 *
 * @param vr
 * @param accessor
 * @param request
 * @return
 */
private ValidationResult validateLogoutRequest(ValidationResult vr, IdmAccessor accessor,
        LogoutRequest request) {
    Validate.notNull(request.getIssuer());

    // Validate single logout service first, if that is valid, we can send
    // SAML replies
    try {
        @SuppressWarnings("unused")
        String acsUrl = accessor.getSloForRelyingParty(request.getIssuer().getValue(),
                OasisNames.HTTP_REDIRECT);
    } catch (IllegalStateException e) {
        // set validation result to 400
        log.debug("Caught illegal state exception while Validating " + e.toString() + ", returning 400");
        vr = new ValidationResult(HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), null);
    }

    // Validate ID
    if (vr == null && request.getID() == null) {
        vr = new ValidationResult(OasisNames.REQUESTER);
        log.debug("Validation FAILED - Request ID is missing");
    }

    // Validate version
    if (vr == null) {
        SAMLVersion version = request.getVersion();
        if ((version.getMajorVersion() > Shared.REQUIRED_SAML_VERSION.getMajorVersion())
                || version.getMajorVersion() == Shared.REQUIRED_SAML_VERSION.getMajorVersion()
                        && version.getMinorVersion() > Shared.REQUIRED_SAML_VERSION.getMinorVersion()) {
            // version too high
            vr = new ValidationResult(OasisNames.VERSION_MISMATCH, OasisNames.REQUEST_VERSION_TOO_HIGH);
            log.debug("Validation FAILED - Version is too high");
        } else if ((version.getMajorVersion() < Shared.REQUIRED_SAML_VERSION.getMajorVersion())
                || version.getMajorVersion() == Shared.REQUIRED_SAML_VERSION.getMajorVersion()
                        && version.getMinorVersion() < Shared.REQUIRED_SAML_VERSION.getMinorVersion()) {
            // version too low
            vr = new ValidationResult(OasisNames.VERSION_MISMATCH, OasisNames.REQUEST_VERSION_TOO_LOW);
            log.debug("Validation FAILED - Version is too low");
        }
    }

    // Validate IssueInstant
    if (vr == null) {
        DateTime dtPlus = request.getIssueInstant();
        DateTime dtMinus = request.getIssueInstant();
        DateTime instant = new DateTime();
        long clockTolerance = accessor.getClockTolerance();
        if (dtPlus == null) {
            vr = new ValidationResult(OasisNames.REQUESTER);
            log.debug("Validation FAILED - Issue Instant is missing");
        } else {
            dtPlus = dtPlus.plus(clockTolerance);
            dtMinus = dtMinus.minus(clockTolerance);
            // dtPlus must be after now and dtMinus must be before now
            // in order to satisfy clock tolerance
            if (dtPlus.isBefore(instant) || dtMinus.isAfter(instant)) {
                vr = new ValidationResult(OasisNames.REQUESTER);
                log.debug("Validation FAILED - Issue Instant outside of clock tolerance");
                log.debug("clockTolerance {}", clockTolerance);
                log.debug("now {}", instant);
                log.debug("dtPlus {}", dtPlus.toString());
                log.debug("dtMinus {}", dtMinus.toString());
            }
        }
    }

    // Destination URL skipped, this is already done by OpenSAML when
    // parsing

    // Validate NotOnOrAfter
    if (vr == null) {
        DateTime notOnOrAfter = request.getNotOnOrAfter();
        if (notOnOrAfter != null) {
            DateTime instant = new DateTime();
            if (!instant.isBefore(notOnOrAfter)) {
                vr = new ValidationResult(OasisNames.REQUESTER, OasisNames.REQUEST_DENIED);
                log.debug("Validation FAILED - NotOnOrAfter condition violated");
                log.debug("now {}", instant);
                log.debug("notOnOrAfter {}", notOnOrAfter.toString());
            }
        }
    }

    // validate NameID
    if (vr == null) {
        NameID nameID = request.getNameID();
        if (nameID == null || nameID.getFormat() == null || nameID.getValue() == null) {
            log.debug("Validation FAILED for NameID: node, format or value missing");
            vr = new ValidationResult(OasisNames.REQUESTER);
        }
    }

    // validate session index
    if (vr == null) {
        List<SessionIndex> sessionList = request.getSessionIndexes();
        if (sessionList == null || sessionList.size() == 0) {
            log.debug("Validation FAILED for session indices: at least one session index is required");
            vr = new ValidationResult(OasisNames.REQUESTER);
        }
    }

    // validation done
    if (vr == null) {
        vr = new ValidationResult(); // success
    }
    return vr;
}