List of usage examples for java.lang IllegalArgumentException getLocalizedMessage
public String getLocalizedMessage()
From source file:com.maestrodev.plugins.collabnet.FrsCopyWorker.java
public void frsCopy() { try {/*from ww w . ja v a 2s . co m*/ verifyConfiguration(); } catch (IllegalArgumentException e) { logger.info(e.getLocalizedMessage()); setError(e.getLocalizedMessage() + "\n"); return; } CollabNetSession session; try { session = new CollabNetSession(teamForgeUrl, teamForgeUsername, teamForgePassword, new MaestroPluginLog()); } catch (RemoteException e) { String msg = "Failed to login to TeamForge: " + e.getLocalizedMessage(); logger.error(msg, e); setError(msg + "\n"); return; } String projectId; try { projectId = session.findProject(project); } catch (RemoteException e) { logger.error("Exception retrieving TeamForge project: " + e.getLocalizedMessage(), e); setError("Failed to retrieve TeamForge project '" + project + "': " + e.getLocalizedMessage() + "\n"); return; } logger.debug("Found CollabNet project '" + projectId + "'"); setField("projectId", projectId); try { FrsSession frsSession = session.createFrsSession(projectId); String packageId = preparePackage(frsSession); String releaseId = prepareRelease(frsSession, packageId); String fileId = copyArtifact(frsSession, releaseId); setField("fileId", fileId); JSONObject record = addCollabnetReleaseToContext(projectId, packageId, releaseId, Collections.singletonList(fileId)); record.put("mavenGroupId", artifactGroupId); record.put("mavenArtifactId", artifactId); record.put("mavenArtifactId", artifactId); record.put("mavenType", artifactType); record.put("mavenClassifier", artifactClassifier); } catch (RemoteException e) { String msg = e.getLocalizedMessage(); logger.error(msg, e); setError(msg + "\n"); } catch (MalformedURLException e) { String msg = e.getLocalizedMessage(); logger.error(msg, e); setError(msg + "\n"); } catch (ResourceNotFoundException e) { String msg = e.getLocalizedMessage(); logger.error(msg, e); setError(msg + "\n"); } finally { logoff(session); } }
From source file:de.steilerdev.myVerein.server.controller.user.EventController.java
@RequestMapping(produces = "application/json", params = { "id", "response" }, method = RequestMethod.GET) public ResponseEntity<List<String>> getResponsesOfEvent(@RequestParam(value = "response") String responseString, @RequestParam(value = "id") String eventID, @CurrentUser User currentUser) { logger.debug("[{}] Finding all responses of type {} to event {}", currentUser, responseString, eventID); Event event;//from w ww .j a v a 2 s .c o m if (eventID.isEmpty()) { logger.warn("[{}] The event id is not allowed to be empty", currentUser); return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } else if ((event = eventRepository.findEventById(eventID)) == null) { logger.warn("[{}] Unable to gather the specified event with id {}", currentUser, eventID); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } else { EventStatus response; try { response = EventStatus.valueOf(responseString.toUpperCase()); } catch (IllegalArgumentException e) { logger.warn("[{}] Unable to parse response: {}", currentUser, e.getLocalizedMessage()); return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } if (!event.getInvitedUser().containsKey(currentUser.getId())) { logger.warn("[{}] User is not invited to the event"); return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } else { // Filtering invited user matching the response HashMap<String, EventStatus> invitedUser = new HashMap<>(event.getInvitedUser()); List<String> matchingUser = invitedUser.keySet().stream() .filter(userID -> invitedUser.get(userID) == response).collect(Collectors.toList()); logger.info("[{}] Successfully gathered all user matching the response {} for event {}", currentUser, response, event); return new ResponseEntity<>(matchingUser, HttpStatus.OK); } } }
From source file:de.steilerdev.myVerein.server.controller.user.EventController.java
@RequestMapping(produces = "application/json", method = RequestMethod.POST) public ResponseEntity respondToEvent(@RequestParam(value = "response") String responseString, @RequestParam(value = "id") String eventID, @CurrentUser User currentUser) { logger.debug("[{}] Responding to event {} with {}", currentUser, eventID, responseString); Event event;/*from w w w . ja va2s . c o m*/ if (eventID.isEmpty()) { logger.warn("[{}] The event id is not allowed to be empty", currentUser); return new ResponseEntity(HttpStatus.BAD_REQUEST); } else if ((event = eventRepository.findEventById(eventID)) == null) { logger.warn("[{}] Unable to gather the specified event with id {}", currentUser, eventID); return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); } else { EventStatus response; try { response = EventStatus.valueOf(responseString.toUpperCase()); if (response == EventStatus.REMOVED || response == EventStatus.PENDING) { logger.warn("[{}] Unable to select 'removed' or 'pending' as a response for an event"); return new ResponseEntity(HttpStatus.BAD_REQUEST); } } catch (IllegalArgumentException e) { logger.warn("[{}] Unable to parse response: {}", currentUser, e.getLocalizedMessage()); return new ResponseEntity(HttpStatus.BAD_REQUEST); } if (!event.getInvitedUser().containsKey(currentUser.getId())) { logger.warn("[{}] User is not invited to the event"); return new ResponseEntity(HttpStatus.BAD_REQUEST); } else { event.getInvitedUser().put(currentUser.getId(), response); eventRepository.save(event); logger.info("[{}] Successfully responded to event {} with response {}", currentUser, event, response); return new ResponseEntity(HttpStatus.OK); } } }
From source file:org.sakaiproject.nakamura.api.resource.lite.SparseContentResource.java
public SparseContentResource(Content content, Session session, ResourceResolver resourceResolver, String resourcePath) throws StorageClientException { this.content = content; this.session = session; this.contentManager = session.getContentManager(); this.resourceResolver = resourceResolver; this.resourcePath = resourcePath; if (content != null) { Map<String, Object> props = content.getProperties(); metadata = new ResourceMetadata(); metadata.setCharacterEncoding(UTF_8); metadata.setContentLength(StorageClientUtils.toLong(props.get(Content.LENGTH_FIELD))); metadata.setCreationTime(StorageClientUtils.toLong(props.get(Content.CREATED_FIELD))); metadata.setModificationTime(StorageClientUtils.toLong(props.get(Content.LASTMODIFIED_FIELD))); metadata.setResolutionPath(content.getPath()); metadata.setResolutionPathInfo(content.getPath()); if (content.hasProperty(Content.MIMETYPE_FIELD)) { metadata.setContentType((String) content.getProperty(Content.MIMETYPE_FIELD)); }/*from w w w . j a v a 2 s . co m*/ } else { // TODO Better argument checking? Throw IAE? IllegalArgumentException iae = new IllegalArgumentException("content is null"); logger.warn(iae.getLocalizedMessage(), iae); } }
From source file:org.apache.archiva.scheduler.indexing.maven.DefaultDownloadRemoteIndexScheduler.java
@Override public void scheduleDownloadRemote(String repositoryId, boolean now, boolean fullDownload) throws DownloadRemoteIndexException { try {/*from www . java 2 s. c om*/ org.apache.archiva.repository.RemoteRepository remoteRepo = repositoryRegistry .getRemoteRepository(repositoryId); if (remoteRepo == null) { log.warn("ignore scheduleDownloadRemote for repo with id {} as not exists", repositoryId); return; } if (!remoteRepo.supportsFeature(RemoteIndexFeature.class)) { log.warn("ignore scheduleDownloadRemote for repo with id {}. Does not support remote index.", repositoryId); return; } RemoteIndexFeature rif = remoteRepo.getFeature(RemoteIndexFeature.class).get(); NetworkProxy networkProxy = null; if (StringUtils.isNotBlank(rif.getProxyId())) { networkProxy = networkProxyAdmin.getNetworkProxy(rif.getProxyId()); if (networkProxy == null) { log.warn( "your remote repository is configured to download remote index trought a proxy we cannot find id:{}", rif.getProxyId()); } } DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest = new DownloadRemoteIndexTaskRequest() // .setRemoteRepository(remoteRepo) // .setNetworkProxy(networkProxy) // .setFullDownload(fullDownload) // .setWagonFactory(wagonFactory) // .setIndexUpdater(indexUpdater) // .setIndexPacker(this.indexPacker); if (now) { log.info("schedule download remote index for repository {}", remoteRepo.getId()); // do it now taskScheduler.schedule( new DownloadRemoteIndexTask(downloadRemoteIndexTaskRequest, this.runningRemoteDownloadIds), new Date()); } else { log.info("schedule download remote index for repository {} with cron expression {}", remoteRepo.getId(), remoteRepo.getSchedulingDefinition()); try { CronTrigger cronTrigger = new CronTrigger(remoteRepo.getSchedulingDefinition()); taskScheduler.schedule(new DownloadRemoteIndexTask(downloadRemoteIndexTaskRequest, this.runningRemoteDownloadIds), cronTrigger); } catch (IllegalArgumentException e) { log.warn("Unable to schedule remote index download: {}", e.getLocalizedMessage()); } if (rif.isDownloadRemoteIndexOnStartup()) { log.info( "remote repository {} configured with downloadRemoteIndexOnStartup schedule now a download", remoteRepo.getId()); taskScheduler.schedule(new DownloadRemoteIndexTask(downloadRemoteIndexTaskRequest, this.runningRemoteDownloadIds), new Date()); } } } catch (RepositoryAdminException e) { log.error(e.getMessage(), e); throw new DownloadRemoteIndexException(e.getMessage(), e); } }
From source file:org.opentaps.common.reporting.ChartViewHandler.java
public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException { /*//from w w w . j a va 2 s . c o m * Looks for parameter "chart" first. Send this temporary image files * to client if it exists and return. */ String chartFileName = UtilCommon.getParameter(request, "chart"); if (UtilValidate.isNotEmpty(chartFileName)) { try { ServletUtilities.sendTempFile(chartFileName, response); if (chartFileName.indexOf(ServletUtilities.getTempOneTimeFilePrefix()) != -1) { // delete temporary file File file = new File(System.getProperty("java.io.tmpdir"), chartFileName); file.delete(); } } catch (IOException ioe) { Debug.logError(ioe.getLocalizedMessage(), module); } return; } /* * Next option eliminate need to store chart in file system. Some event handler * included in request chain prior to this view handler can prepare ready to use * instance of JFreeChart and place it to request attribute chartContext. * Currently chartContext should be Map<String, Object> and we expect to see in it: * "charObject" : JFreeChart * "width" : positive Integer * "height" : positive Integer * "encodeAlpha" : Boolean (optional) * "compressRatio" : Integer in range 0-9 (optional) */ Map<String, Object> chartContext = (Map<String, Object>) request.getAttribute("chartContext"); if (UtilValidate.isNotEmpty(chartContext)) { try { sendChart(chartContext, response); } catch (IOException ioe) { Debug.logError(ioe.getLocalizedMessage(), module); } return; } /* * Prepare context for next options */ Map<String, Object> callContext = FastMap.newInstance(); callContext.put("parameters", UtilHttp.getParameterMap(request)); callContext.put("delegator", request.getAttribute("delegator")); callContext.put("dispatcher", request.getAttribute("dispatcher")); callContext.put("userLogin", request.getSession().getAttribute("userLogin")); callContext.put("locale", UtilHttp.getLocale(request)); /* * view-map attribute "page" may contain BeanShell script in component * URL format that should return chartContext map. */ if (UtilValidate.isNotEmpty(page) && UtilValidate.isUrl(page) && page.endsWith(".bsh")) { try { chartContext = (Map<String, Object>) BshUtil.runBshAtLocation(page, callContext); if (UtilValidate.isNotEmpty(chartContext)) { sendChart(chartContext, response); } } catch (GeneralException ge) { Debug.logError(ge.getLocalizedMessage(), module); } catch (IOException ioe) { Debug.logError(ioe.getLocalizedMessage(), module); } return; } /* * As last resort we can decide that "page" attribute contains class name and "info" * contains method Map<String, Object> getSomeChart(Map<String, Object> context). * There are parameters, delegator, dispatcher, userLogin and locale in the context. * Should return chartContext. */ if (UtilValidate.isNotEmpty(page) && UtilValidate.isNotEmpty(info)) { Class handler = null; synchronized (this) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { handler = loader.loadClass(page); if (handler != null) { Method runMethod = handler.getMethod(info, new Class[] { Map.class }); chartContext = (Map<String, Object>) runMethod.invoke(null, callContext); if (UtilValidate.isNotEmpty(chartContext)) { sendChart(chartContext, response); } } } catch (ClassNotFoundException cnfe) { Debug.logError(cnfe.getLocalizedMessage(), module); } catch (SecurityException se) { Debug.logError(se.getLocalizedMessage(), module); } catch (NoSuchMethodException nsme) { Debug.logError(nsme.getLocalizedMessage(), module); } catch (IllegalArgumentException iae) { Debug.logError(iae.getLocalizedMessage(), module); } catch (IllegalAccessException iace) { Debug.logError(iace.getLocalizedMessage(), module); } catch (InvocationTargetException ite) { Debug.logError(ite.getLocalizedMessage(), module); } catch (IOException ioe) { Debug.logError(ioe.getLocalizedMessage(), module); } } } // Why you disturb me? throw new ViewHandlerException( "In order to generate chart you have to provide chart object or file name. There are no such data in request. Please read comments to ChartViewHandler class."); }
From source file:org.apache.archiva.scheduler.indexing.DefaultDownloadRemoteIndexScheduler.java
@Override public void scheduleDownloadRemote(String repositoryId, boolean now, boolean fullDownload) throws DownloadRemoteIndexException { try {/* w ww. j ava 2 s .c o m*/ RemoteRepository remoteRepository = remoteRepositoryAdmin.getRemoteRepository(repositoryId); if (remoteRepository == null) { log.warn("ignore scheduleDownloadRemote for repo with id {} as not exists", repositoryId); return; } NetworkProxy networkProxy = null; if (StringUtils.isNotBlank(remoteRepository.getRemoteDownloadNetworkProxyId())) { networkProxy = networkProxyAdmin .getNetworkProxy(remoteRepository.getRemoteDownloadNetworkProxyId()); if (networkProxy == null) { log.warn( "your remote repository is configured to download remote index trought a proxy we cannot find id:{}", remoteRepository.getRemoteDownloadNetworkProxyId()); } } DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest = new DownloadRemoteIndexTaskRequest() .setRemoteRepository(remoteRepository).setNetworkProxy(networkProxy) .setFullDownload(fullDownload).setWagonFactory(wagonFactory) .setRemoteRepositoryAdmin(remoteRepositoryAdmin).setIndexUpdater(indexUpdater) .setIndexPacker(this.indexPacker); if (now) { log.info("schedule download remote index for repository {}", remoteRepository.getId()); // do it now taskScheduler.schedule( new DownloadRemoteIndexTask(downloadRemoteIndexTaskRequest, this.runningRemoteDownloadIds), new Date()); } else { log.info("schedule download remote index for repository {} with cron expression {}", remoteRepository.getId(), remoteRepository.getCronExpression()); try { CronTrigger cronTrigger = new CronTrigger(remoteRepository.getCronExpression()); taskScheduler.schedule(new DownloadRemoteIndexTask(downloadRemoteIndexTaskRequest, this.runningRemoteDownloadIds), cronTrigger); } catch (IllegalArgumentException e) { log.warn("Unable to schedule remote index download: {}", e.getLocalizedMessage()); } if (remoteRepository.isDownloadRemoteIndexOnStartup()) { log.info( "remote repository {} configured with downloadRemoteIndexOnStartup schedule now a download", remoteRepository.getId()); taskScheduler.schedule(new DownloadRemoteIndexTask(downloadRemoteIndexTaskRequest, this.runningRemoteDownloadIds), new Date()); } } } catch (RepositoryAdminException e) { log.error(e.getMessage(), e); throw new DownloadRemoteIndexException(e.getMessage(), e); } }
From source file:com.ruizhan.hadoop.hdfs.FsShell.java
/** * run/*from w ww . j a v a 2s .c o m*/ */ public int run(String argv[]) throws Exception { // initialize FsShell init(); int exitCode = -1; if (argv.length < 1) { printUsage(System.err); } else { String cmd = argv[0]; Command instance = null; try { instance = commandFactory.getInstance(cmd); if (instance == null) { throw new UnknownCommandException(); } exitCode = instance.run(Arrays.copyOfRange(argv, 1, argv.length)); } catch (IllegalArgumentException e) { displayError(cmd, e.getLocalizedMessage()); if (instance != null) { printInstanceUsage(System.err, instance); } } catch (Exception e) { // instance.run catches IOE, so something is REALLY wrong if here LOG.debug("Error", e); displayError(cmd, "Fatal internal error"); e.printStackTrace(System.err); } } return exitCode; }
From source file:org.apache.hadoop.hdfs.HighTideShell.java
/** * run// www . j a v a2s . c o m */ public int run(String argv[]) throws Exception { if (argv.length < 1) { printUsage(""); return -1; } int exitCode = -1; int i = 0; String cmd = argv[i++]; // // verify that we have enough command line parameters // if ("-showConfig".equals(cmd)) { if (argv.length < 1) { printUsage(cmd); return exitCode; } } try { if ("-showConfig".equals(cmd)) { initializeRpc(conf, HighTideNode.getAddress(conf)); exitCode = showConfig(cmd, argv, i); } else { exitCode = -1; System.err.println(cmd.substring(1) + ": Unknown command"); printUsage(""); } } catch (IllegalArgumentException arge) { exitCode = -1; System.err.println(cmd.substring(1) + ": " + arge.getLocalizedMessage()); printUsage(cmd); } catch (RemoteException e) { // // This is a error returned by hightidenode server. Print // out the first line of the error mesage, ignore the stack trace. exitCode = -1; try { String[] content; content = e.getLocalizedMessage().split("\n"); System.err.println(cmd.substring(1) + ": " + content[0]); } catch (Exception ex) { System.err.println(cmd.substring(1) + ": " + ex.getLocalizedMessage()); } } catch (IOException e) { // // IO exception encountered locally. // exitCode = -1; System.err.println(cmd.substring(1) + ": " + e.getLocalizedMessage()); } catch (Exception re) { exitCode = -1; System.err.println(cmd.substring(1) + ": " + re.getLocalizedMessage()); } finally { } return exitCode; }
From source file:org.collectionspace.chain.csp.webui.misc.WebLoginStatus.java
private void addPermsToCache(String userId, String tenantId, JSONObject perms) { // Update cache with the permissions for this user and tenant. try {//from w w w . j a v a 2 s .c o m userPermsCache.put(new Element(buildUserPermsCacheKey(userId, tenantId), perms)); } catch (IllegalStateException ise) { log.warn("WebLoginStatus - userperms cache not active: " + ise.getLocalizedMessage()); } catch (CacheException ce) { log.warn("WebLoginStatus - userperms cache exception:" + ce.getLocalizedMessage()); } catch (IllegalArgumentException iae) { throw new RuntimeException( "WebLoginStatus - tried to cache with null perms!:" + iae.getLocalizedMessage()); } }