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.amalto.workbench.actions.XSDSetAnnotationSourceSystemAction.java

public IStatus doAction() {
    try {/*from w ww .j ava  2s.co  m*/
        IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection();
        XSDComponent xSDCom = null;
        if (selection.getFirstElement() instanceof Element) {
            TreePath tPath = ((TreeSelection) selection).getPaths()[0];
            for (int i = 0; i < tPath.getSegmentCount(); i++) {
                if (tPath.getSegment(i) instanceof XSDAnnotation)
                    xSDCom = (XSDAnnotation) (tPath.getSegment(i));
            }
        } else
            xSDCom = (XSDComponent) selection.getFirstElement();
        XSDAnnotationsStructure struc = new XSDAnnotationsStructure(xSDCom);
        // IStructuredSelection selection = (IStructuredSelection)page.getTreeViewer().getSelection();
        // XSDAnnotationsStructure struc = new XSDAnnotationsStructure((XSDComponent)selection.getFirstElement());
        if (struc.getAnnotation() == null) {
            throw new RuntimeException(Messages.bind(Messages.ExceptionInfo, xSDCom.getClass().getName()));
        }

        InputDialog id = new InputDialog(page.getSite().getShell(), Messages.XSDSetAnnoXX_DialogTitle1,
                Messages.XSDSetAnnoXX_DialogTip, struc.getSourceSystem(), new IInputValidator() {

                    public String isValid(String newText) {
                        return null;
                    };
                });

        id.setBlockOnOpen(true);
        int ret = id.open();
        if (ret == Window.CANCEL) {
            return Status.CANCEL_STATUS;
        }

        struc.setSourceSystem("".equals(id.getValue()) ? null : id.getValue());//$NON-NLS-1$

        if (struc.hasChanged()) {
            page.refresh();
            page.getTreeViewer().expandToLevel(xSDCom, 2);
            page.markDirty();
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.XSDSetAnnoXX_ErrorMsg1, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}

From source file:hr.diskobolos.controller.MemberRegisterController.java

/**
 * REST service responsible for creating member register data
 *
 * @param memberRegister//  w  ww  .  ja v  a 2 s.  c o m
 * @param request
 * @param response
 * @return
 * @throws JSONException
 */
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAnyRole('ROLE_USER','ROLE_ADMIN')")
public String createMemberRegisterData(@RequestBody MemberRegister memberRegister, HttpServletRequest request,
        HttpServletResponse response) throws JSONException {
    try {
        memberRegister.getEmails().stream().forEach((email) -> {
            email.setMemberRegister(memberRegister);
        });
        memberRegister.getBankAccounts().stream().forEach((bankAccounts) -> {
            bankAccounts.setMemberRegister(memberRegister);
        });

        List<Phone> phones = mapPhoneDtoToPhoneModelObject(memberRegister.getPhonesDto());
        phones.stream().forEach((phone) -> {
            phone.setMemberRegister(memberRegister);
        });
        memberRegister.setPhones(phones);

        memberRegisterService.persist(memberRegister);
        response.setStatus(HttpServletResponse.SC_OK);
        return new JSONObject().put("result", 200).toString();
    } catch (Exception e) {
        logger.error("Error during creation of member register data: ", e.getLocalizedMessage());
        return ErrorHandlerUtils.handleAjaxError(request, response);
    }
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SetStudyTreeListener.java

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    this.columnsDone = new HashMap<String, Vector<Integer>>();
    for (File rawFile : ((ClinicalData) this.dataType).getRawFiles()) {
        this.columnsDone.put(rawFile.getName(), new Vector<Integer>());
    }//  w w w.  j  a v a  2  s  .  c o m
    if (((ClinicalData) this.dataType).getCMF() == null) {
        this.setStudyTreeUI.displayMessage("Error: no column mapping file");
        return;
    }
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".columns.tmp");
    try {
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write(
                "Filename\tCategory Code\tColumn Number\tData Label\tData Label Source\tControlled Vocab Code\n");

        try {
            BufferedReader br = new BufferedReader(new FileReader(((ClinicalData) this.dataType).getCMF()));
            String line = br.readLine();
            while ((line = br.readLine()) != null) {
                if (line.split("\t", -1)[3].compareTo("SUBJ_ID") == 0
                        || line.split("\t", -1)[3].compareTo("VISIT_NAME") == 0
                        || line.split("\t", -1)[3].compareTo("SITE_ID") == 0) {
                    out.write(line + "\n");
                    this.columnsDone.get(line.split("\t", -1)[0])
                            .add(Integer.parseInt(line.split("\t", -1)[2]));
                } else if (line.split("\t", -1)[3].compareTo("OMIT") != 0
                        && line.split("\t", -1)[3].compareTo("\\") != 0) {
                    File rawFile = new File(this.dataType.getPath() + File.separator + line.split("\t", -1)[0]);
                    this.labels.put(
                            FileHandler.getColumnByNumber(rawFile, Integer.parseInt(line.split("\t", -1)[2])),
                            line.split("\t", -1)[3]);

                }
            }
            br.close();
        } catch (Exception e) {
            this.setStudyTreeUI.displayMessage("File error: " + e.getLocalizedMessage());
            e.printStackTrace();
            out.close();
        }

        this.writeLine(this.setStudyTreeUI.getRoot(), out, "");

        for (String key : this.columnsDone.keySet()) {
            File rawFile = null;
            for (File f : ((ClinicalData) this.dataType).getRawFiles()) {
                if (f.getName().compareTo(key) == 0) {
                    rawFile = f;
                }
            }
            if (rawFile != null) {
                for (int i = 1; i <= FileHandler.getColumnsNumber(rawFile); i++) {
                    if (!this.columnsDone.get(key).contains(i)) {
                        out.write(key + "\t" + "" + "\t" + i + "\t" + "OMIT" + "\t\t\n");
                    }
                }
            }
        }

        out.close();
        try {
            String fileName = ((ClinicalData) this.dataType).getCMF().getName();
            ((ClinicalData) this.dataType).getCMF().delete();
            File fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            FileUtils.moveFile(file, fileDest);
            ((ClinicalData) this.dataType).setCMF(fileDest);
        } catch (IOException ioe) {
            this.setStudyTreeUI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setStudyTreeUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setStudyTreeUI.displayMessage("Column mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

From source file:com.liveneo.plat.web.action.JobmsgAction.java

public String deleteJobmsg() {
    try {/*from  ww w  . j  a v  a2s .c o m*/
        String selectIDS = this.getRequest().getParameter("selectIDS");
        if (StringUtils.isNotEmpty(selectIDS)) {
            List<String> keyList = new ArrayList<String>();
            keyList = ListUtil.ConvertArrayToStringList(StringUtils.split(selectIDS, ','), "String");
            if (keyList != null) {
                for (String key : keyList) {
                    this.jobmsgService.deleteJobmsg(IntegerUtil.converStrToInteger(key));
                }
            }
        }
        this.logService(getRequest()).addLog(this.getRequest(), "LOGTYPE-SC", "delete jobmsg", BdJobmsg.REF);
        return ajaxForwardSuccess(getText("?!"));
    } catch (Exception ex) {
        return ajaxForwardError(ex.getLocalizedMessage());
    }
}

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

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

    try {//from   w w  w .  j  ava  2 s  .c  om
        options.addOption(OPTION_JOB_NAME);
        options.addOption(OPTION_CUBE_NAME);
        options.addOption(OPTION_SEGMENT_NAME);
        options.addOption(OPTION_INPUT_PATH);
        options.addOption(OPTION_OUTPUT_PATH);
        options.addOption(OPTION_NCUBOID_LEVEL);
        options.addOption(OPTION_INPUT_FORMAT);
        parseOptions(options, args);

        Path input = new Path(getOptionValue(OPTION_INPUT_PATH));
        Path output = new Path(getOptionValue(OPTION_OUTPUT_PATH));
        String cubeName = getOptionValue(OPTION_CUBE_NAME).toUpperCase();
        int nCuboidLevel = Integer.parseInt(getOptionValue(OPTION_NCUBOID_LEVEL));
        String segmentName = getOptionValue(OPTION_SEGMENT_NAME);

        KylinConfig config = KylinConfig.getInstanceFromEnv();
        CubeManager cubeMgr = CubeManager.getInstance(config);
        CubeInstance cube = cubeMgr.getCube(cubeName);

        job = Job.getInstance(getConf(), getOptionValue(OPTION_JOB_NAME));
        System.out.println("Starting: " + job.getJobName());
        FileInputFormat.setInputPaths(job, input);

        File jarFile = new File(config.getKylinJobJarPath());
        if (jarFile.exists()) {
            job.setJar(config.getKylinJobJarPath());
        } else {
            job.setJarByClass(this.getClass());
        }

        // Mapper
        if (this.mapperClass == null) {
            throw new Exception("Mapper class is not set!");
        }

        boolean isInputTextFormat = false;
        if (hasOption(OPTION_INPUT_FORMAT)
                && ("textinputformat".equalsIgnoreCase(getOptionValue(OPTION_INPUT_FORMAT)))) {
            isInputTextFormat = true;
        }

        if (isInputTextFormat) {
            job.setInputFormatClass(TextInputFormat.class);

        } else {
            job.setInputFormatClass(SequenceFileInputFormat.class);
        }
        job.setMapperClass(this.mapperClass);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);
        job.setCombinerClass(CuboidReducer.class); // for base cuboid
                                                   // shuffle skew, some
                                                   // rowkey aggregates far
                                                   // more records than
                                                   // others

        // Reducer
        job.setReducerClass(CuboidReducer.class);
        job.setOutputFormatClass(SequenceFileOutputFormat.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);

        FileOutputFormat.setOutputPath(job, output);

        // set job configuration
        job.getConfiguration().set(BatchConstants.CFG_CUBE_NAME, cubeName);
        job.getConfiguration().set(BatchConstants.CFG_CUBE_SEGMENT_NAME, segmentName);
        // add metadata to distributed cache
        attachKylinPropsAndMetadata(cube, job.getConfiguration());

        setReduceTaskNum(job, config, cubeName, nCuboidLevel);

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

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

From source file:com.photon.phresco.service.admin.actions.ErrorReport.java

public String sendReport() throws PhrescoException {
    if (debugEnabled) {
        LOGGER.debug("ErrorReport.sendReport : Entry");
    }/*  w  w w . j  a v a2  s . c o m*/
    try {
        if (debugEnabled) {
            if (StringUtils.isEmpty(userid)) {
                LOGGER.warn("ErrorReport.sendReport", "status=\"Bad Request\"", "message=\"userId is empty\"");
            }
            LOGGER.info("ErrorReport.sendReport", "userId=" + "\"" + userid);
        }
        if (debugEnabled) {
            if (StringUtils.isEmpty(message)) {
                LOGGER.warn("ErrorReport.sendReport", "status=\"Bad Request\"", "message=\"message is empty\"");
            }
            LOGGER.info("ErrorReport.sendReport", "message=" + "\"" + message);
        }
        if (debugEnabled) {
            if (StringUtils.isEmpty(action)) {
                LOGGER.warn("ErrorReport.sendReport", "status=\"Bad Request\"", "message=\"action is empty\"");
            }
            LOGGER.info("ErrorReport.sendReport", "action=" + "\"" + action);
        }
        LogInfo loginfo = new LogInfo(message, trace, action, userid);
        List<LogInfo> infos = new ArrayList<LogInfo>();
        infos.add(loginfo);
        //           ClientResponse response = getServiceManager().sendErrorReport(infos);
    } catch (Exception e) {
        if (debugEnabled) {
            LOGGER.error("ErrorReport.sendReport", "status=\"Failure\"",
                    "message=\"" + e.getLocalizedMessage() + "\"");
        }
        throw new PhrescoException(e);
    }

    if (debugEnabled) {
        LOGGER.debug("ErrorReport.sendReport() : Exit");
    }
    return "success";
}

From source file:org.fenixedu.ulisboa.integration.sas.ui.spring.controller.manageschoolleveltypemapping.SchoolLevelTypeMappingController.java

@RequestMapping(value = _SEARCH_TO_DELETE_ACTION_URI + "{oid}", method = RequestMethod.POST)
public String processSearchToDeleteAction(@PathVariable("oid") SchoolLevelTypeMapping schoolLevelTypeMapping,
        Model model, RedirectAttributes redirectAttributes) {
    setSchoolLevelTypeMapping(schoolLevelTypeMapping, model);
    try {/*from   www.  j  a v a  2  s  .c o  m*/
        deleteSchoolLevelTypeMapping(schoolLevelTypeMapping);

        addInfoMessage("Sucess deleting SchoolLevelTypeMapping ...", model);
        return redirect("/integration/sas/manageschoolleveltypemapping/schoolleveltypemapping/", model,
                redirectAttributes);
    } catch (Exception ex) {
        addErrorMessage(BundleUtil.getString(SasSpringConfiguration.BUNDLE, "label.error.update")
                + ex.getLocalizedMessage(), model);
    }

    return "integration/sas/manageschoolleveltypemapping/schoolleveltypemapping/search";
}

From source file:prodoc.FTRemote.java

/**
 * Communicates to the OpenProdoc Server by http sending instructionss
 * @param pOrder Order to execute//from   www  . j av  a 2s. co m
 * @param pParam Parameters of the order (can be empty or null depending on order
 * @return an xml node extracted form XML answer.
 * @throws PDException in any error
 */
private Node ReadWrite(String pOrder, String pParam) throws PDException {
    Node OPDObject = null;
    CloseableHttpResponse response2 = null;
    if (PDLog.isDebug()) {
        PDLog.Debug("DriverRemote. ReadWrite: Order:" + pOrder);
        PDLog.Debug("Param:" + pParam);
    }
    try {
        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair(ORDER, pOrder));
        nvps.add(new BasicNameValuePair(PARAM, pParam));
        UrlPost.setEntity(new UrlEncodedFormEntity(nvps));
        response2 = httpclient.execute(UrlPost, context);
        HttpEntity Resp = response2.getEntity();
        Document XMLObjects = DB.parse(Resp.getContent());
        NodeList OPDObjectList = XMLObjects.getElementsByTagName("Result");
        OPDObject = OPDObjectList.item(0);
        if (OPDObject.getTextContent().equalsIgnoreCase("KO")) {
            OPDObjectList = XMLObjects.getElementsByTagName("Msg");
            if (OPDObjectList.getLength() > 0) {
                OPDObject = OPDObjectList.item(0);
                PDException.GenPDException("Server_Error", DriverGeneric.DeCodif(OPDObject.getTextContent()));
            } else
                PDException.GenPDException("Server_Error", "");
        }
        OPDObjectList = XMLObjects.getElementsByTagName("Data");
        OPDObject = OPDObjectList.item(0);
    } catch (Exception ex) {
        if (PDLog.isDebug())
            ex.printStackTrace();
        PDException.GenPDException(ex.getLocalizedMessage(), "");
    } finally {
        if (response2 != null)
            try {
                response2.close();
            } catch (IOException ex) {
                PDException.GenPDException(ex.getLocalizedMessage(), "");
            }
    }
    return (OPDObject);
}

From source file:com.wonders.bud.freshmommy.web.asq.controller.AsqResultController.java

@RequestMapping(value = "/detail", method = RequestMethod.GET)
@ResponseBody//from  www.j a  v  a2  s.c o  m
public RestMsg<AsqResultVO> getById(HttpServletRequest request) {
    RestMsg<AsqResultVO> rm = new RestMsg<AsqResultVO>();

    String rId = request.getParameter("rId");

    try {
        if (StringUtils.isBlank(rId)) {
            rm.errorMsg("??");
            return rm;
        }
        AsqResultPO po = asqResultService.getById(rId);
        AsqResultVO vo = new AsqResultVO();
        BeanUtils.copyProperties(vo, po);
        rm.setResult(vo);
        rm.successMsg();
    } catch (Exception e) {
        rm.errorMsg("??");
        log.error(e.getLocalizedMessage());
    }
    return rm;
}

From source file:it.geosolutions.figis.security.authentication.CredentialsManager.java

public CredentialsManager(String propertiesFile, String usersRoleAdmin, String usersRoleUser, long period)
        throws IOException {
    if (propertiesFile == null) {
        throw new IllegalArgumentException("userca.properties: PROPERTIES_FILE key is null");
    }/*from w w  w.ja  va 2s. c  om*/
    if (usersRoleAdmin == null) {
        throw new IllegalArgumentException("userca.properties: usersRoleAdmin key is null");
    }
    if (usersRoleUser == null) {
        throw new IllegalArgumentException("userca.properties: usersRoleUser key is null");
    }
    if (period <= 0) {
        throw new IllegalArgumentException("Wrong period provided:" + period);
    }

    PROPERTIES_FILE = propertiesFile;

    java.net.URL url = this.getClass().getClassLoader().getResource(propertiesFile);
    try {
        propertyFile = new File(url.toURI());
        if (!propertyFile.isFile() || !propertyFile.canRead() || propertyFile.isHidden()) {
            throw new IllegalArgumentException("Unable to reach file:" + url.toURI().toString() + "\n"
                    + "canRead:" + propertyFile.canRead() + ",isFile:" + propertyFile.isFile() + ",isHidden:"
                    + propertyFile.isHidden());
        }
        lastMod = propertyFile.lastModified();
    } catch (Exception se) {
        LOGGER.error(se.getLocalizedMessage(), se);
        throw new RuntimeException(
                "UsersCheckUtils: error on reading file properties: PROPERTIES_FILE: " + propertiesFile);
    }

    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("Checked PROPERTIES_FILE: " + propertiesFile);
    }
    loadProperties();
    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("Assigned new properties from file: PROPERTIES_FILE: " + propertiesFile);
    }

    // set the period and start the reloader
    this.period = period;
    new CredentialsManager.Reloader().start();
}