List of usage examples for java.lang IllegalArgumentException getLocalizedMessage
public String getLocalizedMessage()
From source file:org.linagora.linshare.webservice.interceptor.IllegalArgumentExceptionMapper.java
@Override public Response toResponse(IllegalArgumentException exception) { logger.error("A IllegalArgumentException was caught : " + exception.getLocalizedMessage()); logger.debug("Stacktrace: ", exception); ErrorDto errorDto = new ErrorDto(BusinessErrorCode.WEBSERVICE_FAULT.getCode(), " : " + exception.getMessage()); ResponseBuilder response = Response.status(HttpStatus.SC_BAD_REQUEST); response.entity(errorDto);/*from w w w . j av a2s .co m*/ return response.build(); }
From source file:org.voltdb.bulkloader.VoltDBCLISpec.java
@Override public void postParse(CLIDriver driver) { String[] hostSpecs = driver.getCommaSeparatedStrings("servers", "localhost"); Long defaultPort = driver.getNumber("port", (long) Client.VOLTDB_SERVER_PORT); this.opts.servers = new HostAndPort[hostSpecs.length]; for (int i = 0; i < hostSpecs.length; ++i) { try {/*from w w w . ja v a 2 s . c om*/ this.opts.servers[i] = HostAndPort.fromString(hostSpecs[i]); if (!this.opts.servers[i].hasPort()) { this.opts.servers[i] = HostAndPort.fromParts(this.opts.servers[i].getHostText(), defaultPort.intValue()); } } catch (IllegalArgumentException e) { driver.addError("Bad host[:port]: %s: %s", hostSpecs[i], e.getLocalizedMessage()); } } this.opts.user = driver.getString("user"); this.opts.password = driver.getString("password"); }
From source file:cross.io.AFragmentCommandServiceLoader.java
/** * Returns the list of available user commands, given by class names in the <code>fragmentCommands</code> collection. * * @param of the object factory/*w w w .ja v a2 s. com*/ * @return the list of user commands */ public List<AFragmentCommand> getAvailableUserCommands(ObjectFactory of) { HashSet<AFragmentCommand> s = new HashSet<>(); for (String uc : fragmentCommands) { try { AFragmentCommand af = of.instantiate(uc, AFragmentCommand.class); s.add(af); } catch (IllegalArgumentException iae) { log.warn(iae.getLocalizedMessage()); } } return createSortedListFromSet(s, new ClassNameLexicalComparator()); }
From source file:it.geosolutions.geobatch.imagemosaic.ImageMosaicUpdater.java
/** * Removes from the passed addFileList already present (into the passed * dataStore) features //from w ww .j a v a2 s .c o m * * TODO this can be skipped to perform update (instead * of perform remove+update) */ private static boolean purgeAddFileList(List<File> addFileList, DataStore dataStore, String store, final String locationKey, final File baseDir, boolean absolute) { if (addFileList.isEmpty()) { if (LOGGER.isInfoEnabled()) { LOGGER.info("Add list is empty"); } // we're not expecting empty list here return false; } Filter addFilter = null; // calculate the query try { addFilter = getQuery(addFileList, absolute, locationKey); if (addFilter == null) { // if (LOGGER.isInfoEnabled()) { LOGGER.info("The ADD query is null. Should not happen"); } return false; } } catch (IllegalArgumentException e) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(e.getLocalizedMessage()); } } catch (CQLException e) { if (LOGGER.isErrorEnabled()) { LOGGER.error("Unable to build a query. Message: " + e, e); } return false; } final String handle = "ImageMosaic:" + Thread.currentThread().getId(); final Transaction transaction = new DefaultTransaction(handle); /* * CHECK IF ADD FILES ARE ALREADY INTO THE LAYER */ FeatureReader<SimpleFeatureType, SimpleFeature> fr = null; try { // get the schema if this feature final SimpleFeatureType schema = dataStore.getSchema(store); /* * TODO to save time we could use the store name which should be the * same */ final Query q = new Query(schema.getTypeName(), addFilter); fr = dataStore.getFeatureReader(q, transaction); if (fr == null) { if (LOGGER.isErrorEnabled()) { LOGGER.error("The FeatureReader is null, it's impossible to get a reader on the dataStore: " + dataStore.toString()); } return false; } while (fr.hasNext()) { SimpleFeature feature = fr.next(); if (feature != null) { String path = (String) feature.getAttribute(locationKey); // remove from the list the image which is already // into the layer if (absolute) { File added = new File(baseDir, path); addFileList.remove(added); if (LOGGER.isWarnEnabled()) { LOGGER.warn("The file: " + path + " is removed from the addFiles list because it is already present into the layer"); } } else { // check relative paths Iterator<File> it = addFileList.iterator(); while (it.hasNext()) { File file = it.next(); if (file.getName().equals(path)) { it.remove(); if (LOGGER.isWarnEnabled()) { LOGGER.warn("The file: " + path + " is removed from the addFiles list because it is already present into the layer"); } } } } } else { if (LOGGER.isErrorEnabled()) { LOGGER.error("Problem getting the next feature: it is null!"); } } } //commit transaction.commit(); } catch (Exception e) { if (LOGGER.isErrorEnabled()) { LOGGER.error(e.getLocalizedMessage(), e); } try { transaction.rollback(); } catch (IOException ioe) { if (LOGGER.isErrorEnabled()) { LOGGER.error(ioe.getLocalizedMessage(), ioe); } } return false; } finally { try { transaction.close(); } catch (Throwable t) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("problem closing transaction: " + t.getLocalizedMessage(), t); } } try { if (fr != null) { fr.close(); fr = null; } } catch (Throwable t) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("problem closing transaction: " + t.getLocalizedMessage(), t); } } } return true; }
From source file:com.maestrodev.plugins.collabnet.FrsDeployWorker.java
public void frsDeploy() { try {//www .ja v a 2 s . 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); List<String> fileIds = uploadArtifacts(files, releaseId, frsSession); setField("fileIds", fileIds); addCollabnetReleaseToContext(projectId, packageId, releaseId, fileIds); } 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:org.artifactory.rest.resource.search.types.BuildArtifactsSearchResource.java
@POST @Consumes({ BuildRestConstants.MT_BUILD_ARTIFACTS_REQUEST, MediaType.APPLICATION_JSON }) @Produces({ SearchRestConstants.MT_BUILD_ARTIFACTS_SEARCH_RESULT, MediaType.APPLICATION_JSON }) public Response get(BuildArtifactsRequest buildArtifactsRequest) throws IOException { if (authorizationService.isAnonUserAndAnonBuildInfoAccessDisabled()) { throw new AuthorizationRestException(BuildResource.anonAccessDisabledMsg); }// w w w . j a va 2s. co m if (isBlank(buildArtifactsRequest.getBuildName())) { return Response.status(Response.Status.BAD_REQUEST).entity("Cannot search without build name.").build(); } boolean buildNumberIsBlank = isBlank(buildArtifactsRequest.getBuildNumber()); boolean buildStatusIsBlank = isBlank(buildArtifactsRequest.getBuildStatus()); if (buildNumberIsBlank && buildStatusIsBlank) { return Response.status(Response.Status.BAD_REQUEST) .entity("Cannot search without build number or build status.").build(); } if (!buildNumberIsBlank && !buildStatusIsBlank) { return Response.status(Response.Status.BAD_REQUEST) .entity("Cannot search with both build number and build status parameters, " + "please omit build number if your are looking for latest build by status " + "or omit build status to search for specific build version.") .build(); } if (!authorizationService.isAuthenticated()) { throw new AuthorizationRestException(); } Map<FileInfo, String> buildArtifacts; try { buildArtifacts = restAddon.getBuildArtifacts(buildArtifactsRequest); } catch (IllegalArgumentException e) { return Response.status(Response.Status.BAD_REQUEST).entity(e.getLocalizedMessage()).build(); } if (buildArtifacts == null || buildArtifacts.isEmpty()) { throw new NotFoundException( String.format("Could not find any build artifacts for build '%s' number '%s'.", buildArtifactsRequest.getBuildName(), buildArtifactsRequest.getBuildNumber())); } DownloadRestSearchResult downloadRestSearchResult = new DownloadRestSearchResult(); for (FileInfo fileInfo : buildArtifacts.keySet()) { String downloadUri = RestUtils.buildDownloadUri(request, fileInfo.getRepoKey(), fileInfo.getRelPath()); downloadRestSearchResult.results.add(new DownloadRestSearchResult.SearchEntry(downloadUri)); } return Response.ok(downloadRestSearchResult).build(); }
From source file:org.kitodo.production.services.data.ImportService.java
/** * Load catalog names from OPAC configuration file and return them as a list of Strings. * * @return list of catalog names//from w ww .j a v a2 s .c o m */ public List<String> getAvailableCatalogs() { try { return OPACConfig.getCatalogs(); } catch (IllegalArgumentException e) { logger.error(e.getLocalizedMessage()); throw new IllegalArgumentException("Error: no supported OPACs found in configuration file!"); } }
From source file:org.kitodo.production.services.data.ImportService.java
/** * Load ExternalDataImportInterface implementation with KitodoServiceLoader and perform given query string * with loaded module./*from w w w . j av a2 s. com*/ * * @param searchField field to query * @param searchTerm given search term * @param catalogName catalog to search * @return search result */ public SearchResult performSearch(String searchField, String searchTerm, String catalogName) { importModule = initializeImportModule(); try { OPACConfig.getOPACConfiguration(catalogName); } catch (IllegalArgumentException e) { logger.error(e.getLocalizedMessage()); throw new IllegalArgumentException("Error: OPAC '" + catalogName + "' is not supported!"); } return importModule.search(catalogName, searchField, searchTerm, 10); }
From source file:org.kitodo.production.services.data.ImportService.java
/** * Load search fields of catalog with given name 'opac' from OPAC configuration file and return them as a list * of Strings.//from w w w. j av a2 s . c o m * * @param opac name of catalog whose search fields are loaded * @return list containing search fields */ public List<String> getAvailableSearchFields(String opac) { try { HierarchicalConfiguration searchFields = OPACConfig.getSearchFields(opac); List<String> fields = new ArrayList<>(); for (HierarchicalConfiguration searchField : searchFields.configurationsAt("searchField")) { fields.add(searchField.getString("[@label]")); } return fields; } catch (IllegalArgumentException e) { logger.error(e.getLocalizedMessage()); throw new IllegalArgumentException("Error: OPAC '" + opac + "' is not supported!"); } }
From source file:org.piwik.java.tracking.PiwikTrackerTest.java
/** * Test of sendBulkRequest method, of class PiwikTracker. *//*from www . java 2s .c o m*/ @Test public void testSendBulkRequest_Iterable_StringTT() throws Exception { try { List<PiwikRequest> requests = new ArrayList<>(); HttpClient client = mock(HttpClient.class); PiwikRequest request = mock(PiwikRequest.class); doReturn("query").when(request).getQueryString(); requests.add(request); doReturn(client).when(piwikTracker).getHttpClient(); piwikTracker.sendBulkRequest(requests, "1"); fail("Exception should have been thrown."); } catch (IllegalArgumentException e) { assertEquals("1 is not 32 characters long.", e.getLocalizedMessage()); } }