Example usage for java.lang Exception getLocalizedMessage

List of usage examples for java.lang Exception getLocalizedMessage

Introduction

In this page you can find the example usage for java.lang Exception getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:com.sliit.rules.RuleContainer.java

public Map<String, String> evaluateModel() {

    Map<String, String> evaluationSummary = new HashMap<String, String>();
    try {// ww w.j  a v a 2  s . co  m

        instances.setClassIndex(instances.numAttributes() - 1);
        Evaluation evaluation = new Evaluation(instances);
        evaluation.evaluateModel(ruleMoldel, instances);
        ArrayList<Rule> rulesList = ruleMoldel.getRuleset();
        String rules = ruleMoldel.toString();
        evaluationSummary.put("rules", rules);
        evaluationSummary.put("summary", evaluation.toSummaryString());
        evaluationSummary.put("confusion_matrix", evaluation.toMatrixString());
    } catch (Exception e) {

        log.error("Error occurred:" + e.getLocalizedMessage());
    }
    return evaluationSummary;
}

From source file:com.sqewd.open.dal.core.persistence.query.EntityListSorter.java

public int compare(final AbstractEntity o1, final AbstractEntity o2) {
    int retval = 0;
    for (SortColumn column : columns) {
        try {/*  ww  w.  ja  v  a  2s  .  c  om*/
            retval = compare(o1, o2, column);
            if (retval != 0)
                return retval;
        } catch (Exception e) {
            log.debug("[" + column.getColumn() + "] : " + e.getLocalizedMessage());
            LogUtils.stacktrace(log, e);
            return 0;
        }
    }
    return retval;
}

From source file:cz.zcu.kiv.eeg.mobile.base.ws.asynctask.RemoveReservation.java

/**
 * Method, where reservation information is pushed to server in order to remove it.
 * All heavy lifting is made here.//ww w.  j a  va  2  s. c  om
 *
 * @param params only one Reservation object is accepted
 * @return true if reservation is removed
 */
@Override
protected Boolean doInBackground(Reservation... params) {

    Reservation data = params[0];

    //nothing to remove
    if (data == null)
        return false;

    try {

        setState(RUNNING, R.string.working_ws_remove);

        SharedPreferences credentials = getCredentials();
        String username = credentials.getString("username", null);
        String password = credentials.getString("password", null);
        String url = credentials.getString("url", null) + Values.SERVICE_RESERVATION + data.getReservationId();

        HttpAuthentication authHeader = new HttpBasicAuthentication(username, password);
        HttpHeaders requestHeaders = new HttpHeaders();
        requestHeaders.setAuthorization(authHeader);
        HttpEntity<Reservation> entity = new HttpEntity<Reservation>(requestHeaders);

        SSLSimpleClientHttpRequestFactory factory = new SSLSimpleClientHttpRequestFactory();
        // Create a new RestTemplate instance
        RestTemplate restTemplate = new RestTemplate(factory);
        restTemplate.getMessageConverters().add(new StringHttpMessageConverter());

        Log.d(TAG, url + "\n" + entity);
        restTemplate.exchange(url, HttpMethod.DELETE, entity, String.class);
        return true;
    } catch (Exception e) {
        Log.e(TAG, e.getLocalizedMessage());
        setState(ERROR, e);
    } finally {
        setState(DONE);
    }
    return false;
}

From source file:it.geosolutions.geoserver.jms.JMSPublisher.java

/**
 * Used to publish the event on the queue.
 * /*from ww w .j  a v  a2 s . c  om*/
 * @param <S> a serializable object
 * @param <O> the object to serialize using a JMSEventHandler
 * @param destination
 * @param jmsTemplate the template to use to publish on the topic <br>
 *        (default destination should be already set)
 * @param props the JMSProperties used by this instance of GeoServer
 * @param object the object (or event) to serialize and send on the JMS topic
 * 
 * @throws JMSException
 */
