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:org.metis.cassandra.SimpleContextTest.java

/**
 * Simple test that loads text Spring XML file
 *//*from  w w w. j  av a  2s .co  m*/
@Test
public void TestA() {

    if (cc == null) {
        fail("ERROR: unable to load context");
    }

    CqlComponent cc = CqlComponent.cqlComponent("cassandra.xml");
    try {
        cc.start();
        Thread.sleep(500);
        assertTrue(cc.isStarted());
        assertTrue(cc.getComponentProfile() != null);
        assertTrue(cc.getClients() != null);
        assertTrue(cc.getClients().isEmpty() == false);
        Endpoint endpoint = cc.createEndpoint("cql://user", "user", null);
        assertTrue(endpoint != null);
        assertTrue(endpoint instanceof CqlEndpoint);
        CqlEndpoint ce = (CqlEndpoint) endpoint;
        assertTrue(ce.getClient() != null);
    } catch (Exception exc) {
        fail("caught this exception: " + exc.getLocalizedMessage());
    }

}

From source file:fossasia.valentina.bodyapp.sync.Sync.java

/**
 * Method which makes all the POST calls
 * //ww w  .j a v  a 2s .  c o  m
 * @param url
 * @param json
 * @return
 */
public String POST(String url, String json, int conTimeOut, int socTimeOut) {

    InputStream inputStream = null;
    String result = "";
    try {

        HttpParams httpParameters = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParameters, conTimeOut);
        HttpConnectionParams.setSoTimeout(httpParameters, socTimeOut);
        HttpClient httpclient = new DefaultHttpClient(httpParameters);
        HttpPost httpPost = new HttpPost(url);
        StringEntity se = new StringEntity(json);
        httpPost.setEntity(se);
        httpPost.setHeader("Accept", "application/json");
        httpPost.setHeader("Content-type", "application/json");
        HttpResponse httpResponse = httpclient.execute(httpPost);
        inputStream = httpResponse.getEntity().getContent();

        if (inputStream != null)
            result = convertInputStreamToString(inputStream);
        else
            result = "Did not work!";
        System.out.println(result + "result");

    } catch (Exception e) {
        Log.d("InputStream", e.getLocalizedMessage());
    }

    return result;
}

From source file:com.swordlord.gozer.components.csv.GCsvReport.java

/**
 * //from   ww w.j ava2  s. c om
 * @param gfe
 * @param report
 * @param app
 * @param session
 */
public GCsvReport(IGozerFrameExtension gfe, GReport report, Application app, IGozerSessionInfo session) {
    super(gfe);

    try {
        _app = app;
        _session = session;

        // TODO fix this
        String strReportFile = UserPrefs.APP_REPORT_GOZER_FILES_FOLDER + report.getDefiniton();

        DefaultReportPanelExtension ext = new DefaultReportPanelExtension(session, strReportFile,
                gfe.getDataBindingContext());

        SAXBuilder sb = new SAXBuilder();
        Document document = sb.build(ResourceLoader.loadResource(_app, strReportFile, getClass()));

        Parser parser = new Parser(ext.getDataBindingContext());
        parser.createTree(document);

        _ot = parser.getTree();

        _context = new GWReportContext(null, ext, GozerDisplayMode.PDF, _ot);
    } catch (Exception e) {
        LOG.warn(e.getLocalizedMessage());
    }

}

From source file:nl.mawoo.wcmmanager.services.WCMScriptService.java

public ExecutionResult run(String content) throws ScriptException {
    ExecutionResult result = new ExecutionResult(UUID.randomUUID());
    WCMScript wcmScript = new WCMScript(result.getExecutionId(),
            new LoggingConfig(new ScriptLoggerImpl(result)));
    result.initDone();//from w  w  w .j  a va 2s  . com
    try {
        wcmScript.eval(content);
    } catch (Exception e) {
        String message = e.getLocalizedMessage();

        if (message == null) {
            message = e.getClass().getSimpleName();
        }

        result.setError(message);
    }
    result.executionDone();
    return result;
}

From source file:com.kylinolap.job.hadoop.cube.RowKeyDistributionCheckerJob.java

