List of usage examples for java.lang Exception getLocalizedMessage
public String getLocalizedMessage()
From source file:edu.isi.misd.scanner.network.registry.web.controller.BaseController.java
@ExceptionHandler({ MethodNotAllowedException.class, UnsupportedOperationException.class }) @ResponseBody//from w ww. j a v a 2s.c o m @ResponseStatus(value = HttpStatus.METHOD_NOT_ALLOWED) public ErrorMessage handleMethodNotAllowedException(Exception e) { return new ErrorMessage(HttpStatus.METHOD_NOT_ALLOWED.value(), HttpStatus.METHOD_NOT_ALLOWED.getReasonPhrase(), e.getLocalizedMessage()); }
From source file:edu.du.penrose.systems.fedoraApp.tasks.WorkerTimer.java
public void doIt() { Map<String, WorkerInf> workerList = new HashMap<String, WorkerInf>(); Set<String> remoteConfiguredInstitutions = new HashSet<String>(); Set<String> taskConfiguredInstitutions = new HashSet<String>(); /** //from ww w. ja va2s . co m * Add Enabled workers to the static workerList */ try { if (taskEnableProperties.getProperty(FedoraAppConstants.TASK_ENABLE_PROPERTY, false)) { logger.info("WokerTimer getRemoteConfiguredInstitutions() "); remoteConfiguredInstitutions = FedoraAppUtil.getRemoteConfiguredInstitutions(); logger.info("WokerTimer remoteConfigureInstitutions: " + remoteConfiguredInstitutions); logger.info("WokerTimer getTaskConfiguredInstitutions() "); taskConfiguredInstitutions = FedoraAppUtil.getTaskConfiguredInstitutions(); logger.info("WokerTimer taskConfigureInstitutions: " + taskConfiguredInstitutions); remoteConfiguredInstitutions.addAll(taskConfiguredInstitutions); Object[] remoteInstitutionsAsArray = remoteConfiguredInstitutions.toArray(); for (int i = 0; i < remoteInstitutionsAsArray.length; i++) { // batchName is of type codu_ectd_REMOTE String batchSetName = (String) remoteInstitutionsAsArray[i]; // logger.info( "WokerTimer batchSetName="+batchSetName ); String[] tempArray = batchSetName.split("_"); String institution = tempArray[0]; // logger.info( "WokerTimer institution="+institution ); String batchSet = tempArray[1]; // logger.info( "WokerTimer batchSet="+batchSet ); if (taskEnableProperties.getProperty(institution + "_" + batchSet, false)) { if (workerList != null && !workerList.containsKey(batchSetName)) { // worker does not exist yet, so add it to the workerList WorkerInf newWorker = WorkerFactory.getWorker(batchSetName); if (newWorker != null) { // logger.info( "WokerTimer add worker="+batchSetName ); workerList.put(batchSetName, newWorker); } } } else { // The worker is not enabled in taskEnableProperties so remove it from the list. remoteConfiguredInstitutions.remove(batchSetName); } } } } catch (Exception e) { logger.info("ERROR: Getting task enable properties: " + e.getLocalizedMessage()); } /** * Start all workers in the workerList and remove previously started, but now disabled workers from the workerList (this will NOT * stop running background ingest tasks). */ Set<Entry<String, WorkerInf>> workerSet = workerList.entrySet(); Iterator<Entry<String, WorkerInf>> workerIterator = workerSet.iterator(); while (workerIterator.hasNext()) { WorkerInf currentWorker = workerIterator.next().getValue(); // This will allow for the disabling of tasks without restarting the application. if (!remoteConfiguredInstitutions.contains(currentWorker.getName())) { logger.info("Worker:" + currentWorker.getName() + " disabled"); workerList.remove(currentWorker.getName()); } else { logger.info("StartWorker:" + currentWorker.getName()); currentWorker.doWork(); } } }
From source file:org.pentaho.platform.web.http.api.resources.ActionResource.java
/** * Runs the action defined within the provided json feed in the background asynchronously. * * @param actionId the action id, if applicable * @param actionClass the action class name, if applicable * @param actionUser the user invoking the action * @param actionParams the action parameters needed to instantiate and invoke the action * @return a {@link Response}/*from w w w. jav a 2 s . c o m*/ */ @POST @Path("/invoke") @Consumes({ APPLICATION_JSON }) @StatusCodes({ @ResponseCode(code = 200, condition = "Action invoked successfully."), @ResponseCode(code = 400, condition = "Bad input - could not invoke action."), @ResponseCode(code = 401, condition = "User does not have permissions to invoke action"), @ResponseCode(code = 500, condition = "Error while retrieving system resources."), }) public Response invokeAction( @QueryParam(ActionUtil.INVOKER_ASYNC_EXEC) @DefaultValue(ActionUtil.INVOKER_DEFAULT_ASYNC_EXEC_VALUE) String async, @QueryParam(ActionUtil.INVOKER_ACTIONID) String actionId, @QueryParam(ActionUtil.INVOKER_ACTIONCLASS) String actionClass, @QueryParam(ActionUtil.INVOKER_ACTIONUSER) String actionUser, final ActionParams actionParams) { IAction action = null; Map<String, Serializable> params = null; try { action = createActionBean(actionClass, actionId); params = ActionParams.deserialize(action, actionParams); } catch (final Exception e) { logger.error(e.getLocalizedMessage()); // we're not able to get the work item UID at this point WorkItemLifecyclePublisher.publish("?", params, WorkItemLifecyclePhase.FAILED, e.toString()); return Response.status(HttpStatus.SC_BAD_REQUEST).build(); } final String workItemUid = ActionUtil.extractUid(params); WorkItemLifecyclePublisher.publish(workItemUid, params, WorkItemLifecyclePhase.RECEIVED); final boolean isAsyncExecution = Boolean.parseBoolean(async); int httpStatus = HttpStatus.SC_INTERNAL_SERVER_ERROR; // default ( pessimistic ) if (isAsyncExecution) { // default scenario for execution executorService.submit(createCallable(action, actionUser, params)); httpStatus = HttpStatus.SC_ACCEPTED; } else { final IActionInvokeStatus status = createCallable(action, actionUser, params).call(); httpStatus = (status != null && status.getThrowable() == null) ? HttpStatus.SC_OK : HttpStatus.SC_INTERNAL_SERVER_ERROR; } return Response.status(httpStatus).build(); }
From source file:com.epam.dlab.backendapi.resources.base.InfrastructureService.java
public String action(String username, UserEnvironmentResources dto, String iamUser, DockerAction dockerAction) { log.trace("Request the status of resources for user {}: {}", username, dto); String uuid = DockerCommands.generateUUID(); folderListenerExecutor.start(configuration.getImagesDirectory(), configuration.getRequestEnvStatusTimeout(), getFileHandlerCallback(dockerAction, uuid, iamUser)); try {/*from w w w .j a v a 2 s . c o m*/ removeResourcesWithRunningContainers(username, dto); if (!(dto.getResourceList().getHostList().isEmpty() && dto.getResourceList().getClusterList().isEmpty())) { log.trace("Request the status of resources for user {} after filtering: {}", username, dto); commandExecutor.executeAsync(username, uuid, commandBuilder.buildCommand(new RunDockerCommand() .withInteractive().withName(nameContainer(dto.getEdgeUserName(), STATUS, "resources")) .withVolumeForRootKeys(configuration.getKeyDirectory()) .withVolumeForResponse(configuration.getImagesDirectory()) .withVolumeForLog(configuration.getDockerLogDirectory(), Directories.EDGE_LOG_DIRECTORY) .withResource(getResourceType()).withRequestId(uuid) .withConfKeyName(configuration.getAdminKey()) .withActionStatus(configuration.getEdgeImage()), dto)); } else { log.debug("Skipping calling status command. Resource lists are empty"); } } catch (Exception e) { throw new DlabException( "Docker's command \"" + getResourceType() + "\" is fail: " + e.getLocalizedMessage(), e); } return uuid; }
From source file:cn.vlabs.umt.ui.actions.EditTemplateAction.java
public ActionForward saveConfig(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {//from w w w . ja v a2 s . com EditTemplateForm etForm = (EditTemplateForm) form; boolean succ = true; try { String file = request.getSession().getServletContext().getRealPath("/") + "WEB-INF/conf/umt.properties"; PropertyWriter pw = new PropertyWriter(); pw.load(new FileInputStream(file)); pw.setProperty(EmailTemplate.CONFIG_EMAIL, etForm.getEmail()); pw.setProperty(EmailTemplate.CONFIG_PASSWORD, etForm.getPassword()); pw.setProperty(EmailTemplate.CONFIG_SMTP, etForm.getSmtp()); pw.store(new FileOutputStream(file)); } catch (Exception e) { succ = false; log.error(e.getLocalizedMessage()); } EmailConfig emailConfig = new EmailConfig(); emailConfig.setEmail(etForm.getEmail()); emailConfig.setPassword(etForm.getPassword()); emailConfig.setSmtp(etForm.getSmtp()); request.setAttribute("config", emailConfig); request.setAttribute("tabtype", "parameter"); if (succ) { request.setAttribute("succ", "emailtemp.update.success"); } else { request.setAttribute("succ", "emailtemp.update.error"); } request.setAttribute("act", request.getParameter("reAct")); return mapping.getInputForward(); }
From source file:com.github.drbookings.ical.XlsxBookingFactory.java
@Override public Collection<BookingBeanSer> build() { final List<BookingBeanSer> bookings = new ArrayList<>(); FileInputStream stream = null; Workbook workbook = null;/*from w w w . j a v a 2 s .c o m*/ try { stream = new FileInputStream(file); workbook = new HSSFWorkbook(stream); final Sheet sheet = workbook.getSheetAt(0); if (logger.isInfoEnabled()) { logger.info("Processing sheet " + sheet.getSheetName()); } final int indexBookingNumber = FileFormatBookingXLS.getColumnIndexBookingNumber(sheet.getRow(0)); final int indexClientName = FileFormatBookingXLS.getColumnIndexClientName(sheet.getRow(0)); final int indexBookingCheckIn = FileFormatBookingXLS.getColumnIndexCheckIn(sheet.getRow(0)); final int indexBookingCheckOut = FileFormatBookingXLS.getColumnIndexCheckOut(sheet.getRow(0)); final int indexStatus = FileFormatBookingXLS.getColumnIndexStatus(sheet.getRow(0)); final List<Integer> bookingNumbers = new ArrayList<>(); final List<String> guestNames = new ArrayList<>(); final List<String> stati = new ArrayList<>(); final List<LocalDate> bookingCheckIn = new ArrayList<>(); final List<LocalDate> bookingCheckOut = new ArrayList<>(); for (final Row r : sheet) { // skip first row if (r.getRowNum() == 0) { continue; } bookingNumbers.add(FileFormatBookingXLS.getBookingNumber(r.getCell(indexBookingNumber))); guestNames.add(FileFormatBookingXLS.getString(r.getCell(indexClientName))); bookingCheckIn.add(FileFormatBookingXLS.getDate(r.getCell(indexBookingCheckIn))); bookingCheckOut.add(FileFormatBookingXLS.getDate(r.getCell(indexBookingCheckOut))); stati.add(FileFormatBookingXLS.getString(r.getCell(indexStatus))); } if (logger.isDebugEnabled()) { logger.debug("BookingBean numbers: " + bookingNumbers); logger.debug("Guest names: " + guestNames); logger.debug("Check-in dates: " + bookingCheckIn); logger.debug("Check-out dates: " + bookingCheckOut); } if (logger.isInfoEnabled()) { logger.info("Building bookings.. "); } for (int i = 0; i < bookingNumbers.size(); i++) { final int number = bookingNumbers.get(i); final LocalDate checkIn = bookingCheckIn.get(i); final LocalDate checkOut = bookingCheckOut.get(i); final String names = guestNames.get(i); final String status = stati.get(i); if (status.equals("ok")) { final BookingBeanSer bb = new BookingBeanSer(); bb.checkInDate = checkIn; bb.checkOutDate = checkOut; bb.guestName = names; bb.externalId = Integer.toString(number); bookings.add(bb); } else { if (logger.isDebugEnabled()) { logger.debug("Skipping status " + status); } } } } catch (final Exception e) { if (logger.isErrorEnabled()) { logger.error(e.getLocalizedMessage(), e); } } finally { if (workbook != null) { IOUtils.closeQuietly(workbook); } if (stream != null) { IOUtils.closeQuietly(stream); } } return bookings; }
From source file:plbtw.klmpk.barang.hilang.controller.DeveloperController.java
@RequestMapping(method = RequestMethod.POST, produces = "application/json") public CustomResponseMessage addDeveloper(@RequestBody DeveloperRequest developerRequest) { try {//from w w w.j av a 2 s. c o m if (developerService.checkDeveloperExist(developerRequest.getEmail()) != null) { return new CustomResponseMessage(HttpStatus.METHOD_NOT_ALLOWED, "Email Already Used"); } Developer developer = new Developer(); developer.setRole(roleService.getRole(developerRequest.getIdrole())); SecureRandom random = new SecureRandom(); byte bytes[] = new byte[20]; random.nextBytes(bytes); String token = bytes.toString(); developer.setToken(token); developer.setSecretKey(token); developer.setEmail(developerRequest.getEmail()); developer.setPassword(developerRequest.getPassword()); developerService.addDeveloper(developer); List<Developer> result = new ArrayList<>(); result.add(developer); return new CustomResponseMessage(HttpStatus.CREATED, "Developer Has Been Created", result); } catch (Exception ex) { return new CustomResponseMessage(HttpStatus.BAD_REQUEST, ex.getLocalizedMessage()); } }
From source file:com.qperior.gsa.oneboxprovider.implementations.jive.rest.QPJiveJsonObject.java
private MorphDynaBean ensureBeanProperty(Object bean, String name) { try {//from w ww . j a v a2s.c o m return (MorphDynaBean) PropertyUtils.getProperty(bean, name); } catch (Exception exc) { this.log.info("Exception in getting JSON property '" + name + "': " + exc.getLocalizedMessage()); return null; } }
From source file:com.qperior.gsa.oneboxprovider.implementations.jive.rest.QPJiveJsonObject.java
private String ensureStringProperty(Object bean, String name) { try {// ww w. j a v a2 s. c om return (String) PropertyUtils.getProperty(bean, name); } catch (Exception exc) { this.log.info("Exception in getting JSON property '" + name + "': " + exc.getLocalizedMessage()); return null; } }
From source file:com.qperior.gsa.oneboxprovider.implementations.jive.rest.QPJiveJsonObject.java
private Integer ensureIntegerProperty(Object bean, String name) { try {/*from www . j av a 2s. co m*/ return (Integer) PropertyUtils.getProperty(bean, name); } catch (Exception exc) { this.log.info("Exception in getting JSON property '" + name + "': " + exc.getLocalizedMessage()); return null; } }