public <S extends Serializable, O> void publish(final Topic destination, final JmsTemplate jmsTemplate,
        final Properties props, final O object) throws JMSException {
    try {

        final JMSEventHandler<S, O> handler = jmsManager.getHandler(object);

        // set the used SPI
        props.put(JMSEventHandlerSPI.getKeyName(), handler.getGeneratorClass().getSimpleName());

        // TODO make this configurable
        final MessageCreator creator = new JMSObjectMessageCreator(handler.serialize(object), props);

        jmsTemplate.send(destination, creator);

    } catch (Exception e) {
        if (LOGGER.isLoggable(java.util.logging.Level.SEVERE)) {
            LOGGER.severe(e.getLocalizedMessage());
        }
        final JMSException ex = new JMSException(e.getLocalizedMessage());
        ex.initCause(e);
        throw ex;
    }
}

From source file:com.dchq.docker.volume.driver.adaptor.LocalVolumeAdaptorImpl.java

@Override
public BaseResponse remove(RemoveRequest request) {
    BaseResponse response = new BaseResponse();
    try {//from  w w  w  .j  a  va  2 s. c om
        File file = new File(new File(TMP_LOC), request.getName());
        FileUtils.forceDelete(file);
        logger.info("Removed Volume [{}] on path [{}]", file.getName(), file.getAbsoluteFile());
    } catch (Exception e) {
        logger.warn(e.getLocalizedMessage(), e);
        response.setErr(e.getLocalizedMessage());
    }
    return response;
}

From source file:org.jbpm.formbuilder.server.ExportTemplateServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String profile = req.getParameter("profile");
    try {/*from   www .  j a  v a2 s . c  om*/
        if (notEmpty(profile) && "jbpm".equals(profile)) {
            String uuid = req.getParameter("uuid");
            TaskDefinitionService taskService = createTaskService(req);
            FormDefinitionService formService = createFormService(req);
            String packageName = taskService.getContainingPackage(uuid);
            FormRepresentation form = formService.getFormByUUID(packageName, uuid);
            if (notEmpty(form.getProcessName()) || notEmpty(form.getTaskId())) {
                Translator translator = TranslatorFactory.getInstance().getTranslator("ftl");
                URL url = translator.translateForm(form);
                String content = IOUtils.toString(url.openStream());
                String templateName = "";
                if (!notEmpty(form.getTaskId())
                        || ProcessGetInputHandler.PROCESS_INPUT_NAME.equals(form.getTaskId())) {
                    templateName = form.getProcessName();
                } else {
                    templateName = form.getTaskId();
                }
                if (templateName != null && !"".equals(templateName)) {
                    templateName += "-taskform.ftl";
                    templateName = URLEncoder.encode(templateName, "UTF-8");
                    formService.saveTemplate(packageName, templateName, content);
                }
            }
        } else {
            throw new Exception("Profile not available for " + profile);
        }
    } catch (Exception e) {
        resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getLocalizedMessage());
    }
}

From source file:com.amalto.core.save.generator.HazelcastAutoIncrementGenerator.java

@Override
public synchronized void init() {
    CONFIGURATION.evictAll();/*w  w  w.j a v  a2  s . c  om*/
    try {
        ItemPOJOPK pk = new ItemPOJOPK(DC, AUTO_INCREMENT, IDS);
        ItemPOJO itempojo = ItemPOJO.load(pk);
        if (itempojo == null) {
            LOGGER.info("Could not load configuration from database, use default configuration.");
        } else {
            String xml = itempojo.getProjectionAsString();
            if (StringUtils.isNotBlank(xml)) {
                Properties properties = Util.convertAutoIncrement(xml);
                for (Entry<Object, Object> entry : properties.entrySet()) {
                    String key = entry.getKey().toString();
                    CONFIGURATION.lock(key);
                    try {
                        CONFIGURATION.put(key, Long.valueOf(entry.getValue().toString()));
                    } finally {
                        CONFIGURATION.unlock(key);
                    }
                }
            }
        }
        WAS_INIT_CALLED.set(1);
    } catch (Exception e) {
        LOGGER.error(e.getLocalizedMessage(), e);
    }
}