@Override
public int run(String[] args) throws Exception {
    Options options = new Options();

    try {//from ww w . java  2 s. co m
        options.addOption(OPTION_INPUT_PATH);
        options.addOption(OPTION_OUTPUT_PATH);
        options.addOption(OPTION_JOB_NAME);
        options.addOption(rowKeyStatsFilePath);

        parseOptions(options, args);

        String statsFilePath = getOptionValue(rowKeyStatsFilePath);

        // start job
        String jobName = getOptionValue(OPTION_JOB_NAME);
        job = Job.getInstance(getConf(), jobName);

        job.setJarByClass(this.getClass());

        addInputDirs(getOptionValue(OPTION_INPUT_PATH), job);

        Path output = new Path(getOptionValue(OPTION_OUTPUT_PATH));
        FileOutputFormat.setOutputPath(job, output);

        // Mapper
        job.setInputFormatClass(SequenceFileInputFormat.class);
        job.setMapperClass(RowKeyDistributionCheckerMapper.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(LongWritable.class);

        // Reducer - only one
        job.setReducerClass(RowKeyDistributionCheckerReducer.class);
        job.setOutputFormatClass(SequenceFileOutputFormat.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(LongWritable.class);
        job.setNumReduceTasks(1);

        job.getConfiguration().set("rowKeyStatsFilePath", statsFilePath);

        this.deletePath(job.getConfiguration(), output);

        return waitForCompletion(job);
    } catch (Exception e) {
        printUsage(options);
        log.error(e.getLocalizedMessage(), e);
        return 2;
    }
}

From source file:things.view.rest.ThingRestExceptionHandler.java

@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody/*from  w ww. ja  v a2s.  c o m*/
public ErrorInfo exception(final HttpServletRequest req, final Exception ex) {

    myLogger.debug("Exception: " + ex.getLocalizedMessage(), ex);

    return new ErrorInfo(req.getRequestURL().toString(), ex);
}

From source file:ru.codemine.pos.service.StoreServiceTest.java

@Before
public void init() {
    store = new Store("TheTestStore");

    p1 = new Product("art001", "name01", "123456", 10.0);
    p2 = new Product("art002", "name02", "223456", 20.0);
    p3 = new Product("art003", "name03", "323456", 40.0);

    try {/*from  w ww.j a v a2 s.  co m*/
        productService.create(p1);
        productService.create(p2);
        productService.create(p3);
    } catch (Exception e) {
        log.info(e.getLocalizedMessage());
    }

    store.getStocks().put(p1, 1);
    store.getStocks().put(p2, 5);
}

From source file:com.kylinolap.rest.controller.ProjectController.java

@RequestMapping(value = "/{projectName}", method = { RequestMethod.DELETE })
@ResponseBody/* w  ww. j a  v a 2  s .  co  m*/
@Metered(name = "deleteProject")
public void deleteProject(@PathVariable String projectName) {
    try {
        projectService.deleteProject(projectName);
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException("Failed to delete project. " + " Caused by: " + e.getMessage(), e);
    }
}

From source file:com.sqewd.open.dal.api.persistence.AbstractEntity.java

@Override
public String toString() {
    StringBuffer buff = new StringBuffer("\n");
    try {//from  w  w w .  j  a  v a2  s. c o m
        StructEntityReflect enref = ReflectionUtils.get().getEntityMetadata(this.getClass());
        buff.append("[ENTITY:").append(enref.Entity).append("(").append(enref.Class).append(")");
        for (StructAttributeReflect attr : enref.Attributes) {
            buff.append("\n\t[").append(attr.Column).append(":")
                    .append(PropertyUtils.getSimpleProperty(this, attr.Field.getName())).append("]");
        }
        buff.append("\n]");
    } catch (Exception e) {
        buff.append(e.getLocalizedMessage());
    }
    return buff.toString();
}

From source file:es.tid.cosmos.platform.injection.server.InjectionServer.java

/**
 * Sets up and start an SFTP server./*from  w  w  w  . jav  a  2s . co  m*/
 */
public void setupSftpServer() {
    SshServer sshd = SshServer.setUpDefaultServer();

    // general settings
    sshd.setFileSystemFactory(hadoopFileSystemFactory);
    sshd.setPort(this.configuration.getPort());
    sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser"));

    // user authentication settings
    sshd.setPasswordAuthenticator(setupPasswordAuthenticator());
    List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>();
    userAuthFactories.add(new UserAuthPassword.Factory());
    sshd.setUserAuthFactories(userAuthFactories);

    // command settings
    sshd.setCommandFactory(new ScpCommandFactory());

    // subsystem settings
    List<NamedFactory<Command>> namedFactoryList = new ArrayList<NamedFactory<Command>>();
    namedFactoryList.add(new SftpSubsystem.Factory());
    sshd.setSubsystemFactories(namedFactoryList);

    try {
        sshd.start();
    } catch (Exception e) {
        LOG.error(e.getLocalizedMessage());
    } // try catch
}