List of usage examples for java.lang Exception getLocalizedMessage
public String getLocalizedMessage()
From source file:com.jaspersoft.jasperserver.rest.services.RESTRole.java
@Override protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServiceException { try {//from w w w .j a v a2 s. com WSRole role = restUtils.unmarshal(WSRole.class, req.getInputStream()); role = restUtils.populateServiceObject(role); if (userAndRoleManagementService.findRoles(wsRoleToWSRoleSearchCriteria(role)).length == 0) { userAndRoleManagementService.putRole(role); restUtils.setStatusAndBody(HttpServletResponse.SC_CREATED, resp, ""); } else { throw new IllegalArgumentException( "can not create new role: " + role.getRoleName() + ". it already exists"); } } catch (Exception e) { throw new ServiceException(HttpServletResponse.SC_BAD_REQUEST, e.getLocalizedMessage()); } }
From source file:com.wonders.bud.freshmommy.web.asq.controller.AsqResultController.java
@RequestMapping(value = "/add", method = RequestMethod.POST) @ResponseBody//w w w .j ava2 s.c o m public RestMsg<Object> addResult(HttpServletRequest request) { RestMsg<Object> rm = new RestMsg<Object>(); // ? String qType = request.getParameter("q_Type"); String month = request.getParameter("b_Month"); String rDesc = request.getParameter("r_rDesc"); if (StringUtils.isBlank(qType)) { rm.errorMsg("?"); return rm; } if (StringUtils.isBlank(month)) { rm.errorMsg("???"); return rm; } if (StringUtils.isBlank(rDesc)) { rm.errorMsg("??"); return rm; } Map<String, Object> map = new HashMap<String, Object>(); map.put("qType", Integer.valueOf(qType)); map.put("month", Integer.valueOf(month)); if (asqResultService.duplicatecheck(null, map)) { rm.errorMsg("????"); return rm; } try { AsqResultPO po = new AsqResultPO(); po.setqType(Integer.valueOf(qType)); po.setMonth(Integer.valueOf(month)); po.setrDesc(rDesc); po = asqResultService.save(po); rm.successMsg("??"); } catch (Exception e) { log.error(e.getLocalizedMessage()); rm.errorMsg("??"); } return rm; }
From source file:com.epam.dlab.backendapi.service.impl.GitCredentialServiceImpl.java
@Override public ExploratoryGitCredsDTO getGitCredentials(String user) { log.debug("Loading GIT creds for user {}", user); try {/* w ww . ja v a 2 s. c o m*/ return gitCredsDAO.findGitCreds(user, CLEAR_USER_PASSWORD); } catch (Exception t) { log.error("Cannot load list of GIT creds for user: {}", user, t); throw new DlabException( String.format("Cannot load GIT credentials for user %s: %s", user, t.getLocalizedMessage()), t); } }
From source file:com.ugam.collage.plus.controller.people_count.TeamStructureController.java
@RequestMapping(value = "/save", method = RequestMethod.POST) public @ResponseBody Map<String, Object> save(HttpServletRequest httpServletRequest, @ModelAttribute("pcTeamStructureVo") PCTeamStructureVo pcTeamStructureVo, Locale locale, Model model) { Map<String, Object> returnData = new HashMap<String, Object>(); try {/*from w ww . j av a 2s . c o m*/ int loggedInUserId = authService.getLoggedInUserDetails().getId(); if (loggedInUserId != pcTeamStructureVo.getMgrEmployeeId() && !authService.userHasAccessLevel("L3")) { return returnData; } Map<String, String[]> parameterMap = httpServletRequest.getParameterMap(); pcTeamStructureVo.extractAssignedEmployees(parameterMap); pcTeamStructureVo.extractProjectEmpCount(parameterMap); pcTeamStructureVo.extractEmpRules(parameterMap); pcTeamStructureVo.extractProportions(parameterMap); pcTeamStructureVo.extractApportionApproachs(parameterMap); teamStructureService.saveTeamStructure(pcTeamStructureVo); returnData.put("success", "true"); returnData.put("message", "Saved"); } catch (Exception e) { returnData.put("success", "false"); returnData.put("message", "Error reading/saving Data from UI - " + e.getLocalizedMessage()); logger.error("Error reading/saving Data from UI", e); } return returnData; }
From source file:co.turnus.analysis.profiler.orcc.dynamic.OrccDynamicProfilerApplication.java
@Override public Object start(IApplicationContext context) throws Exception { CommandLineParser parser = new PosixParser(); CommandLine commandLine = parser.parse(cliOptions, (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS)); if (commandLine.hasOption('h')) { printUsage();// w w w . ja va2 s. c o m return IApplication.EXIT_RELAUNCH; } try { Configuration configuration = OrccDynamicProfilerOptions.getConfiguration(commandLine); disableAutoBuild(); // set the log level boolean verbose = configuration.getBoolean(VERBOSE, false); OrccLogger.setLevel(verbose ? OrccLogger.ALL : OrccLogger.TRACE); // build, configure and launch the profiler OrccDynamicProfiler profiler = new OrccDynamicProfiler(); profiler.setConfiguration(configuration); profiler.start(); } catch (CoreException ce) { OrccLogger.severeln("Unable to set the workspace properties."); restoreAutoBuild(); return IApplication.EXIT_RELAUNCH; } catch (Exception e) { OrccLogger.severeln("Something went wrong: " + e.getLocalizedMessage()); restoreAutoBuild(); return IApplication.EXIT_RELAUNCH; } finally { restoreAutoBuild(); } return IApplication.EXIT_OK; }
From source file:in.bookmylab.controllers.BaseController.java
protected void handleActionError(Exception e) throws IOException { if (e instanceof AppException) { sendJsonResponse(Status.ERROR, e.getLocalizedMessage()); } else {// w w w.j av a 2s . co m sendJsonResponse(Status.ERROR, "Error occurred while processing your request. Please retry later or contact the administrator."); } logger.log(Level.SEVERE, "Error occured. ", e); }
From source file:pl.datamatica.traccar.api.fcm.Daemon.java
protected void sendToFcm(EntityManager em, FcmNotificationDto dto) { Gson gson = Context.getInstance().getGson(); String message = gson.toJson(dto); String result = sendToFcm(message); boolean success = false; if (result != null) { try {//w w w . j a v a 2s. co m JsonParser parser = new JsonParser(); JsonObject o = parser.parse(result).getAsJsonObject(); success = o.get("success").getAsInt() == 1; if (!success) Logger.getLogger(Daemon.class.getName()).log(Level.INFO, o.getAsJsonArray("results").toString()); } catch (Exception e) { // Probably incorrect fcm scret -> incorrect response JSON Logger.getLogger(Daemon.class.getName()).log(Level.INFO, e.getLocalizedMessage()); } } NotificationStatus ns = new NotificationStatus(dto.getTo(), dto.getKind(), success); em.persist(ns); }
From source file:fr.univsavoie.ltp.client.LoginActivity.java
/** * Pav de code permetant de se connecter de faon scuris au serveur *//*from ww w. j av a 2 s . c o m*/ private void auth() { try { HttpRequestInterceptor preemptiveAuth = new HttpRequestInterceptor() { public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); CredentialsProvider credsProvider = (CredentialsProvider) context .getAttribute(ClientContext.CREDS_PROVIDER); HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); if (authState.getAuthScheme() == null) { AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort()); Credentials creds = credsProvider.getCredentials(authScope); if (creds != null) { authState.setAuthScheme(new BasicScheme()); authState.setCredentials(creds); } } } }; // Setup a custom SSL Factory object which simply ignore the certificates validation and accept all type of self signed certificates SSLSocketFactory sslFactory = new SimpleSSLSocketFactory(null); sslFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); // Enable HTTP parameters HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.UTF_8); // Register the HTTP and HTTPS Protocols. For HTTPS, register our custom SSL Factory object. SchemeRegistry registry = new SchemeRegistry(); // registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); registry.register(new Scheme("https", sslFactory, 443)); // Create a new connection manager using the newly created registry and then create a new HTTP client using this connection manager ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry); httpClient = new DefaultHttpClient(ccm, params); CredentialsProvider authCred = new BasicCredentialsProvider(); Credentials creds = new UsernamePasswordCredentials(login.getText().toString(), password.getText().toString()); authCred.setCredentials(AuthScope.ANY, creds); httpClient.addRequestInterceptor(preemptiveAuth, 0); httpClient.setCredentialsProvider(authCred); } catch (Exception e) { Log.e("Catch", "Auth: " + e.getLocalizedMessage()); } }
From source file:com.jgeppert.struts2.jquery.grid.showcase.action.EditCustomerAction.java
public String execute() throws Exception { log.debug("Edit Customer :" + id); Customers customer;/*w ww .j ava 2 s. c o m*/ try { if (oper.equalsIgnoreCase("add")) { log.debug("Add Customer"); customer = new Customers(); int nextid = customersDao.nextCustomerNumber(); log.debug("Id for ne Customer is " + nextid); customer.setCustomernumber(nextid); customer.setCustomername(customername); customer.setCountry(country); customer.setCity(city); customer.setCreditlimit(creditlimit); customer.setContactfirstname(contactfirstname); customer.setContactlastname(contactlastname); if (salesemployee != null) { customer.setSalesemployee(employeeDao.get(salesemployee.getEmployeenumber())); } customersDao.save(customer); } else if (oper.equalsIgnoreCase("edit")) { log.debug("Edit Customer"); customer = customersDao.get(Integer.parseInt(id)); customer.setCustomername(customername); customer.setCountry(country); customer.setCity(city); customer.setCreditlimit(creditlimit); customer.setContactfirstname(contactfirstname); customer.setContactlastname(contactlastname); if (salesemployee != null) { customer.setSalesemployee(employeeDao.get(salesemployee.getEmployeenumber())); } customersDao.update(customer); } else if (oper.equalsIgnoreCase("del")) { StringTokenizer ids = new StringTokenizer(id, ","); while (ids.hasMoreTokens()) { int removeId = Integer.parseInt(ids.nextToken()); log.debug("Delete Customer " + removeId); customersDao.delete(removeId); } } // Commit changes hTransaction.commit(); } catch (Exception e) { hTransaction.rollback(); addActionError("ERROR : " + e.getLocalizedMessage()); addActionError("Is Database in read/write modus?"); return "error"; } return NONE; }
From source file:org.openxdata.server.servlet.MultimediaServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //Setting header from hear ensures that user is not given a blank page //if there is not data response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", -1); response.setHeader("Cache-Control", "no-store"); String sFormId = request.getParameter("formId"); String xpath = request.getParameter("xpath"); String contentType = request.getParameter("contentType"); String name = request.getParameter("name"); if ("recentbinary".equals(request.getParameter("action"))) { byte[] postData = (byte[]) getSessionData(request, sFormId, KEY_MULTIMEDIA_POST_DATA + getFieldKey(sFormId, xpath)); //(byte[])session.getAttribute(KEY_MULTIMEDIA_POST_DATA+getFieldKey(sFormId,xpath)); if (postData != null) { response.setContentType((String) getSessionData(request, sFormId, KEY_MULTIMEDIA_POST_CONTENT_TYPE + getFieldKey(sFormId, xpath))); response.getOutputStream().write(postData); setSessionData(request, sFormId, KEY_MULTIMEDIA_POST_CONTENT_TYPE + getFieldKey(sFormId, xpath), null);/*from w ww .j a v a 2s.c om*/ setSessionData(request, sFormId, KEY_MULTIMEDIA_POST_DATA + getFieldKey(sFormId, xpath), null); } return; } try { if (name == null || name.trim().length() == 0) name = "multimedia.3gp"; if (sFormId == null || sFormId.trim().length() == 0) return; if (xpath == null || xpath.trim().length() == 0) return; byte[] bytes = (byte[]) getSessionData(request, sFormId, KEY_MULTIMEDIA_POST_DATA + getFieldKey(sFormId, xpath)); String value = null; if (bytes == null) { int id = Integer.parseInt(sFormId); FormData formData = studyManagerService.getFormData(id); if (formData == null) return; String xml = formData.getData(); if (xml == null || xml.trim().length() == 0) return; Document doc = XmlUtil.fromString2Doc(xml); if (doc == null) return; value = XmlUtil.getNodeValue(doc, xpath); } if (bytes != null || (value != null && value.trim().length() > 0)) { if (bytes == null) bytes = Base64.decodeBase64(value.getBytes()); if (bytes != null) { if (contentType != null && contentType.trim().length() > 0) { response.setContentType(contentType); //Send it as an attachement such that atleast firefox can also detect it if (contentType.contains("video") || contentType.contains("audio")) response.setHeader(OpenXDataConstants.HTTP_HEADER_CONTENT_DISPOSITION, OpenXDataConstants.HTTP_HEADER_CONTENT_DISPOSITION_VALUE + name + "\""); } response.getOutputStream().write(bytes); } } //This elese if is to prevent a blank page if there is no data. else if (contentType != null && (contentType.contains("video") || contentType.contains("audio"))) response.setHeader(OpenXDataConstants.HTTP_HEADER_CONTENT_DISPOSITION, OpenXDataConstants.HTTP_HEADER_CONTENT_DISPOSITION_VALUE + name + "\""); } catch (Exception ex) { log.error(ex.getLocalizedMessage(), ex); } }