From source file:com.dchq.docker.volume.driver.adaptor.LocalVolumeAdaptorImpl.java

@Override
public BaseResponse create(CreateRequest request) {
    BaseResponse response = new BaseResponse();
    try {/*w  w w  .  j a  v a 2s .c o  m*/
        File file = new File(new File(TMP_LOC), request.getName());
        FileUtils.forceMkdir(file);
        logger.info("Created Volume [{}] on path [{}]", file.getName(), file.getAbsoluteFile());

    } catch (Exception e) {
        logger.warn(e.getLocalizedMessage(), e);
        response.setErr(e.getLocalizedMessage());
    }
    return response;
}

From source file:com.dchq.docker.volume.driver.adaptor.LocalVolumeAdaptorImpl.java

@Override
public MountResponse mount(MountRequest request) {
    MountResponse response = new MountResponse();
    try {// w w  w  .  j  a v a  2s  .c om
        File file = new File(new File(TMP_LOC), request.getName());
        if (file.isDirectory()) {
            response.setMountpoint(file.getAbsolutePath());
        }
        logger.info("Mounted Volume [{}] on path [{}]", file.getName(), file.getAbsoluteFile());
    } catch (Exception e) {
        logger.warn(e.getLocalizedMessage(), e);
        response.setErr(e.getLocalizedMessage());
    }
    return response;
}

From source file:com.phonegap.plugins.CloudStorage.java

/**
  * Executes the request and returns PluginResult.
  */*w w w  . j  av  a2s .com*/
  * @param action        The action to execute.
  * @param data          JSONArry of arguments for the plugin.
  *                   'url': server url for upload
  *                   'file URI': URI of file to upload
 *                   'X-Auth-Token': authentication header to use for this request
  * @param callbackId    The callback id used when calling back into JavaScript.
  * @return              A PluginResult object with a status and message.
  * 
  */
public PluginResult execute(String action, JSONArray data, String callbackId) {
    PluginResult result = null;
    if (ACTION_UPLOAD.equals(action) || ACTION_STORE.equals(action)) {
        try {
            String serverUrl = data.get(0).toString();
            String imageURI = data.getString(1).toString();
            String token = null;
            if (ACTION_UPLOAD.equals(action)) {
                token = data.getString(2).toString();
            }

            File file = new File(new URI(imageURI));
            try {
                HttpClient httpclient = new DefaultHttpClient();

                HttpPut httpput = new HttpPut(serverUrl);

                InputStreamEntity reqEntity = new InputStreamEntity(new FileInputStream(file), -1);
                if (ACTION_UPLOAD.equals(action)) {
                    reqEntity.setContentType("binary/octet-stream");
                    reqEntity.setChunked(true); // Send in multiple parts if needed
                } else {
                    reqEntity.setContentType("image/jpg");
                }

                httpput.setEntity(reqEntity);
                if (token != null) {
                    httpput.addHeader("X-Auth-Token", token);
                }

                HttpResponse response = httpclient.execute(httpput);
                Log.d(LOG_TAG, "http response: " + response.getStatusLine().getStatusCode()
                        + response.getStatusLine().getReasonPhrase());
                //Do something with response...
                result = new PluginResult(Status.OK, response.getStatusLine().getStatusCode());
            } catch (Exception e) {
                Log.d(LOG_TAG, e.getLocalizedMessage());
                result = new PluginResult(Status.ERROR);
            }
        } catch (JSONException e) {
            Log.d(LOG_TAG, e.getLocalizedMessage());
            result = new PluginResult(Status.JSON_EXCEPTION);
        } catch (Exception e1) {
            Log.d(LOG_TAG, e1.getLocalizedMessage());
            result = new PluginResult(Status.ERROR);
        }
    }
    return result;
}